-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[@xstate/graph] Mock
actorContext
(#4308)
* Add mock actorContext * Changeset * Refine test
- Loading branch information
1 parent
5fd8f26
commit af032db
Showing
9 changed files
with
74 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
'@xstate/graph': patch | ||
--- | ||
|
||
Traversing state machines that have delayed transitions will now work as expected: | ||
|
||
```ts | ||
const machine = createMachine({ | ||
initial: 'a', | ||
states: { | ||
a: { | ||
after: { | ||
1000: 'b' | ||
} | ||
}, | ||
b: {} | ||
} | ||
}); | ||
|
||
const paths = getShortestPaths(machine); // works | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { AnyActorContext, createEmptyActor } from 'xstate'; | ||
|
||
export function createMockActorContext(): AnyActorContext { | ||
const emptyActor = createEmptyActor(); | ||
return { | ||
self: emptyActor, | ||
logger: console.log, | ||
id: '', | ||
sessionId: Math.random().toString(32).slice(2), | ||
defer: () => {}, | ||
system: emptyActor, | ||
stopChild: () => {} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters