Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
shoonia committed Feb 20, 2024
1 parent 5b227e8 commit 348d663
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/on.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,19 @@ describe('state.on()', () => {
expect(spy).toHaveBeenCalledTimes(1);
expect(spy).toHaveBeenCalledWith({}, '1');
});

it('should not update state by async listener', () => {
expect.hasAssertions();

const event = randomUUID();

const { dispatch, getState } = createStoreon([
(store) => {
store.on(event, async () => ({ x: 1 }));
},
]);

dispatch(event);
expect(getState()).toStrictEqual({});
});
});

0 comments on commit 348d663

Please sign in to comment.