Skip to content
Snippets Groups Projects
Commit c181968c authored by Angapay Divin's avatar Angapay Divin
Browse files

add test for admin/instance/dataset/components/attribute/detail

parent b8dcbe08
No related branches found
No related tags found
2 merge requests!72Develop,!66Resolve "Tests client: Tester le module dataset de la partie admin->instance"
/**
* This file is part of Anis Client.
*
* @copyright Laboratoire d'Astrophysique de Marseille / CNRS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { detailComponents } from './index';
describe('[admin][instance][dataset][components][attribute][detail] index', () => {
it('Test detail index components', () => {
expect(detailComponents.length).toEqual(2);
});
});
/**
* This file is part of Anis Client.
*
* @copyright Laboratoire d'Astrophysique de Marseille / CNRS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { TableDetailComponent } from './table-detail.component';
describe('[admin][instance][dataset][components][attribute][detail] TableDetailComponent', () => {
let component: TableDetailComponent;
let fixture: ComponentFixture<TableDetailComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
TableDetailComponent,
],
imports: [
BrowserAnimationsModule,
],
});
fixture = TestBed.createComponent(TableDetailComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create the component', () => {
expect(component).toBeTruthy();
});
});
/**
* This file is part of Anis Client.
*
* @copyright Laboratoire d'Astrophysique de Marseille / CNRS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ReactiveFormsModule } from '@angular/forms';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { Attribute, OutputFamily } from 'src/app/metamodel/models';
import { TrDetailComponent } from './tr-detail.component';
describe('[admin][instance][dataset][components][attribute][detail] TrDetailComponent', () => {
let component: TrDetailComponent;
let fixture: ComponentFixture<TrDetailComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
TrDetailComponent,
],
imports: [
BrowserAnimationsModule,
ReactiveFormsModule
],
});
fixture = TestBed.createComponent(TrDetailComponent);
component = fixture.componentInstance;
let attribute: Attribute;
component.attribute = { ...attribute, name: 'test', id_detail_output_category: 0, detail_display: 0 };
fixture.detectChanges();
});
it('should create the component', () => {
expect(component).toBeTruthy();
});
it('detailOutputCategoryOnChange() should set form.id_detail_output_category to null', () => {
component.form.controls.id_detail_output_category.setValue('');
expect(component.form.controls.id_detail_output_category.value).toEqual('');
component.detailOutputCategoryOnChange();
expect(component.form.controls.id_detail_output_category.value).toEqual(null);
});
it('getOutputFamilyLabel(idOutputFamilly: number) should return test1', () => {
let outputFamilyList: OutputFamily[] = [
{ display: 0, id: 1, label: 'test0', opened: false },
{ display: 0, id: 2, label: 'test1', opened: false },
{ display: 0, id: 3, label: 'test2', opened: false }
]
component.outputFamilyList = outputFamilyList;
let result: string = component.getOutputFamilyLabel(2);
expect(result).toEqual('test1');
})
it('submit() should emit with attribute and form.value', () => {
let spy = jest.spyOn(component.save, 'emit');
component.submit();
expect(spy).toHaveBeenCalledTimes(1);
expect(spy).toHaveBeenCalledWith({ ...component.attribute, ...component.form.value });
})
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment