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

add test for admin/instance/dataset/components/output-family

parent f661f510
No related branches found
No related tags found
2 merge requests!72Develop,!66Resolve "Tests client: Tester le module dataset de la partie admin->instance"
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ReactiveFormsModule } from '@angular/forms'; import { ReactiveFormsModule } from '@angular/forms';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { FileInfo } from 'src/app/admin/store/models';
import { OutputCategoryFormComponent } from './output-category-form.component'; import { OutputCategoryFormComponent } from './output-category-form.component';
describe('[admin][instance][dataset][components][output-category] OutputCategoryFormComponent', () => { describe('[admin][instance][dataset][components][output-category] OutputCategoryFormComponent', () => {
......
/**
* 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 { AddOutputFamilyComponent } from './add-output-family.component';
describe('[admin][instance][dataset][components][output-family] AddOutputFamilyComponent', () => {
let component: AddOutputFamilyComponent;
let fixture: ComponentFixture<AddOutputFamilyComponent>;
const modalServiceStub = {
show: jest.fn(),
};
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
AddOutputFamilyComponent,
],
providers: [
BsModalRef,
{ provide: BsModalService, useValue: modalServiceStub }
],
imports: [
BrowserAnimationsModule,
ReactiveFormsModule
],
});
fixture = TestBed.createComponent(AddOutputFamilyComponent);
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);
});
});
/**
* 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 { EditOutputFamilyComponent } from './edit-output-family.component';
describe('[admin][instance][dataset][components][output-family] EditOutputFamilyComponent', () => {
let component: EditOutputFamilyComponent;
let fixture: ComponentFixture<EditOutputFamilyComponent>;
const modalServiceStub = {
show: jest.fn(),
};
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
EditOutputFamilyComponent,
],
providers: [
BsModalRef,
{ provide: BsModalService, useValue: modalServiceStub }
],
imports: [
BrowserAnimationsModule,
ReactiveFormsModule
],
});
fixture = TestBed.createComponent(EditOutputFamilyComponent);
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);
});
});
\ 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 { outputFamilyComponents } from './index';
describe('[admin][instance][dataset][components][output-family] index', () => {
it('should test output-family index components', () => {
expect(outputFamilyComponents.length).toEqual(4);
});
});
/**
* 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 { OutputFamilyFormComponent } from './output-family-form.component';
describe('[admin][instance][dataset][components][output-family] OutputFamilyFormComponent', () => {
let component: OutputFamilyFormComponent;
let fixture: ComponentFixture<OutputFamilyFormComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
OutputFamilyFormComponent,
],
imports: [
BrowserAnimationsModule,
ReactiveFormsModule
],
});
fixture = TestBed.createComponent(OutputFamilyFormComponent);
component = fixture.componentInstance;
component.outputFamily = {
display: 10,
id: 1,
label: 'test',
opened: false
};
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.outputFamily, ...component.form.value });
});
it('submit() should emit only form.value()', () => {
let spy = jest.spyOn(component.onSubmit, 'emit');
component.outputFamily = null;
component.submit();
expect(spy).toHaveBeenCalledTimes(1);
expect(spy).toHaveBeenCalledWith({ ...component.form.value });
})
});
/**
* 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 { OutputFamilyListComponent } from './output-family-list.component';
@Component({
selector: 'app-add-output-family',
})
class AddOutputFamilyComponent { }
describe('[admin][instance][dataset][components][output-family] OutputFamilyListComponent', () => {
let component: OutputFamilyListComponent;
let fixture: ComponentFixture<OutputFamilyListComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
OutputFamilyListComponent,
AddOutputFamilyComponent
],
imports: [
BrowserAnimationsModule,
ReactiveFormsModule
],
});
fixture = TestBed.createComponent(OutputFamilyListComponent);
component = fixture.componentInstance;
});
it('should create the component', () => {
expect(component).toBeTruthy();
});
});
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