diff --git a/client/src/app/admin/instance/dataset/components/output-category/add-output-category.component.spec.ts b/client/src/app/admin/instance/dataset/components/output-category/add-output-category.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..2ee1382a90a3aacc24f7d386ac3afdcb59f82791 --- /dev/null +++ b/client/src/app/admin/instance/dataset/components/output-category/add-output-category.component.spec.ts @@ -0,0 +1,56 @@ +/** + * 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 { TemplateRef } from '@angular/core'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ReactiveFormsModule } from '@angular/forms'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal'; +import { AddOutputCategoryComponent } from './add-output-category.component'; + +describe('[admin][instance][dataset][components][output-category] AddOutputCategoryComponent', () => { + let component: AddOutputCategoryComponent; + let fixture: ComponentFixture<AddOutputCategoryComponent>; + const modalServiceStub = { + show: jest.fn(), + }; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [ + AddOutputCategoryComponent, + ], + providers: [ + BsModalRef, + { provide: BsModalService, useValue: modalServiceStub } + ], + imports: [ + BrowserAnimationsModule, + ReactiveFormsModule + ], + }); + fixture = TestBed.createComponent(AddOutputCategoryComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create the component', () => { + expect(component).toBeTruthy(); + }); + + it('should call modalRef.show(template)', () => { + let template: TemplateRef<any> = null; + let spy = jest.spyOn(modalServiceStub, 'show'); + component.openModal(template); + expect(spy).toHaveBeenCalledTimes(1); + expect(spy).toHaveBeenCalledWith(template); + }); + +}); + diff --git a/client/src/app/admin/instance/dataset/components/output-category/edit-output-category.component.spec.ts b/client/src/app/admin/instance/dataset/components/output-category/edit-output-category.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc840b3a7580c44fafe1f3d48cef424eca97db52 --- /dev/null +++ b/client/src/app/admin/instance/dataset/components/output-category/edit-output-category.component.spec.ts @@ -0,0 +1,56 @@ +/** + * 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 { TemplateRef } from '@angular/core'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ReactiveFormsModule } from '@angular/forms'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal'; +import { EditOutputCategoryComponent } from './edit-output-category.component'; + +describe('[admin][instance][dataset][components][output-category] EditOutputCategoryComponent', () => { + let component: EditOutputCategoryComponent; + let fixture: ComponentFixture<EditOutputCategoryComponent>; + const modalServiceStub = { + show: jest.fn(), + }; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [ + EditOutputCategoryComponent, + ], + providers: [ + BsModalRef, + { provide: BsModalService, useValue: modalServiceStub } + ], + imports: [ + BrowserAnimationsModule, + ReactiveFormsModule + ], + }); + fixture = TestBed.createComponent(EditOutputCategoryComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create the component', () => { + expect(component).toBeTruthy(); + }); + + it('should call modalRef.show(template)', () => { + let template: TemplateRef<any> = null; + let spy = jest.spyOn(modalServiceStub, 'show'); + component.openModal(template); + expect(spy).toHaveBeenCalledTimes(1); + expect(spy).toHaveBeenCalledWith(template); + }); + +}); + diff --git a/client/src/app/admin/instance/dataset/components/output-category/index.spec.ts b/client/src/app/admin/instance/dataset/components/output-category/index.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..c9aa822e9134a6426f16f23046824adc3b3417b0 --- /dev/null +++ b/client/src/app/admin/instance/dataset/components/output-category/index.spec.ts @@ -0,0 +1,20 @@ +/** + * 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 { outputCategoryComponents } from './index'; + + describe('[admin][instance][dataset][components][output-category] index', () => { + it('should test output-category index components', () => { + expect(outputCategoryComponents.length).toEqual(4); + }); + }); + + + + \ No newline at end of file diff --git a/client/src/app/admin/instance/dataset/components/output-category/output-category-form.component.spec.ts b/client/src/app/admin/instance/dataset/components/output-category/output-category-form.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..6689a827a220ccba3a43a78cdf769a2b93c39f4a --- /dev/null +++ b/client/src/app/admin/instance/dataset/components/output-category/output-category-form.component.spec.ts @@ -0,0 +1,60 @@ +/** + * 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 { FileInfo } from 'src/app/admin/store/models'; +import { OutputCategoryFormComponent } from './output-category-form.component'; + +describe('[admin][instance][dataset][components][output-category] OutputCategoryFormComponent', () => { + let component: OutputCategoryFormComponent; + let fixture: ComponentFixture<OutputCategoryFormComponent>; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [ + OutputCategoryFormComponent, + ], + imports: [ + BrowserAnimationsModule, + ReactiveFormsModule + ], + }); + fixture = TestBed.createComponent(OutputCategoryFormComponent); + component = fixture.componentInstance; + component.outputCategory = { + display: 10, + id: 1, + id_output_family: 1, + label: 'test' + }; + fixture.detectChanges(); + }); + + it('should create the component', () => { + expect(component).toBeTruthy(); + }); + + it('submit() should emit outputCategory and form.value()', () => { + let spy = jest.spyOn(component.onSubmit, 'emit'); + component.submit(); + expect(spy).toHaveBeenCalledTimes(1); + expect(spy).toHaveBeenCalledWith({ ...component.outputCategory, ...component.form.value }); + }); + it('submit() should emit only form.value()', () => { + let spy = jest.spyOn(component.onSubmit, 'emit'); + component.outputCategory = null; + component.submit(); + expect(spy).toHaveBeenCalledTimes(1); + expect(spy).toHaveBeenCalledWith({ ...component.form.value }); + }) + +}); + diff --git a/client/src/app/admin/instance/dataset/components/output-category/output-category-list.component.spec.ts b/client/src/app/admin/instance/dataset/components/output-category/output-category-list.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..055940def8cadb6f1bff48329a1a2d3ae14058dc --- /dev/null +++ b/client/src/app/admin/instance/dataset/components/output-category/output-category-list.component.spec.ts @@ -0,0 +1,43 @@ +/** + * 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 { OutputCategoryListComponent } from './output-category-list.component'; +@Component({ + selector: 'app-add-output-category', +}) +class AddOutputCategoryComponent { } + +describe('[admin][instance][dataset][components][output-category] OutputCategoryListComponent', () => { + let component: OutputCategoryListComponent; + let fixture: ComponentFixture<OutputCategoryListComponent>; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [ + OutputCategoryListComponent, + ], + imports: [ + BrowserAnimationsModule, + ReactiveFormsModule + ], + }); + fixture = TestBed.createComponent(OutputCategoryListComponent); + component = fixture.componentInstance; + }); + + it('should create the component', () => { + expect(component).toBeTruthy(); + }); + +}); + +