diff --git a/client/src/app/admin/instance/dataset/components/attribute/general/index.spec.ts b/client/src/app/admin/instance/dataset/components/attribute/general/index.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..82cb0587851f7943eecbac656e8e125aa374c8e8 --- /dev/null +++ b/client/src/app/admin/instance/dataset/components/attribute/general/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 { generalComponents } from './index'; + +describe('[admin][instance][dataset][components][attribute][general] index', () => { + it('Test general index components', () => { + expect(generalComponents.length).toEqual(2); + }); +}); + diff --git a/client/src/app/admin/instance/dataset/components/attribute/general/table-general.component.spec.ts b/client/src/app/admin/instance/dataset/components/attribute/general/table-general.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..93d9d4a01578ecae4228190b77726d4829c3c8bd --- /dev/null +++ b/client/src/app/admin/instance/dataset/components/attribute/general/table-general.component.spec.ts @@ -0,0 +1,37 @@ +/** + * 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 { TableGeneralComponent } from './table-general.component'; + +describe('[admin][instance][dataset][components][attribute][general] TableGeneralComponent', () => { + let component: TableGeneralComponent; + let fixture: ComponentFixture<TableGeneralComponent>; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [ + TableGeneralComponent, + ], + imports: [ + BrowserAnimationsModule, + ], + }); + fixture = TestBed.createComponent(TableGeneralComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create the component', () => { + expect(component).toBeTruthy(); + }); +}); + + diff --git a/client/src/app/admin/instance/dataset/components/attribute/general/tr-general.component.spec.ts b/client/src/app/admin/instance/dataset/components/attribute/general/tr-general.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..dbf19c1e8536716505bf99a2730c83224207362f --- /dev/null +++ b/client/src/app/admin/instance/dataset/components/attribute/general/tr-general.component.spec.ts @@ -0,0 +1,54 @@ +/** + * 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 { Component } from '@angular/core'; +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 { TrGeneralComponent } from './tr-general.component'; +@Component({ + selector: 'app-delete-btn' +}) +class DeleteBtnComponent { } +describe('[admin][instance][dataset][components][attribute][general] TrDetailComponent', () => { + let component: TrGeneralComponent; + let fixture: ComponentFixture<TrGeneralComponent>; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [ + TrGeneralComponent, + DeleteBtnComponent + ], + imports: [ + BrowserAnimationsModule, + ReactiveFormsModule + ], + }); + fixture = TestBed.createComponent(TrGeneralComponent); + component = fixture.componentInstance; + let attribute: Attribute; + component.attribute = { ...attribute, name: 'test', id: 0, label: 'test', form_label: 'test', description: 'test', primary_key: false }; + fixture.detectChanges(); + }); + + it('should create the component', () => { + expect(component).toBeTruthy(); + }); + + 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 }); + }) +}); + +