Skip to content
Snippets Groups Projects
Commit add66fb9 authored by Tifenn Guillas's avatar Tifenn Guillas
Browse files

Tests on globale search multiple component => DONE

parent 29c62cbc
No related branches found
No related tags found
2 merge requests!147Develop,!137Resolve "[Module Multiple] : ajouter le nouveau module"
......@@ -4,8 +4,6 @@ import { DatasetListComponent } from './datasets/dataset-list.component';
import { DatasetsByProjetComponent } from './datasets/datasets-by-projet.component';
import { OverviewComponent } from './result/overview.component';
import { DatasetsResultComponent } from './result/datasets-result.component';
// import { DatatableComponent } from "../../shared/datatable/datatable.component";
// import { RendererComponents } from "../../shared/datatable/renderer";
export const dummiesComponents = [
ProgressBarMultipleComponent,
......@@ -13,7 +11,5 @@ export const dummiesComponents = [
DatasetListComponent,
DatasetsByProjetComponent,
OverviewComponent,
DatasetsResultComponent,
// DatatableComponent,
// RendererComponents
DatasetsResultComponent
];
\ No newline at end of file
// import { async, ComponentFixture, TestBed } from '@angular/core/testing';
// import { RouterTestingModule } from '@angular/router/testing';
// import { By } from '@angular/platform-browser';
//
// import { ProgressBarComponentMultiple } from './progress-bar.component';
//
// describe('[Search] Component: ProgressBarComponent', () => {
// let component: ProgressBarComponentMultiple;
// let fixture: ComponentFixture<ProgressBarComponentMultiple>;
//
// beforeEach(async(() => {
// TestBed.configureTestingModule({
// declarations: [ProgressBarComponentMultiple],
// imports: [RouterTestingModule]
// }).compileComponents();
// }));
//
// beforeEach(() => {
// fixture = TestBed.createComponent(ProgressBarComponentMultiple);
// component = fixture.componentInstance;
// fixture.detectChanges();
// });
//
// it('should create the component', () => {
// expect(component).toBeTruthy();
// });
//
// it('#getStepClass() should return correct step class', () => {
// let style = component.getStepClass();
// expect(style).toBe('datasetStep');
// component.currentStep = 'dataset';
// style = component.getStepClass();
// expect(style).toBe('datasetStep');
// component.currentStep = 'criteria';
// style = component.getStepClass();
// expect(style).toBe('criteriaStep');
// component.currentStep = 'output';
// style = component.getStepClass();
// expect(style).toBe('outputStep');
// component.currentStep = 'result';
// style = component.getStepClass();
// expect(style).toBe('resultStep');
// });
//
// // TODO: Make test working
// // it('should apply the correct class', () => {
// // component.currentStep = 'dataset';
// // fixture.detectChanges();
// // let style = fixture.debugElement.query(By.css('#criteriaStep')).nativeElement.getAttribute('class');
// // expect(style).not.toContain('active');
// // component.currentStep = 'criteria';
// // fixture.detectChanges();
// // style = fixture.debugElement.query(By.css('#criteriaStep')).nativeElement.getAttribute('class');
// // console.log(style);
// // expect(style).toContain('active');
// // component.criteriaStepChecked = true;
// // fixture.detectChanges();
// // style = fixture.debugElement.query(By.css('#criteriaStep')).nativeElement.getAttribute('class');
// // expect(style).toContain('checked');
// // const template = fixture.nativeElement;
// // expect(template.querySelector('#criteriaStep')).toBeTruthy();
// // });
// });
//
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { ProgressBarMultipleComponent } from './progress-bar-multiple.component';
describe('[SearchMultiple] Component: ProgressBarMultipleComponent', () => {
let component: ProgressBarMultipleComponent;
let fixture: ComponentFixture<ProgressBarMultipleComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [ProgressBarMultipleComponent],
imports: [RouterTestingModule]
});
fixture = TestBed.createComponent(ProgressBarMultipleComponent);
component = fixture.componentInstance;
});
it('should create the component', () => {
expect(component).toBeTruthy();
});
it('#getStepClass() should return correct step class', () => {
let style = component.getStepClass();
expect(style).toBe('positionStep');
component.currentStep = 'position';
style = component.getStepClass();
expect(style).toBe('positionStep');
component.currentStep = 'datasets';
style = component.getStepClass();
expect(style).toBe('datasetsStep');
component.currentStep = 'result';
style = component.getStepClass();
expect(style).toBe('resultStep');
});
});
// import { ComponentFixture, TestBed } from '@angular/core/testing';
// import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
//
// import { AccordionModule } from 'ngx-bootstrap/accordion';
// import { SummaryMultipleComponent } from './summary.component';
// import { ATTRIBUTE_LIST, CRITERIA_LIST, DATASET_LIST, CATEGORY_LIST } from '../../../settings/test-data';
// import { Criterion } from '../store/model';
// import { Category } from '../../metamodel/model';
//
// describe('[Search] Component: SummaryComponent', () => {
// let component: SummaryMultipleComponent;
// let fixture: ComponentFixture<SummaryMultipleComponent>;
//
// beforeEach(() => {
// TestBed.configureTestingModule({
// declarations: [SummaryMultipleComponent],
// imports: [AccordionModule.forRoot(), BrowserAnimationsModule]
// });
// fixture = TestBed.createComponent(SummaryMultipleComponent);
// component = fixture.componentInstance;
// });
//
// it('should create the component', () => {
// expect(component).toBeTruthy();
// });
//
// it('#getDataset() should return the dataset with the given name', () => {
// component.datasetList = DATASET_LIST;
// component.datasetName = 'cat_1';
// expect(component.getDataset().description).toBe('Description of cat 1');
// });
//
// it('#noCriteria() should return if there is criteria or not', () => {
// component.isConeSearchAdded = false;
// component.criteriaList = [];
// expect(component.noCriteria()).toBeTruthy();
// component.criteriaList = CRITERIA_LIST;
// expect(component.noCriteria()).toBeFalsy();
// component.isConeSearchAdded = true;
// expect(component.noCriteria()).toBeFalsy();
// component.criteriaList = [];
// expect(component.noCriteria()).toBeFalsy();
// });
//
// it('#getAttribute() should return the attribute with the given id', () => {
// component.datasetAttributeList = ATTRIBUTE_LIST;
// expect(component.getAttribute(1).name).toBe('name_one');
// });
//
// it('#printCriterion() should return pretty criterion', () => {
// const criterion: Criterion = CRITERIA_LIST.find(c => c.id === 1);
// expect(component.printCriterion(criterion)).toBe('= fd_crit_1');
// });
//
// it('#getCategoryByFamilySortedByDisplay(idFamily) should sort by display categories belonging to idFamily', () => {
// component.categoryList = CATEGORY_LIST;
// const sortedCategoryList: Category[] = component.getCategoryByFamilySortedByDisplay(1);
// expect(sortedCategoryList.length).toBe(2);
// expect(sortedCategoryList[0].id).toBe(2);
// expect(sortedCategoryList[1].id).toBe(1);
// });
//
// it('#getSelectedOutputByCategory() should return selected attributes belonging to the given category', () => {
// component.datasetAttributeList = ATTRIBUTE_LIST;
// component.outputList = [1];
// expect(component.getSelectedOutputByCategory(1).length).toEqual(1);
// component.outputList = [];
// expect(component.getSelectedOutputByCategory(1).length).toEqual(0);
// });
// });
//
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { AccordionModule } from 'ngx-bootstrap/accordion';
import { SummaryMultipleComponent } from './summary-multiple.component';
import { DATASET_LIST, PROJECT_LIST } from '../../../settings/test-data';
describe('[SearchMultiple] Component: SummaryMultipleComponent', () => {
let component: SummaryMultipleComponent;
let fixture: ComponentFixture<SummaryMultipleComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [SummaryMultipleComponent],
imports: [AccordionModule.forRoot(), BrowserAnimationsModule]
});
fixture = TestBed.createComponent(SummaryMultipleComponent);
component = fixture.componentInstance;
});
it('should create the component', () => {
expect(component).toBeTruthy();
});
it('#getProjectSortedByName() should return list of projects', () => {
component.projectList = PROJECT_LIST;
expect(component.getProjectSortedByName()[0].name).toBe('project_1');
expect(component.getProjectSortedByName()[1].name).toBe('project_2');
});
it('#getSelectedDatasetsByProject() should return list of selected datasets for the given project', () => {
component.datasetList = DATASET_LIST;
component.selectedDatasets = ['cat_1'];
expect(component.getSelectedDatasetsByProject('project_1').length).toEqual(1);
expect(component.getSelectedDatasetsByProject('project_1')[0].name).toEqual('cat_1');
});
});
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
import { SearchMultipleQueryParams } from '../store/model';
import { Dataset, Project } from '../../metamodel/model';
import { ConeSearch } from "../../shared/cone-search/store/model";
import { SearchMultipleQueryParams } from "../store/model";
import { ConeSearch } from '../../shared/cone-search/store/model';
@Component({
selector: 'app-summary-multiple',
......
......@@ -2,17 +2,17 @@ import { Project } from 'src/app/metamodel/model';
export const PROJECT_LIST: Project[] = [
{
name: 'project_1',
label: 'Project 1',
description: 'Description of project 1',
name: 'project_2',
label: 'Project 2',
description: 'Description of project 2',
link: '',
manager: '',
id_database: 1
},
{
name: 'project_2',
label: 'Project 2',
description: 'Description of project 2',
name: 'project_1',
label: 'Project 1',
description: 'Description of project 1',
link: '',
manager: '',
id_database: 1
......
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