import { TestBed, inject } from '@angular/core/testing'; import { geoInfoInitial, geoInfoReducer, InfoLevel } from './geo-info.reducer'; import { GeoInfoActions } from './geo-info.actions'; import { GeoIdService } from '../geo.id'; const deepFreeze = require('deep-freeze-strict'); const testInfo = { message: 'test message', isVisible: true, level: 'error', canRevert: true }; describe(`geoInfoReducer`, () => { beforeEach(() => { TestBed.configureTestingModule({ providers: [ {provide: GeoIdService, useValue: {id$: {getValue () { return; }}}}, GeoInfoActions ] }); }); describe(GeoInfoActions.SHOW_INFO, () => { it(`should set info properties to state`, inject([GeoInfoActions], (geoInfoActions: GeoInfoActions) => { const state = geoInfoInitial; deepFreeze(state); const newState = geoInfoReducer(state, geoInfoActions.showInfo(testInfo)); expect(newState) .toEqual(testInfo); }) ); }); describe(GeoInfoActions.HIDE_INFO, () => { it(`should hide info by resetting it to initial`, inject([GeoInfoActions], (geoInfoActions: GeoInfoActions) => { const state = testInfo; deepFreeze(state); const newState = geoInfoReducer(state, geoInfoActions.hideInfo()); expect(newState) .toEqual(geoInfoInitial); }) ); }); });