Skip to content

Commit

Permalink
test passing with duplicated machine
Browse files Browse the repository at this point in the history
  • Loading branch information
technoplato committed Mar 22, 2024
1 parent 036e469 commit dc1d725
Show file tree
Hide file tree
Showing 4 changed files with 492 additions and 415 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,43 @@ import {
const user = { name: 'David' };

describe('invoke', () => {
it('should be possible to send immediate events to initially invoked actors', () => {
const child = createMachine({
on: {
PING: {
actions: sendParent({ type: 'PONG' }),
},
},
});

const machine = createMachine({
initial: 'waiting',
states: {
waiting: {
invoke: {
id: 'ponger',
src: child,
},
// entry: sendTo('ponger', { type: 'PING' }),
on: {
PONG: 'done',
sendPing: {
actions: sendTo('ponger', { type: 'PING' }),
},
},
},
done: {
type: 'final',
},
},
});

const service = createActor(machine).start();
service.send({ type: 'sendPing' });

expect(service.getSnapshot().value).toBe('done');
});

it('child can immediately respond to the parent with multiple events', () => {
const childMachine = createMachine({
types: {} as {
Expand Down
Loading

0 comments on commit dc1d725

Please sign in to comment.