@@ -101,15 +101,38 @@ describe('createMiddleware', () => {
101
101
const store = { getState : sinon . spy ( ) } ;
102
102
const next = sinon . spy ( ) ;
103
103
const action = { type : 'ALLOWED' } ;
104
- const whitelistFn = ( type ) => {
105
- return type === 'ALLOWED' ;
106
- } ;
104
+ const whitelistFn = ( ) => true ;
107
105
108
106
createMiddleware ( engine , [ ] , whitelistFn ) ( store ) ( next ) ( action ) ;
109
107
110
108
engine . save . should . have . been . called ;
111
109
} ) ;
112
110
111
+ it ( 'should ignore actions if the whitelist function returns false' , ( ) => {
112
+ const engine = { save : sinon . stub ( ) . resolves ( ) } ;
113
+ const store = { getState : sinon . spy ( ) } ;
114
+ const next = sinon . spy ( ) ;
115
+ const action = { type : 'ALLOWED' } ;
116
+ const whitelistFn = ( ) => false ;
117
+
118
+ createMiddleware ( engine , [ ] , whitelistFn ) ( store ) ( next ) ( action ) ;
119
+
120
+ engine . save . should . not . have . been . called ;
121
+ } ) ;
122
+
123
+ it ( 'should pass the whole action to the whitelist function' , ( done ) => {
124
+ const engine = { save : sinon . stub ( ) . resolves ( ) } ;
125
+ const store = { getState : sinon . spy ( ) } ;
126
+ const next = sinon . spy ( ) ;
127
+ const action = { type : 'ALLOWED' } ;
128
+ const whitelistFn = ( checkAction ) => {
129
+ checkAction . should . deep . equal ( action ) ;
130
+ done ( ) ;
131
+ } ;
132
+
133
+ createMiddleware ( engine , [ ] , whitelistFn ) ( store ) ( next ) ( action ) ;
134
+ } ) ;
135
+
113
136
describeConsoleWarnInNonProduction (
114
137
'should not process functions' ,
115
138
( ) => {
0 commit comments