@@ -101,15 +101,38 @@ describe('createMiddleware', () => {
101101 const store = { getState : sinon . spy ( ) } ;
102102 const next = sinon . spy ( ) ;
103103 const action = { type : 'ALLOWED' } ;
104- const whitelistFn = ( type ) => {
105- return type === 'ALLOWED' ;
106- } ;
104+ const whitelistFn = ( ) => true ;
107105
108106 createMiddleware ( engine , [ ] , whitelistFn ) ( store ) ( next ) ( action ) ;
109107
110108 engine . save . should . have . been . called ;
111109 } ) ;
112110
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+
113136 describeConsoleWarnInNonProduction (
114137 'should not process functions' ,
115138 ( ) => {
0 commit comments