From 2b026abe8487b6480f43c81d3ca16c2766d820af Mon Sep 17 00:00:00 2001 From: Tifenn Guillas <tifenn.guillas@lam.fr> Date: Thu, 30 Apr 2020 17:01:06 +0200 Subject: [PATCH] WIP: Tests on result container --- src/app/search/containers/result.component.spec.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/app/search/containers/result.component.spec.ts b/src/app/search/containers/result.component.spec.ts index a140455e..54cb6594 100644 --- a/src/app/search/containers/result.component.spec.ts +++ b/src/app/search/containers/result.component.spec.ts @@ -1,10 +1,11 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed, async } 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 datasetActions from '../../metamodel/action/dataset.action'; import * as searchActions from '../store/search.action'; import { Dataset, Attribute } from 'src/app/metamodel/model'; import { Criterion, SearchQueryParams } from '../store/model'; @@ -65,7 +66,7 @@ fdescribe('[Search] Container: ResultComponent', () => { metamodel: { ...fromMetamodel } }; - beforeEach(() => { + beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [ ResultComponent, @@ -83,18 +84,20 @@ fdescribe('[Search] Container: ResultComponent', () => { 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 changeStepAction = new searchActions.ChangeStepAction('result'); + const loadDatasetSearchMetaAction = new datasetActions.LoadDatasetSearchMetaAction(); const spy = spyOn(store, 'dispatch'); fixture.detectChanges(); - expect(spy).toHaveBeenCalledWith(action); + // expect(spy).toHaveBeenCalledTimes(1); + expect(spy).toHaveBeenCalledWith(loadDatasetSearchMetaAction); }); }); // Promise.resolve(null).then(() => this.store.dispatch(new searchActions.ChangeStepAction('result'))); -- GitLab