|
1 |
| -import { DevToolsExtension, NgRedux } from '@angular-redux/store'; |
2 |
| -import { |
3 |
| - MockNgRedux, |
4 |
| - NgReduxTestingModule, |
5 |
| -} from '@angular-redux/store/testing'; |
6 |
| -import { async, TestBed } from '@angular/core/testing'; |
| 1 | +import { async } from '@angular/core/testing'; |
| 2 | +import { applyMiddleware, compose, createStore } from 'redux'; |
7 | 3 | import { RootEpics } from './epics';
|
8 | 4 | import { StoreModule } from './module';
|
9 | 5 |
|
10 | 6 | describe('Store Module', () => {
|
11 |
| - let mockNgRedux: NgRedux<any>; |
12 |
| - let devTools: DevToolsExtension; |
13 | 7 | let mockEpics: Partial<RootEpics>;
|
14 | 8 |
|
15 | 9 | beforeEach(async(() => {
|
16 |
| - TestBed.configureTestingModule({ |
17 |
| - imports: [NgReduxTestingModule], |
18 |
| - }); |
19 |
| - |
20 | 10 | mockEpics = {
|
21 | 11 | createEpics() {
|
22 | 12 | return [];
|
23 | 13 | },
|
24 | 14 | };
|
25 |
| - devTools = TestBed.get(DevToolsExtension); |
26 |
| - mockNgRedux = MockNgRedux.getInstance(); |
27 | 15 | }));
|
28 | 16 |
|
29 | 17 | it('should configure the store when the module is loaded', async(() => {
|
30 |
| - const configureSpy = spyOn(MockNgRedux.getInstance(), 'configureStore'); |
31 |
| - const module = new StoreModule( |
32 |
| - mockNgRedux, |
33 |
| - devTools, |
| 18 | + const mockNgRedux = { |
| 19 | + configureStore(_: any, __: any, middleware: any = [], ___: any) { |
| 20 | + createStore( |
| 21 | + () => '', |
| 22 | + compose(...middleware.map((m: any) => applyMiddleware(m))), |
| 23 | + ); |
| 24 | + }, |
| 25 | + }; |
| 26 | + const configureSpy = spyOn(mockNgRedux, 'configureStore').and.callThrough(); |
| 27 | + const store = new StoreModule( |
| 28 | + mockNgRedux as any, |
| 29 | + { |
| 30 | + enhancer: jasmine.createSpy(), |
| 31 | + isEnabled: jasmine.createSpy(), |
| 32 | + } as any, |
34 | 33 | null as any,
|
35 | 34 | mockEpics as any,
|
36 | 35 | );
|
|
0 commit comments