Skip to content
Snippets Groups Projects
Commit f2550f8c authored by Angapay Divin's avatar Angapay Divin
Browse files

add test for admin/instance/dataset/components/cone-search-config

parent 3e15d8d7
No related branches found
No related tags found
2 merge requests!72Develop,!66Resolve "Tests client: Tester le module dataset de la partie admin->instance"
/**
* 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);
})
});
/**
* 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
/**
* 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);
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment