From 1acf74c13bea9b224facf3eef232e4ace4494837 Mon Sep 17 00:00:00 2001 From: dangapay <divin.angapay@lam.fr> Date: Thu, 6 Oct 2022 11:47:54 +0200 Subject: [PATCH] add test for admin/instance/dataset/components/attribute/general --- .../attribute/general/index.spec.ts | 17 ++++++ .../general/table-general.component.spec.ts | 37 +++++++++++++ .../general/tr-general.component.spec.ts | 54 +++++++++++++++++++ 3 files changed, 108 insertions(+) create mode 100644 client/src/app/admin/instance/dataset/components/attribute/general/index.spec.ts create mode 100644 client/src/app/admin/instance/dataset/components/attribute/general/table-general.component.spec.ts create mode 100644 client/src/app/admin/instance/dataset/components/attribute/general/tr-general.component.spec.ts 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 00000000..82cb0587 --- /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 00000000..93d9d4a0 --- /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 00000000..dbf19c1e --- /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 }); + }) +}); + + -- GitLab