Skip to content

Instantly share code, notes, and snippets.

@junibrosas
Last active October 14, 2017 07:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save junibrosas/f8102fd8e0b5c8a848961403abff8381 to your computer and use it in GitHub Desktop.
Save junibrosas/f8102fd8e0b5c8a848961403abff8381 to your computer and use it in GitHub Desktop.
Compilation of snippets for testing reducers in React with Redux.
import { IState } from './types';
import { MyReducer } from './path/to/my/reducer';
import { expect, assert } from 'chai';
describe("DashBoardTodoListStateReducer", () =>
{
var defaultState:IState
beforeEach(() => {
defaultState = MyReducer(undefined, undefined);
});
it("Should set List.", () =>
{
var value = [];
var state = MyReducer(defaultState, {type:"MyAction", Value:value});
chai.assert.equal(state.List, value, "List was not set in the reducer.");
chai.assert.notEqual(defaultState, state, "Mutable state detected!")
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment