Skip to content

Instantly share code, notes, and snippets.

@andirkh
Last active March 27, 2021 21:39
Show Gist options
  • Save andirkh/264973c7ab7762f2673a11f43a02a40f to your computer and use it in GitHub Desktop.
Save andirkh/264973c7ab7762f2673a11f43a02a40f to your computer and use it in GitHub Desktop.
Template for testing reducer
import ReducerName, {
initialState,
} from '#src/containers/ContainerName/reducer';
import {
...
} from '#src/containers/ContainerName/constants';
describe('ReducerName reducer', () => {
const initialStateJS = initialState.toJS();
const testTable = [
{
title: 'it should return initial state',
action: { type: undefined },
expected: initialStateJS,
},
];
testTable.forEach(({ title, action, expected }) => {
it(`${title}`, () => {
expect(ReducerName(initialState, action).toJS()).toEqual(
expected
);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment