Skip to content

Commit 05a8322

Browse files
committed
add test for fix
1 parent c65558a commit 05a8322

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

packages/toolkit/src/listenerMiddleware/tests/listenerMiddleware.test.ts

+22
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ describe('createListenerMiddleware', () => {
117117
const testAction1 = createAction<string>('testAction1')
118118
type TestAction1 = ReturnType<typeof testAction1>
119119
const testAction2 = createAction<string>('testAction2')
120+
type TestAction2 = ReturnType<typeof testAction2>
120121
const testAction3 = createAction<string>('testAction3')
121122

122123
beforeAll(() => {
@@ -339,6 +340,27 @@ describe('createListenerMiddleware', () => {
339340
])
340341
})
341342

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+
342364
test('unsubscribing via callback', () => {
343365
const effect = vi.fn((_: TestAction1) => {})
344366

0 commit comments

Comments
 (0)