Testing Store - Tuong-Nguyen/JavaScript-Structure GitHub Wiki
Purpose
- Integration test
- Test Store's state
Steps
Create store with reducers and initial state
const store = createStore(rootReducer, initialState);
Create actions
const course = {title: 'Clean code'};
const action = courseActions.createCourseSuccess(course);
Dispatch actions
store.dispatch(action);
state
Assert output getState()
: get state from Store
const actual = store.getState().courses[0];
expect(actual).toEqual(course);