Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update tests to handle update argument in listeners
  • Loading branch information
lkmill committed Dec 1, 2019
commit 3b1e5b9ff06e673020d596c899754586c5057890
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