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

add test for admin/instance/dataset/components/attribute/output

parent 1acf74c1
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 { outputComponents } from './index';
describe('[admin][instance][dataset][components][attribute][output] index', () => {
it('Test output index components', () => {
expect(outputComponents.length).toEqual(2);
});
});
/**
* 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 { TableOutputComponent } from './table-output.component';
describe('[admin][instance][dataset][components][attribute][output] TableOutputComponent', () => {
let component: TableOutputComponent;
let fixture: ComponentFixture<TableOutputComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
TableOutputComponent,
],
imports: [
BrowserAnimationsModule,
],
});
fixture = TestBed.createComponent(TableOutputComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create the component', () => {
expect(component).toBeTruthy();
});
});
/**
* 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, 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: [
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
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