Skip to content

Commit

Permalink
fix(alm): re-enable 34 skipped tests and fix 3 tests
Browse files Browse the repository at this point in the history
Changes:

- removes an .only that prevented the execution of 34 tests
- fix: 'Can subscribe with an action predicate function' test
- fix: 'condition method resolves promise when there is a timeout'
- fix: 'condition method resolves promise when the predicate succeeds'
  • Loading branch information
FaberVitale committed Jan 2, 2022
1 parent a7f1dfc commit 54490d9
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,10 @@ describe('createActionListenerMiddleware', () => {
let listener1Calls = 0

middleware.addListener({
predicate: (action, state, previousState) => {
predicate: (action, state) => {
return (state as CounterState).value > 1
},
listener: (action, listenerApi) => {
listener: () => {
listener1Calls++
},
})
Expand All @@ -280,7 +280,7 @@ describe('createActionListenerMiddleware', () => {
(prevState as CounterState).value % 2 === 0
)
},
listener: (action, listenerApi) => {
listener: () => {
listener2Calls++
},
})
Expand All @@ -291,7 +291,7 @@ describe('createActionListenerMiddleware', () => {
store.dispatch(increment())

expect(listener1Calls).toBe(3)
expect(listener2Calls).toBe(2)
expect(listener2Calls).toBe(1)
})

test('subscribing with the same listener will not make it trigger twice (like EventTarget.addEventListener())', () => {
Expand Down Expand Up @@ -690,7 +690,7 @@ describe('createActionListenerMiddleware', () => {
})

describe('take and condition methods', () => {
test.only('take resolves to the tuple [A, CurrentState, PreviousState] when the predicate matches the action', async () => {
test('take resolves to the tuple [A, CurrentState, PreviousState] when the predicate matches the action', async () => {
const store = configureStore({
reducer: counterSlice.reducer,
middleware: (gDM) => gDM().prepend(middleware),
Expand Down Expand Up @@ -766,10 +766,10 @@ describe('createActionListenerMiddleware', () => {
let listenerStarted = false

middleware.addListener({
predicate: (action, currentState) => {
predicate: (action, _, previousState) => {
return (
increment.match(action) &&
(currentState as CounterState).value === 0
(previousState as CounterState).value === 0
)
},
listener: async (action, listenerApi) => {
Expand All @@ -785,6 +785,7 @@ describe('createActionListenerMiddleware', () => {
})

store.dispatch(increment())

expect(listenerStarted).toBe(true)
await delay(25)
store.dispatch(increment())
Expand All @@ -808,7 +809,7 @@ describe('createActionListenerMiddleware', () => {
predicate: (action, currentState) => {
return (
increment.match(action) &&
(currentState as CounterState).value === 0
(currentState as CounterState).value === 1
)
},
listener: async (action, listenerApi) => {
Expand Down

0 comments on commit 54490d9

Please sign in to comment.