Skip to content

Commit a3c10fd

Browse files
author
James Salas
committed
fix: issue with epicmiddleware not being called in mock test
1 parent 543c3ee commit a3c10fd

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

packages/example-app/src/app/store/module.spec.ts

+17-18
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,35 @@
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';
73
import { RootEpics } from './epics';
84
import { StoreModule } from './module';
95

106
describe('Store Module', () => {
11-
let mockNgRedux: NgRedux<any>;
12-
let devTools: DevToolsExtension;
137
let mockEpics: Partial<RootEpics>;
148

159
beforeEach(async(() => {
16-
TestBed.configureTestingModule({
17-
imports: [NgReduxTestingModule],
18-
});
19-
2010
mockEpics = {
2111
createEpics() {
2212
return [];
2313
},
2414
};
25-
devTools = TestBed.get(DevToolsExtension);
26-
mockNgRedux = MockNgRedux.getInstance();
2715
}));
2816

2917
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,
3433
null as any,
3534
mockEpics as any,
3635
);

0 commit comments

Comments
 (0)