Skip to content
Snippets Groups Projects

Resolve "Fix SQ issues + add tests"

Merged Tifenn Guillas requested to merge 92-fix-sq-issues-add-tests into develop
3 files
+ 161
0
Compare changes
  • Side-by-side
  • Inline
Files
3
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { provideMockStore, MockStore } from '@ngrx/store/testing';
import { Component, Input } from '@angular/core';
import { ResultComponent } from './result.component';
import * as fromMetamodel from '../../metamodel/reducers';
import * as fromSearch from '../store/search.reducer';
import * as searchActions from '../store/search.action';
import { Dataset, Attribute } from 'src/app/metamodel/model';
import { Criterion, SearchQueryParams } from '../store/model';
import { ScrollTopService } from '../../shared/service/sroll-top.service';
import { RouterLinkDirectiveStub } from '../../../settings/test-data/router-link-directive-stub';
fdescribe('[Search] Container: ResultComponent', () => {
@Component({ selector: 'app-result-download', template: '' })
class DownloadSectionStubComponent {
@Input() datasetName: string;
@Input() datasetList: Dataset[];
@Input() dataLength: number;
@Input() apiPath: string;
@Input() criteriaList: Criterion[];
@Input() outputList: number[];
}
@Component({ selector: 'app-result-summary', template: '' })
class SummarySectionStubComponent {
@Input() datasetAttributeList: Attribute[];
@Input() criteriaList: Criterion[];
@Input() outputList: number[];
}
@Component({ selector: 'app-result-url-display', template: '' })
class UrlDisplaySectionStubComponent {
@Input() apiPath: string;
@Input() datasetName: string;
@Input() criteriaList: Criterion[];
@Input() outputList: number[];
}
@Component({ selector: 'app-result-datatable', template: '' })
class DatatableSectionStubComponent {
@Input() apiPath: string;
@Input() datasetName: string;
@Input() datasetList: Dataset[];
@Input() queryParams: SearchQueryParams;
@Input() datasetAttributeList: Attribute[];
@Input() outputList: number[];
@Input() searchData: any[];
@Input() dataLength: number;
@Input() selectedData: any[];
@Input() processWip: boolean;
@Input() processDone: boolean;
@Input() processId: string;
}
let scrollTopServiceStub: Partial<ScrollTopService> = {
setScrollTop() {}
};
let component: ResultComponent;
let fixture: ComponentFixture<ResultComponent>;
let store: MockStore;
const initialState = {
search: { ...fromSearch.initialState },
metamodel: { ...fromMetamodel }
};
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
ResultComponent,
DownloadSectionStubComponent,
SummarySectionStubComponent,
UrlDisplaySectionStubComponent,
DatatableSectionStubComponent,
RouterLinkDirectiveStub
],
providers: [
provideMockStore({ initialState }),
{ provide: ScrollTopService, useValue: scrollTopServiceStub }
]
});
fixture = TestBed.createComponent(ResultComponent);
component = fixture.componentInstance;
store = TestBed.inject(MockStore);
});
it('should create the component', () => {
expect(component).toBeTruthy();
});
it('should execute ngOnInit lifecycle', () => {
const action = new searchActions.ChangeStepAction('result');
const spy = spyOn(store, 'dispatch');
fixture.detectChanges();
expect(spy).toHaveBeenCalledWith(action);
});
});
// Promise.resolve(null).then(() => this.store.dispatch(new searchActions.ChangeStepAction('result')));
// Promise.resolve(null).then(() => this.store.dispatch(new searchActions.ResultChecked()));
// Promise.resolve(null).then(() => this.store.dispatch(new searchActions.InitSearchByUrl()));
// this.store.dispatch(new datasetActions.LoadDatasetSearchMetaAction());
// this.scrollTopService.setScrollTop();
Loading