Skip to content

Commit

Permalink
Add simple unit tests for reducer.js
Browse files Browse the repository at this point in the history
  • Loading branch information
MrOrz committed Oct 2, 2017
1 parent 40b15f2 commit 28d2b77
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
14 changes: 14 additions & 0 deletions util/__tests__/__snapshots__/reducer.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`reducer commonSetState sets state from payload 1`] = `
Immutable.Map {
"foo": "bar2",
}
`;

exports[`reducer commonSetState sets state from payload 2`] = `
Immutable.Map {
"foo": "bar",
"not-exist-key": "new-value",
}
`;
22 changes: 21 additions & 1 deletion util/__tests__/reducer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
import { fromJS } from 'immutable';
import { commonSetState } from '../reducer';

describe('reducer', () => {
describe('commonSetState', () => {
it('sets state from payload');
const initState = fromJS({
state: {
foo: 'bar',
},
});
it('sets state from payload', () => {
expect(
commonSetState(initState, {
payload: { key: 'foo', value: 'bar2' },
}).get('state')
).toMatchSnapshot();

expect(
commonSetState(initState, {
payload: { key: 'not-exist-key', value: 'new-value' },
}).get('state')
).toMatchSnapshot();
});
});
});

0 comments on commit 28d2b77

Please sign in to comment.