File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
packages/toolkit/src/listenerMiddleware/tests Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -117,6 +117,7 @@ describe('createListenerMiddleware', () => {
117
117
const testAction1 = createAction < string > ( 'testAction1' )
118
118
type TestAction1 = ReturnType < typeof testAction1 >
119
119
const testAction2 = createAction < string > ( 'testAction2' )
120
+ type TestAction2 = ReturnType < typeof testAction2 >
120
121
const testAction3 = createAction < string > ( 'testAction3' )
121
122
122
123
beforeAll ( ( ) => {
@@ -339,6 +340,27 @@ describe('createListenerMiddleware', () => {
339
340
] )
340
341
} )
341
342
343
+ test ( 'subscribing with the same effect but different predicate is allowed' , ( ) => {
344
+ const effect = vi . fn ( ( _ : TestAction1 | TestAction2 ) => { } )
345
+
346
+ startListening ( {
347
+ actionCreator : testAction1 ,
348
+ effect,
349
+ } )
350
+ startListening ( {
351
+ actionCreator : testAction2 ,
352
+ effect,
353
+ } )
354
+
355
+ store . dispatch ( testAction1 ( 'a' ) )
356
+ store . dispatch ( testAction2 ( 'b' ) )
357
+
358
+ expect ( effect . mock . calls ) . toEqual ( [
359
+ [ testAction1 ( 'a' ) , middlewareApi ] ,
360
+ [ testAction2 ( 'b' ) , middlewareApi ] ,
361
+ ] )
362
+ } )
363
+
342
364
test ( 'unsubscribing via callback' , ( ) => {
343
365
const effect = vi . fn ( ( _ : TestAction1 ) => { } )
344
366
You can’t perform that action at this time.
0 commit comments