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

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

parent f2550f8c
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 { 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 { AddCriteriaFamilyComponent } from './add-criteria-family.component';
describe('[admin][instance][dataset][components][criteria-family] AddCriteriaFamilyComponent', () => {
let component: AddCriteriaFamilyComponent;
let fixture: ComponentFixture<AddCriteriaFamilyComponent>;
const modalServiceStub = {
show: jest.fn(),
};
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
AddCriteriaFamilyComponent,
],
providers: [
BsModalRef,
{ provide: BsModalService, useValue: modalServiceStub }
],
imports: [
BrowserAnimationsModule,
ReactiveFormsModule
],
});
fixture = TestBed.createComponent(AddCriteriaFamilyComponent);
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 { ComponentFixture, TestBed } from '@angular/core/testing';
import { ReactiveFormsModule } from '@angular/forms';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { CriteriaFamilyFormComponent } from './criteria-family-form.component';
describe('[admin][instance][dataset][components][criteria-family] CriteriaFamilyFormComponent', () => {
let component: CriteriaFamilyFormComponent;
let fixture: ComponentFixture<CriteriaFamilyFormComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
CriteriaFamilyFormComponent,
],
imports: [
BrowserAnimationsModule,
ReactiveFormsModule
],
});
fixture = TestBed.createComponent(CriteriaFamilyFormComponent);
component = fixture.componentInstance;
component.criteriaFamily = { display: 10, id: 1, label: 'test', opened: false };
fixture.detectChanges();
});
it('should create the component', () => {
expect(component).toBeTruthy();
});
it(' submit() should emit criterFamily and form.value', () => {
let spy = jest.spyOn(component.onSubmit, 'emit');
component.submit();
expect(spy).toHaveBeenCalledTimes(1);
expect(spy).toHaveBeenCalledWith({ ...component.criteriaFamily, ...component.form.value });
});
it(' submit() should emit form.value', () => {
component.criteriaFamily = null;
let spy = jest.spyOn(component.onSubmit, 'emit');
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 { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { CriteriaFamilyListComponent } from './criteria-family-list.component';
@Component({
selector: 'app-add-criteria-family',
})
class AddCriteriaFamilyComponent {}
describe('[admin][instance][dataset][components][criteria-family] CriteriaFamilyListComponent', () => {
let component: CriteriaFamilyListComponent;
let fixture: ComponentFixture<CriteriaFamilyListComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
CriteriaFamilyListComponent,
],
imports: [
BrowserAnimationsModule,
],
});
fixture = TestBed.createComponent(CriteriaFamilyListComponent);
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 { 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 { EditCriteriaFamilyComponent } from './edit-criteria-family.component';
describe('[admin][instance][dataset][components][criteria-family] EditCriteriaFamilyComponent', () => {
let component: EditCriteriaFamilyComponent;
let fixture: ComponentFixture<EditCriteriaFamilyComponent>;
const modalServiceStub = {
show: jest.fn(),
};
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
EditCriteriaFamilyComponent,
],
providers: [
BsModalRef,
{ provide: BsModalService, useValue: modalServiceStub }
],
imports: [
BrowserAnimationsModule,
ReactiveFormsModule
],
});
fixture = TestBed.createComponent(EditCriteriaFamilyComponent);
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 { criteriaFamilyComponents } from './index';
describe('[admin][instance][dataset][components][criteria-family] index', () => {
it('should test criteria-family index components', () => {
expect(criteriaFamilyComponents.length).toEqual(4);
});
});
\ 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