@@ -32,7 +32,7 @@ describe('instrument', () => {
3232 let liftedStore ;
3333
3434 beforeEach ( ( ) => {
35- store = instrument ( ) ( createStore ) ( counter ) ;
35+ store = createStore ( counter , instrument ( ) ) ;
3636 liftedStore = store . liftedStore ;
3737 } ) ;
3838
@@ -156,7 +156,7 @@ describe('instrument', () => {
156156
157157 it ( 'should catch and record errors' , ( ) => {
158158 let spy = spyOn ( console , 'error' ) ;
159- let storeWithBug = instrument ( ) ( createStore ) ( counterWithBug ) ;
159+ let storeWithBug = createStore ( counterWithBug , instrument ( ) ) ;
160160
161161 storeWithBug . dispatch ( { type : 'INCREMENT' } ) ;
162162 storeWithBug . dispatch ( { type : 'DECREMENT' } ) ;
@@ -180,12 +180,13 @@ describe('instrument', () => {
180180 expect ( ( ) => {
181181 store . dispatch ( { type : undefined } ) ;
182182 } ) . toThrow (
183- / A c t i o n s m a y n o t h a v e a n u n d e f i n e d /
183+ 'Actions may not have an undefined "type" property. ' +
184+ 'Have you misspelled a constant?'
184185 ) ;
185186 } ) ;
186187
187188 it ( 'should return the last non-undefined state from getState' , ( ) => {
188- let storeWithBug = instrument ( ) ( createStore ) ( counterWithBug ) ;
189+ let storeWithBug = createStore ( counterWithBug , instrument ( ) ) ;
189190 storeWithBug . dispatch ( { type : 'INCREMENT' } ) ;
190191 storeWithBug . dispatch ( { type : 'INCREMENT' } ) ;
191192 expect ( storeWithBug . getState ( ) ) . toBe ( 2 ) ;
@@ -196,7 +197,7 @@ describe('instrument', () => {
196197
197198 it ( 'should not recompute states on every action' , ( ) => {
198199 let reducerCalls = 0 ;
199- let monitoredStore = instrument ( ) ( createStore ) ( ( ) => reducerCalls ++ ) ;
200+ let monitoredStore = createStore ( ( ) => reducerCalls ++ , instrument ( ) ) ;
200201 expect ( reducerCalls ) . toBe ( 1 ) ;
201202 monitoredStore . dispatch ( { type : 'INCREMENT' } ) ;
202203 monitoredStore . dispatch ( { type : 'INCREMENT' } ) ;
@@ -206,7 +207,7 @@ describe('instrument', () => {
206207
207208 it ( 'should not recompute old states when toggling an action' , ( ) => {
208209 let reducerCalls = 0 ;
209- let monitoredStore = instrument ( ) ( createStore ) ( ( ) => reducerCalls ++ ) ;
210+ let monitoredStore = createStore ( ( ) => reducerCalls ++ , instrument ( ) ) ;
210211 let monitoredLiftedStore = monitoredStore . liftedStore ;
211212
212213 expect ( reducerCalls ) . toBe ( 1 ) ;
@@ -249,7 +250,7 @@ describe('instrument', () => {
249250
250251 it ( 'should not recompute states when jumping to state' , ( ) => {
251252 let reducerCalls = 0 ;
252- let monitoredStore = instrument ( ) ( createStore ) ( ( ) => reducerCalls ++ ) ;
253+ let monitoredStore = createStore ( ( ) => reducerCalls ++ , instrument ( ) ) ;
253254 let monitoredLiftedStore = monitoredStore . liftedStore ;
254255
255256 expect ( reducerCalls ) . toBe ( 1 ) ;
@@ -272,10 +273,9 @@ describe('instrument', () => {
272273 expect ( monitoredLiftedStore . getState ( ) . computedStates ) . toBe ( savedComputedStates ) ;
273274 } ) ;
274275
275-
276276 it ( 'should not recompute states on monitor actions' , ( ) => {
277277 let reducerCalls = 0 ;
278- let monitoredStore = instrument ( ) ( createStore ) ( ( ) => reducerCalls ++ ) ;
278+ let monitoredStore = createStore ( ( ) => reducerCalls ++ , instrument ( ) ) ;
279279 let monitoredLiftedStore = monitoredStore . liftedStore ;
280280
281281 expect ( reducerCalls ) . toBe ( 1 ) ;
@@ -301,7 +301,7 @@ describe('instrument', () => {
301301 let exportedState ;
302302
303303 beforeEach ( ( ) => {
304- monitoredStore = instrument ( ) ( createStore ) ( counter ) ;
304+ monitoredStore = createStore ( counter , instrument ( ) ) ;
305305 monitoredLiftedStore = monitoredStore . liftedStore ;
306306 // Set up state to export
307307 monitoredStore . dispatch ( { type : 'INCREMENT' } ) ;
@@ -312,15 +312,15 @@ describe('instrument', () => {
312312 } ) ;
313313
314314 it ( 'should replay all the steps when a state is imported' , ( ) => {
315- let importMonitoredStore = instrument ( ) ( createStore ) ( counter ) ;
315+ let importMonitoredStore = createStore ( counter , instrument ( ) ) ;
316316 let importMonitoredLiftedStore = importMonitoredStore . liftedStore ;
317317
318318 importMonitoredLiftedStore . dispatch ( ActionCreators . importState ( exportedState ) ) ;
319319 expect ( importMonitoredLiftedStore . getState ( ) ) . toEqual ( exportedState ) ;
320320 } ) ;
321321
322322 it ( 'should replace the existing action log with the one imported' , ( ) => {
323- let importMonitoredStore = instrument ( ) ( createStore ) ( counter ) ;
323+ let importMonitoredStore = createStore ( counter , instrument ( ) ) ;
324324 let importMonitoredLiftedStore = importMonitoredStore . liftedStore ;
325325
326326 importMonitoredStore . dispatch ( { type : 'DECREMENT' } ) ;
@@ -333,12 +333,27 @@ describe('instrument', () => {
333333
334334 it ( 'throws if reducer is not a function' , ( ) => {
335335 expect ( ( ) =>
336- instrument ( ) ( createStore ) ( )
337- ) . toThrow ( 'Expected the nextReducer to be a function.' ) ;
336+ createStore ( undefined , instrument ( ) )
337+ ) . toThrow ( 'Expected the reducer to be a function.' ) ;
338+ } ) ;
339+
340+ it ( 'warns if the reducer is not a function but has a default field that is' , ( ) => {
341+ expect ( ( ) =>
342+ createStore ( ( { default : ( ) => { } } ) , instrument ( ) )
343+ ) . toThrow (
344+ 'Expected the reducer to be a function. ' +
345+ 'Instead got an object with a "default" field. ' +
346+ 'Did you pass a module instead of the default export? ' +
347+ 'Try passing require(...).default instead.'
348+ ) ;
338349 } ) ;
350+
339351 it ( 'throws if there are more than one instrument enhancer included' , ( ) => {
340352 expect ( ( ) => {
341- store = createStore ( counter , undefined , compose ( instrument ( ) , instrument ( ) ) ) ;
342- } ) . toThrow ( 'DevTools instrument shouldn\'t be included more than once. Check your store configuration.' ) ;
353+ createStore ( counter , compose ( instrument ( ) , instrument ( ) ) )
354+ } ) . toThrow (
355+ 'DevTools instrumentation should not be applied more than once. ' +
356+ 'Check your store configuration.'
357+ ) ;
343358 } ) ;
344359} ) ;
0 commit comments