@@ -104,40 +104,25 @@ describe('applyMiddleware', () => {
104
104
} )
105
105
106
106
it ( 'passes through all arguments of dispatch calls from within middleware' , ( ) => {
107
- const spy = jest . fn ( )
108
- const testCallArgs = [ 'test' ]
109
- function multiArgMiddleware ( ) {
110
- return next => ( action , callArgs ) => {
111
- if ( Array . isArray ( callArgs ) ) {
112
- return action ( ...callArgs )
113
- }
114
- return next ( action )
107
+ const spy = jest . fn ( )
108
+ const testCallArgs = [ 'test' ]
109
+
110
+ function multiArgMiddleware ( ) {
111
+ return next => ( action , callArgs ) => {
112
+ if ( Array . isArray ( callArgs ) ) {
113
+ return action ( ...callArgs )
115
114
}
115
+ return next ( action )
116
116
}
117
- function dummyMiddleware ( { dispatch } ) {
118
- return next => action => dispatch ( action , testCallArgs )
119
- }
120
-
121
- const store = createStore ( reducers . todos , applyMiddleware ( multiArgMiddleware , dummyMiddleware ) )
122
- store . dispatch ( spy )
123
- expect ( spy . mock . calls [ 0 ] ) . toEqual ( testCallArgs )
124
- } )
125
-
126
- it ( 'keeps unwrapped dispatch available while middleware is initializing' , ( ) => {
127
- // This is documenting the existing behavior in Redux 3.x.
128
- // We plan to forbid this in Redux 4.x.
117
+ }
129
118
130
- function earlyDispatch ( { dispatch } ) {
131
- dispatch ( addTodo ( 'Hello' ) )
132
- return ( ) => action => action
119
+ function dummyMiddleware ( { dispatch } ) {
120
+ return next => action => dispatch ( action , testCallArgs )
133
121
}
134
122
135
- const store = createStore ( reducers . todos , applyMiddleware ( earlyDispatch ) )
136
- expect ( store . getState ( ) ) . toEqual ( [
137
- {
138
- id : 1 ,
139
- text : 'Hello'
140
- }
141
- ] )
123
+ const store = createStore ( reducers . todos , applyMiddleware ( multiArgMiddleware , dummyMiddleware ) )
124
+
125
+ store . dispatch ( spy )
126
+ expect ( spy . mock . calls [ 0 ] ) . toEqual ( testCallArgs )
142
127
} )
143
128
} )
0 commit comments