Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract state keys #456

Merged
merged 3 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
147 changes: 80 additions & 67 deletions new-packages/ts-project/__tests__/actions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ test('should extract a string entry action (direct)', async () => {
"history": undefined,
"initial": undefined,
"invoke": [],
"key": "(machine)",
"metaEntries": [],
"tags": [],
"type": "normal",
Expand Down Expand Up @@ -130,6 +131,7 @@ test('should extract a string exit action (direct)', async () => {
"history": undefined,
"initial": undefined,
"invoke": [],
"key": "(machine)",
"metaEntries": [],
"tags": [],
"type": "normal",
Expand Down Expand Up @@ -203,6 +205,7 @@ test('should extract a string action (in array)', async () => {
"history": undefined,
"initial": undefined,
"invoke": [],
"key": "(machine)",
"metaEntries": [],
"tags": [],
"type": "normal",
Expand Down Expand Up @@ -292,6 +295,7 @@ test('should extract multiple string actions', async () => {
"history": undefined,
"initial": undefined,
"invoke": [],
"key": "(machine)",
"metaEntries": [],
"tags": [],
"type": "normal",
Expand Down Expand Up @@ -367,6 +371,7 @@ test('should extract a simple parameterized action (direct)', async () => {
"history": undefined,
"initial": undefined,
"invoke": [],
"key": "(machine)",
"metaEntries": [],
"tags": [],
"type": "normal",
Expand Down Expand Up @@ -444,6 +449,7 @@ test('should extract a simple parameterized action (in array)', async () => {
"history": undefined,
"initial": undefined,
"invoke": [],
"key": "(machine)",
"metaEntries": [],
"tags": [],
"type": "normal",
Expand Down Expand Up @@ -517,6 +523,7 @@ test('should extract an inline action (function)', async () => {
"history": undefined,
"initial": undefined,
"invoke": [],
"key": "(machine)",
"metaEntries": [],
"tags": [],
"type": "normal",
Expand Down Expand Up @@ -592,6 +599,7 @@ test('should extract an inline action (builtin)', async () => {
"history": undefined,
"initial": undefined,
"invoke": [],
"key": "(machine)",
"metaEntries": [],
"tags": [],
"type": "normal",
Expand Down Expand Up @@ -646,6 +654,7 @@ test('should error when extracting undefined action (direct)', async () => {
"history": undefined,
"initial": undefined,
"invoke": [],
"key": "(machine)",
"metaEntries": [],
"tags": [],
"type": "normal",
Expand Down Expand Up @@ -704,6 +713,7 @@ test('should error when extracting undefined action (in array)', async () => {
"history": undefined,
"initial": undefined,
"invoke": [],
"key": "(machine)",
"metaEntries": [],
"tags": [],
"type": "normal",
Expand Down Expand Up @@ -803,6 +813,7 @@ test('should extract a transition action', async () => {
"history": undefined,
"initial": undefined,
"invoke": [],
"key": "(machine)",
"metaEntries": [],
"tags": [],
"type": "normal",
Expand Down Expand Up @@ -877,6 +888,7 @@ test('should not register multiple entry actions with duplicated entry property'
"history": undefined,
"initial": undefined,
"invoke": [],
"key": "(machine)",
"metaEntries": [],
"tags": [],
"type": "normal",
Expand Down Expand Up @@ -914,78 +926,79 @@ test('should not register multiple transition actions with duplicated actions pr
const project = await createTestProject(tmpPath);
expect(replaceUniqueIds(project.extractMachines('index.ts')))
.toMatchInlineSnapshot(`
[
[
{
"blocks": {
"block-0": {
"blockType": "action",
"parentId": "edge-0",
"properties": {
"params": {},
"type": "callAnders",
},
"sourceId": "callAnders",
"uniqueId": "block-0",
[
{
"blocks": {
"block-0": {
"blockType": "action",
"parentId": "edge-0",
"properties": {
"params": {},
"type": "callAnders",
},
"sourceId": "callAnders",
"uniqueId": "block-0",
},
},
},
"data": {
"context": {},
},
"edges": {
"edge-0": {
"data": {
"actions": [
"block-0",
],
"description": undefined,
"eventTypeData": {
"eventType": "EVENT",
"type": "named",
},
"guard": undefined,
"internal": true,
"metaEntries": [],
},
"source": "state-0",
"targets": [],
"type": "edge",
"uniqueId": "edge-0",
"data": {
"context": {},
},
},
"implementations": {
"actions": {
"callAnders": {
"id": "callAnders",
"name": "callAnders",
"type": "action",
"edges": {
"edge-0": {
"data": {
"actions": [
"block-0",
],
"description": undefined,
"eventTypeData": {
"eventType": "EVENT",
"type": "named",
},
"guard": undefined,
"internal": true,
"metaEntries": [],
},
"source": "state-0",
"targets": [],
"type": "edge",
"uniqueId": "edge-0",
},
},
"actors": {},
"guards": {},
},
"nodes": {
"state-0": {
"data": {
"description": undefined,
"entry": [],
"exit": [],
"history": undefined,
"initial": undefined,
"invoke": [],
"metaEntries": [],
"tags": [],
"type": "normal",
},
"parentId": undefined,
"type": "node",
"uniqueId": "state-0",
"implementations": {
"actions": {
"callAnders": {
"id": "callAnders",
"name": "callAnders",
"type": "action",
},
},
"actors": {},
"guards": {},
},
"nodes": {
"state-0": {
"data": {
"description": undefined,
"entry": [],
"exit": [],
"history": undefined,
"initial": undefined,
"invoke": [],
"key": "(machine)",
"metaEntries": [],
"tags": [],
"type": "normal",
},
"parentId": undefined,
"type": "node",
"uniqueId": "state-0",
},
},
"root": "state-0",
},
"root": "state-0",
},
[],
],
]
`);
[],
],
]
`);
});
Loading
Loading