diff --git a/client/src/app/admin/instance/dataset/components/attribute/index.spec.ts b/client/src/app/admin/instance/dataset/components/attribute/index.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..022a4efac19f88a426e2a44899490a075bbf4890 --- /dev/null +++ b/client/src/app/admin/instance/dataset/components/attribute/index.spec.ts @@ -0,0 +1,18 @@ +/** + * 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 { attributeComponents } from './index'; + +describe('[admin][instance][dataset][components][attribute] index', () => { + it('Test output index components', () => { + expect(attributeComponents.length).toEqual(6); + }); +}); + + diff --git a/client/src/app/admin/instance/dataset/components/attribute/output/tr-output.component.spec.ts b/client/src/app/admin/instance/dataset/components/attribute/output/tr-output.component.spec.ts index 65cf844aad023023fc02f4d07746579e512a5b7d..cf15cb9550928d82865e3c553ccd9a4a5039bd7b 100644 --- a/client/src/app/admin/instance/dataset/components/attribute/output/tr-output.component.spec.ts +++ b/client/src/app/admin/instance/dataset/components/attribute/output/tr-output.component.spec.ts @@ -7,58 +7,57 @@ * 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 { 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 { TrOutputComponent } from './tr-output.component'; - - describe('[admin][instance][dataset][components][attribute][] TrOutputComponent', () => { - let component: TrOutputComponent; - let fixture: ComponentFixture<TrOutputComponent>; - - beforeEach(() => { - TestBed.configureTestingModule({ - declarations: [ + +describe('[admin][instance][dataset][components][attribute][] TrOutputComponent', () => { + let component: TrOutputComponent; + let fixture: ComponentFixture<TrOutputComponent>; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [ TrOutputComponent, - ], - imports: [ - BrowserAnimationsModule, - ReactiveFormsModule - ], - }); - fixture = TestBed.createComponent(TrOutputComponent); - component = fixture.componentInstance; - let attribute: Attribute; - component.attribute = { ...attribute, name: 'test', output_display: 0, id_output_category: 0 , selected: true}; - fixture.detectChanges(); - }); - - it('should create the component', () => { - expect(component).toBeTruthy(); - }); - it('outputCategoryOnChange() should set form.id_output_category to null', () => { - component.form.controls.id_output_category.setValue(''); - expect(component.form.controls.id_output_category.value).toEqual(''); - component.outputCategoryOnChange(); - expect(component.form.controls.id_output_category.value).toEqual(null); - }); - it('getOutputFamilyLabel(idOutputFamilly: number) should return test2', () => { - 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(3); - expect(result).toEqual('test2'); - }) - 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 }); - }) - }); - - \ No newline at end of file + ], + imports: [ + BrowserAnimationsModule, + ReactiveFormsModule + ], + }); + fixture = TestBed.createComponent(TrOutputComponent); + component = fixture.componentInstance; + let attribute: Attribute; + component.attribute = { ...attribute, name: 'test', output_display: 0, id_output_category: 0, selected: true }; + fixture.detectChanges(); + }); + + it('should create the component', () => { + expect(component).toBeTruthy(); + }); + it('outputCategoryOnChange() should set form.id_output_category to null', () => { + component.form.controls.id_output_category.setValue(''); + expect(component.form.controls.id_output_category.value).toEqual(''); + component.outputCategoryOnChange(); + expect(component.form.controls.id_output_category.value).toEqual(null); + }); + it('getOutputFamilyLabel(idOutputFamilly: number) should return test2', () => { + 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(3); + expect(result).toEqual('test2'); + }) + 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 }); + }) +}); + diff --git a/client/src/app/admin/instance/dataset/components/attribute/result/index.spec.ts b/client/src/app/admin/instance/dataset/components/attribute/result/index.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..a5a869c86f2ab07372f8481cf0dab3590985f6b5 --- /dev/null +++ b/client/src/app/admin/instance/dataset/components/attribute/result/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 { resultComponents } from './index'; + +describe('[admin][instance][dataset][components][attribute][result] index', () => { + it('Test result index components', () => { + expect(resultComponents.length).toEqual(3); + }); +}); + diff --git a/client/src/app/admin/instance/dataset/components/attribute/result/table-result.component.spec.ts b/client/src/app/admin/instance/dataset/components/attribute/result/table-result.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..aa0104624cb6ec48ced9634c874577c72b5920a1 --- /dev/null +++ b/client/src/app/admin/instance/dataset/components/attribute/result/table-result.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 { TableResultComponent } from './table-result.component'; + +describe('[admin][instance][dataset][components][attribute][result] TableResultComponent ', () => { + let component: TableResultComponent; + let fixture: ComponentFixture<TableResultComponent>; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [ + TableResultComponent, + ], + imports: [ + BrowserAnimationsModule + ], + }); + fixture = TestBed.createComponent(TableResultComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create the component', () => { + expect(component).toBeTruthy(); + }); +}); + diff --git a/client/src/app/admin/instance/dataset/components/attribute/result/tr-result.component.spec.ts b/client/src/app/admin/instance/dataset/components/attribute/result/tr-result.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..0cacf9ce75f21c58ed62a67782071da615e2b628 --- /dev/null +++ b/client/src/app/admin/instance/dataset/components/attribute/result/tr-result.component.spec.ts @@ -0,0 +1,72 @@ +/** + * 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, UntypedFormGroup } from '@angular/forms'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { Attribute } from 'src/app/metamodel/models'; +import { RendererFormFactory } from './renderers'; +import { TrResultComponent } from './tr-result.component'; + + +describe('[admin][instance][dataset][components][attribute][result] TrResultComponent', () => { + let component: TrResultComponent; + let fixture: ComponentFixture<TrResultComponent>; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [ + TrResultComponent, + ], + imports: [ + BrowserAnimationsModule, + ReactiveFormsModule + ], + }); + fixture = TestBed.createComponent(TrResultComponent); + component = fixture.componentInstance; + let attribute: Attribute; + component.attribute = { ...attribute, name: 'test', renderer: '', order_by: false, archive: true }; + fixture.detectChanges(); + }); + + it('should create the component', () => { + expect(component).toBeTruthy(); + }); + it('getRendererConfigForm() should form.controls["renderer_config"] as an instance of UntypedFormGroup', () => { + let result = component.getRendererConfigForm(); + expect(result).toBeInstanceOf(UntypedFormGroup); + + }) + it(' rendererOnChange() should set form.controls.renderer to nul and call setcontrol on the form ', () => { + let spy = jest.spyOn(component.form, 'setControl'); + expect(component.form.controls.renderer.value).toEqual(''); + component.rendererOnChange(); + expect(component.form.controls.renderer.value).toEqual(null); + expect(spy).toHaveBeenCalledTimes(1); + + + }); + it('rendererOnChange() should call RenderFormFactory.create', () => { + component.form.controls.renderer.setValue('test'); + let spy = jest.spyOn(RendererFormFactory, 'create'); + component.rendererOnChange() + expect(spy).toHaveBeenCalledTimes(1); + + }); + 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 }); + }) + + +}); + diff --git a/client/src/app/admin/instance/dataset/components/attribute/vo/index.spec.ts b/client/src/app/admin/instance/dataset/components/attribute/vo/index.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..cabfd99a6d55a15798b0902d1cf56bea70580951 --- /dev/null +++ b/client/src/app/admin/instance/dataset/components/attribute/vo/index.spec.ts @@ -0,0 +1,18 @@ +/** + * 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 { voComponents } from './index'; + +describe('[admin][instance][dataset][components][attribute][vo] index', () => { + it('Test output index components', () => { + expect(voComponents.length).toEqual(2); + }); +}); + + diff --git a/client/src/app/admin/instance/dataset/components/attribute/vo/table-vo.component.spec.ts b/client/src/app/admin/instance/dataset/components/attribute/vo/table-vo.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..8c7ca8e24593fce89a803b16606a3fe01388f652 --- /dev/null +++ b/client/src/app/admin/instance/dataset/components/attribute/vo/table-vo.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 { TableVoComponent } from './table-vo.component'; + +describe('[admin][instance][dataset][components][attribute][vo] TableVoComponent', () => { + let component: TableVoComponent; + let fixture: ComponentFixture<TableVoComponent>; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [ + TableVoComponent, + ], + imports: [ + BrowserAnimationsModule, + ], + }); + fixture = TestBed.createComponent(TableVoComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create the component', () => { + expect(component).toBeTruthy(); + }); +}); + diff --git a/client/src/app/admin/instance/dataset/components/attribute/vo/tr-vo.component.spec.ts b/client/src/app/admin/instance/dataset/components/attribute/vo/tr-vo.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..bb73f57154f101ffcb6279e348c325f4fe25ea43 --- /dev/null +++ b/client/src/app/admin/instance/dataset/components/attribute/vo/tr-vo.component.spec.ts @@ -0,0 +1,47 @@ +/** + * 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 } from 'src/app/metamodel/models'; +import { TrVoComponent } from './tr-vo.component'; + +describe('[admin][instance][dataset][components][attribute][vo] TrVoComponent', () => { + let component: TrVoComponent; + let fixture: ComponentFixture<TrVoComponent>; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [ + TrVoComponent, + ], + imports: [ + BrowserAnimationsModule, + ReactiveFormsModule + ], + }); + fixture = TestBed.createComponent(TrVoComponent); + component = fixture.componentInstance; + let attribute: Attribute; + component.attribute = { ...attribute, name: 'test', vo_utype: '', vo_ucd: '', vo_unit: '', vo_description: '', vo_datatype: '', vo_size: 1 }; + 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 }); + }) +}); +