Skip to content

Commit

Permalink
Update tests to handle update argument in listeners
Browse files Browse the repository at this point in the history
  • Loading branch information
lkmill committed Dec 1, 2019
1 parent 9f22c9c commit 3b1e5b9
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions test/unistore.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,17 @@ describe('createStore()', () => {
let rval = store.subscribe(sub1);
expect(rval).toBeInstanceOf(Function);

store.setState({ a: 'b' });
expect(sub1).toBeCalledWith(store.getState(), action);
let update1 = { a: 'b' };
store.setState(update1);
expect(sub1).toBeCalledWith(store.getState(), action, update1);

store.subscribe(sub2);
store.setState({ c: 'd' });
let update2 = { c: 'd' };
store.setState(update2);

expect(sub1).toHaveBeenCalledTimes(2);
expect(sub1).toHaveBeenLastCalledWith(store.getState(), action);
expect(sub2).toBeCalledWith(store.getState(), action);
expect(sub1).toHaveBeenLastCalledWith(store.getState(), action, update2);
expect(sub2).toBeCalledWith(store.getState(), action, update2);
});

it('should unsubscribe', () => {
Expand Down

0 comments on commit 3b1e5b9

Please sign in to comment.