Skip to content

Instantly share code, notes, and snippets.

@matthewlehner
Created January 7, 2016 18:44
Show Gist options
  • Save matthewlehner/5aa8dcfe6a0fe00403af to your computer and use it in GitHub Desktop.
Save matthewlehner/5aa8dcfe6a0fe00403af to your computer and use it in GitHub Desktop.
Writing tests for redux reducers
import { expect } from "chai";
import reducer from "../../src/reducers/workspace";
import { EDIT_ITEM } from "../../src/actions/workspace";
describe("workspace reducer", () => {
it("handles EDIT_ITEM", () => {
const initialState = {};
const action = {
type: EDIT_ITEM,
itemIndex: 1
};
const nextState = reducer(initialState, action);
expect(nextState.editingItem).to.equal(1);
expect(nextState.isEditing).to.equal(true);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment