diff --git a/client/src/app/admin/instance/dataset/components/attribute/detail/index.spec.ts b/client/src/app/admin/instance/dataset/components/attribute/detail/index.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..993b73ad962e67735289fb8b9d6d85dd053fe4b0 --- /dev/null +++ b/client/src/app/admin/instance/dataset/components/attribute/detail/index.spec.ts @@ -0,0 +1,17 @@ +/** + * 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); + }); +}); + diff --git a/client/src/app/admin/instance/dataset/components/attribute/detail/table-detail.component.spec.ts b/client/src/app/admin/instance/dataset/components/attribute/detail/table-detail.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..e7beb8f1316d586b246f699b52c190a4412602d4 --- /dev/null +++ b/client/src/app/admin/instance/dataset/components/attribute/detail/table-detail.component.spec.ts @@ -0,0 +1,36 @@ +/** + * 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(); + }); +}); + diff --git a/client/src/app/admin/instance/dataset/components/attribute/detail/tr-detail.component.spec.ts b/client/src/app/admin/instance/dataset/components/attribute/detail/tr-detail.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..e562209fb73d1c23fbd2303bb5b55ef02d755634 --- /dev/null +++ b/client/src/app/admin/instance/dataset/components/attribute/detail/tr-detail.component.spec.ts @@ -0,0 +1,63 @@ +/** + * 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 }); + }) +}); +