Skip to content

Commit

Permalink
use a spy
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarist committed Sep 15, 2024
1 parent c38a72c commit db4f6f9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/xstate-store/test/fromStore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('fromStore', () => {
});

it('emits events', () => {
expect.assertions(2);
const spy = jest.fn();

const storeLogic = fromStore({
types: {
Expand All @@ -67,14 +67,14 @@ describe('fromStore', () => {
input: 42
});

actor.on('increased', (ev) => {
expect(ev).toEqual({ type: 'increased', upBy: 8 });
});
actor.on('increased', spy);

actor.start();

actor.send({ type: 'inc', by: 8 });

expect(actor.getSnapshot().context.count).toEqual(50);
expect(spy).toHaveBeenCalledTimes(1);
expect(spy).toHaveBeenCalledWith({ type: 'increased', upBy: 8 });
});
});

0 comments on commit db4f6f9

Please sign in to comment.