Skip to content

Commit

Permalink
add test for fix
Browse files Browse the repository at this point in the history
  • Loading branch information
EskiMojo14 committed Nov 28, 2024
1 parent c65558a commit 05a8322
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ describe('createListenerMiddleware', () => {
const testAction1 = createAction<string>('testAction1')
type TestAction1 = ReturnType<typeof testAction1>
const testAction2 = createAction<string>('testAction2')
type TestAction2 = ReturnType<typeof testAction2>
const testAction3 = createAction<string>('testAction3')

beforeAll(() => {
Expand Down Expand Up @@ -339,6 +340,27 @@ describe('createListenerMiddleware', () => {
])
})

test('subscribing with the same effect but different predicate is allowed', () => {
const effect = vi.fn((_: TestAction1 | TestAction2) => {})

startListening({
actionCreator: testAction1,
effect,
})
startListening({
actionCreator: testAction2,
effect,
})

store.dispatch(testAction1('a'))
store.dispatch(testAction2('b'))

expect(effect.mock.calls).toEqual([
[testAction1('a'), middlewareApi],
[testAction2('b'), middlewareApi],
])
})

test('unsubscribing via callback', () => {
const effect = vi.fn((_: TestAction1) => {})

Expand Down

0 comments on commit 05a8322

Please # to comment.