|
| 1 | +import { NgRedux, DevToolsExtension } from '@angular-redux/store'; |
| 2 | +import { NgReduxTestingModule, MockNgRedux } from '@angular-redux/store/testing'; |
| 3 | +import { TestBed, async, getTestBed } from '@angular/core/testing'; |
| 4 | +import { StoreModule } from './module'; |
| 5 | +import { IAppState } from './model'; |
| 6 | +import { RootEpics } from './epics'; |
| 7 | + |
| 8 | +describe('Store Module', () => { |
| 9 | + let mockNgRedux: NgRedux<any>; |
| 10 | + let devTools: DevToolsExtension; |
| 11 | + let mockEpics: RootEpics; |
| 12 | + |
| 13 | + beforeEach(async(() => { |
| 14 | + TestBed.configureTestingModule({ |
| 15 | + imports: [ NgReduxTestingModule ], |
| 16 | + }).compileComponents().then(() => { |
| 17 | + const testbed = getTestBed(); |
| 18 | + |
| 19 | + mockEpics = { |
| 20 | + createEpics() { return [] } |
| 21 | + } as RootEpics; |
| 22 | + |
| 23 | + devTools = testbed.get(DevToolsExtension); |
| 24 | + mockNgRedux = MockNgRedux.getInstance(); |
| 25 | + }); |
| 26 | + })); |
| 27 | + |
| 28 | + it('should configure the store when the module is loaded', async(() => { |
| 29 | + const configureSpy = spyOn(MockNgRedux.getInstance(), 'configureStore'); |
| 30 | + const instance = new StoreModule(mockNgRedux, devTools, null, mockEpics); |
| 31 | + |
| 32 | + expect(configureSpy).toHaveBeenCalled(); |
| 33 | + })); |
| 34 | +}); |
0 commit comments