-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simple utility to reduce the boilerplate of bringing a bare React view into xstate-tree land Closes View to machine utility #51
- Loading branch information
Showing
6 changed files
with
86 additions
and
36 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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
*.snap | ||
*.typegen.ts | ||
README.md |
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,18 @@ | ||
import { render, waitFor } from "@testing-library/react"; | ||
import React from "react"; | ||
|
||
import { viewToMachine } from "./builders"; | ||
import { buildRootComponent } from "./xstateTree"; | ||
|
||
describe("xstate-tree builders", () => { | ||
describe("viewToMachine", () => { | ||
it("takes a React view and wraps it in an xstate-tree machine that renders that view", async () => { | ||
const ViewMachine = viewToMachine(() => <div>hello world</div>); | ||
const Root = buildRootComponent(ViewMachine); | ||
|
||
const { getByText } = render(<Root />); | ||
|
||
await waitFor(() => getByText("hello world")); | ||
}); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,35 @@ | ||
// This file was automatically generated. Edits will be overwritten | ||
|
||
export interface Typegen0 { | ||
"@@xstate/typegen": true; | ||
internalEvents: { | ||
"xstate.init": { type: "xstate.init" }; | ||
}; | ||
invokeSrcNameMap: { | ||
OtherMachine: "done.invoke.app.otherScreen:invocation[0]"; | ||
TodosMachine: "done.invoke.app.todos:invocation[0]"; | ||
}; | ||
missingImplementations: { | ||
actions: never; | ||
services: never; | ||
guards: never; | ||
delays: never; | ||
}; | ||
eventsCausingActions: {}; | ||
eventsCausingServices: { | ||
OtherMachine: "GO_SETTINGS"; | ||
TodosMachine: "GO_HOME"; | ||
}; | ||
eventsCausingGuards: {}; | ||
eventsCausingDelays: {}; | ||
matchesStates: "otherScreen" | "todos" | "waitingForRoute"; | ||
tags: never; | ||
} | ||
// This file was automatically generated. Edits will be overwritten | ||
|
||
export interface Typegen0 { | ||
'@@xstate/typegen': true; | ||
internalEvents: { | ||
"xstate.init": { type: "xstate.init" }; | ||
}; | ||
invokeSrcNameMap: { | ||
"OtherMachine": "done.invoke.app.otherScreen:invocation[0]"; | ||
"TodosMachine": "done.invoke.app.todos:invocation[0]"; | ||
}; | ||
missingImplementations: { | ||
actions: never; | ||
delays: never; | ||
guards: never; | ||
services: never; | ||
}; | ||
eventsCausingActions: { | ||
|
||
}; | ||
eventsCausingDelays: { | ||
|
||
}; | ||
eventsCausingGuards: { | ||
|
||
}; | ||
eventsCausingServices: { | ||
"OtherMachine": "GO_SETTINGS"; | ||
"TodosMachine": "GO_HOME"; | ||
}; | ||
matchesStates: "otherScreen" | "todos" | "waitingForRoute"; | ||
tags: never; | ||
} | ||
|
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