diff --git a/client/src/app/admin/instance/dataset/components/cone-search-config/cone-search-config-form.component.spec.ts b/client/src/app/admin/instance/dataset/components/cone-search-config/cone-search-config-form.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..206957e45a13ed72cee5898c7c0e49fb472e0876 --- /dev/null +++ b/client/src/app/admin/instance/dataset/components/cone-search-config/cone-search-config-form.component.spec.ts @@ -0,0 +1,62 @@ +/** + * 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 { ConeSearchConfigFormComponent } from './cone-search-config-form.component'; + +describe('[admin][instance][dataset][components][cone-search-config] ConeSearchConfigFormComponent', () => { + let component: ConeSearchConfigFormComponent; + let fixture: ComponentFixture<ConeSearchConfigFormComponent>; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [ + ConeSearchConfigFormComponent + ], + imports: [ + BrowserAnimationsModule, + ReactiveFormsModule + ], + }); + fixture = TestBed.createComponent(ConeSearchConfigFormComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create the component', () => { + expect(component).toBeTruthy(); + }); + it('enable() should set (opened, column_ra, colomn_dec, plot_enabled) disabled property to false', () => { + + component.form.controls.enabled.setValue(true); + expect(component.form.controls.opened.disabled).toEqual(true) + expect(component.form.controls.column_ra.disabled).toEqual(true) + expect(component.form.controls.plot_enabled.disabled).toEqual(true) + expect(component.form.controls.column_dec.disabled).toEqual(true); + component.checkConeSearchDisableOpened(); + expect(component.form.controls.opened.disabled).toEqual(false) + expect(component.form.controls.column_ra.disabled).toEqual(false) + expect(component.form.controls.plot_enabled.disabled).toEqual(false) + expect(component.form.controls.column_dec.disabled).toEqual(false); + }); + it('should emit form.getRawValue and call makAsPristine', () => { + let spyOnSubmit = jest.spyOn(component.onSubmit, 'emit'); + let spyForm = jest.spyOn(component.form, 'markAsPristine'); + component.submit(); + expect(spyOnSubmit).toHaveBeenCalledTimes(1); + expect(spyOnSubmit).toHaveBeenCalledWith({ ...component.form.getRawValue() }) + expect(spyForm).toHaveBeenCalledTimes(1); + + + }) + +}); + diff --git a/client/src/app/admin/instance/dataset/components/cone-search-config/cone-search-config.component.spec.ts b/client/src/app/admin/instance/dataset/components/cone-search-config/cone-search-config.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..6f965156e98e2812b8def777ba3d98943eced7a0 --- /dev/null +++ b/client/src/app/admin/instance/dataset/components/cone-search-config/cone-search-config.component.spec.ts @@ -0,0 +1,62 @@ +/** + * 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 { UntypedFormGroup } from '@angular/forms'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { ConeSearchConfig } from 'src/app/metamodel/models'; +import { ConeSearchConfigComponent } from './cone-search-config.component'; +@Component({ + selector: 'app-cone-search-config-form', + +}) +class ConeSearchConfigFormComponent { + form = new UntypedFormGroup({}); +} +describe('[admin][instance][dataset][components][cone-search-config] ConeSearchConfigComponent', () => { + let component: ConeSearchConfigComponent; + let fixture: ComponentFixture<ConeSearchConfigComponent>; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [ + ConeSearchConfigComponent, + ConeSearchConfigFormComponent + ], + imports: [ + BrowserAnimationsModule, + ], + }); + fixture = TestBed.createComponent(ConeSearchConfigComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create the component', () => { + expect(component).toBeTruthy(); + }); + it(' save(coneSearchConfig: ConeSearchConfig) should emit the current coneSearchConfig, coneSearchConfig in args', () => { + let spy = jest.spyOn(component.editConeSearchConfig, 'emit'); + let coneSearchConfig: ConeSearchConfig = { column_dec: 10, column_ra: 5, enabled: false, id: 1, opened: false, plot_enabled: false }; + component.coneSearchConfig = coneSearchConfig; + let param: ConeSearchConfig = { ...coneSearchConfig, id: 2 } + component.save(param); + expect(spy).toHaveBeenCalledTimes(1); + expect(spy).toHaveBeenCalledWith({ ...component.coneSearchConfig, ...param }) + }) + it(' save(coneSearchConfig: ConeSearchConfig) should emit the coneSearchConfig passed in args', () => { + let spy = jest.spyOn(component.addConeSearchConfig, 'emit'); + let coneSearchConfig: ConeSearchConfig = { column_dec: 10, column_ra: 5, enabled: false, id: 1, opened: false, plot_enabled: false }; + component.save(coneSearchConfig); + expect(spy).toHaveBeenCalledTimes(1); + expect(spy).toHaveBeenCalledWith(coneSearchConfig); + }) + +}) \ No newline at end of file diff --git a/client/src/app/admin/instance/dataset/components/cone-search-config/index.spec.ts b/client/src/app/admin/instance/dataset/components/cone-search-config/index.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..e2a4ffa0e8184c3659617f43be5be31d3b528adf --- /dev/null +++ b/client/src/app/admin/instance/dataset/components/cone-search-config/index.spec.ts @@ -0,0 +1,19 @@ +/** + * 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 { coneSearchConfigComponents } from './index'; + +describe('[admin][instance][dataset][components][cone-search-config] index', () => { + it('Test output index components', () => { + expect(coneSearchConfigComponents.length).toEqual(2); + }); +}); + + +