UX: `ofType(..).matching(...)` uses predicates, could use assertions
rradczewski opened this issue · 1 comments
rradczewski commented
The suggested use cases is as following:
1. Matching exactly one action dispatched to the store.
Given a test where exactly one action
of $type
is expected to be dispatched, we want to use an assertion-library to check whether the action matches. An action that does not match the assertion is considered a failure, possibly with a meaningful error message.
const store;
store.dispatch({type: 'IRRELEVANT'});
store.dispatch({type: 'FOO', payload: 3});
return expectRedux(store)
.toDispatchAnAction()
.ofType('FOO')
.expectingExclusively(action => expect(action.payload).toEqual(3));
2. Matching one of the actions dispatched to the store using assertions
const store;
store.dispatch({type: 'IRRELEVANT'});
store.dispatch({type: 'FOO', payload: 3});
return expectRedux(store)
.toDispatchAnAction()
.ofType('FOO')
.expecting(action => expect(action.payload).toEqual(3));
rradczewski commented
Went with 2. for 3.2.0