@@ -283,16 +283,28 @@ describe('configureStore', async () => {
283283 undefined ,
284284 expect . any ( Function )
285285 )
286+
287+ expect ( dummyEnhancerCalled ) . toBe ( true )
286288 } )
287289
288- it ( 'accepts a callback for customizing enhancers ', ( ) => {
289- const store = configureStore ( {
290- reducer,
291- enhancers : ( getDefaultEnhancers ) =>
292- getDefaultEnhancers ( ) . concat ( dummyEnhancer ) ,
290+ describe ( 'invalid arguments ', ( ) => {
291+ test ( 'enhancers is not a callback' , ( ) => {
292+ expect ( ( ) => configureStore ( { reducer, enhancers : [ ] as any } ) ) . toThrow (
293+ '" enhancers" field must be a callback'
294+ )
293295 } )
294296
295- expect ( dummyEnhancerCalled ) . toBe ( true )
297+ test ( 'callback fails to return array' , ( ) => {
298+ expect ( ( ) =>
299+ configureStore ( { reducer, enhancers : ( ( ) => { } ) as any } )
300+ ) . toThrow ( '"enhancers" callback must return an array' )
301+ } )
302+
303+ test ( 'array contains non-function' , ( ) => {
304+ expect ( ( ) =>
305+ configureStore ( { reducer, enhancers : ( ( ) => [ '' ] ) as any } )
306+ ) . toThrow ( 'each enhancer provided to configureStore must be a function' )
307+ } )
296308 } )
297309
298310 const consoleSpy = vi . spyOn ( console , 'error' ) . mockImplementation ( ( ) => { } )
@@ -306,20 +318,20 @@ describe('configureStore', async () => {
306318 it ( 'warns if middleware enhancer is excluded from final array when middlewares are provided' , ( ) => {
307319 const store = configureStore ( {
308320 reducer,
309- enhancers : new Tuple ( dummyEnhancer ) ,
321+ enhancers : ( ) => new Tuple ( dummyEnhancer ) ,
310322 } )
311323
312324 expect ( dummyEnhancerCalled ) . toBe ( true )
313325
314326 expect ( consoleSpy ) . toHaveBeenCalledWith (
315- 'middlewares were provided, but middleware enhancer was not included in final enhancers'
327+ 'middlewares were provided, but middleware enhancer was not included in final enhancers - make sure to call `getDefaultEnhancers` '
316328 )
317329 } )
318330 it ( "doesn't warn when middleware enhancer is excluded if no middlewares provided" , ( ) => {
319331 const store = configureStore ( {
320332 reducer,
321333 middleware : new Tuple ( ) ,
322- enhancers : new Tuple ( dummyEnhancer ) ,
334+ enhancers : ( ) => new Tuple ( dummyEnhancer ) ,
323335 } )
324336
325337 expect ( dummyEnhancerCalled ) . toBe ( true )
0 commit comments