-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Capture
FileList
to breadcrumbs
- Loading branch information
1 parent
b180df9
commit cf28660
Showing
6 changed files
with
85 additions
and
4 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
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
50 changes: 50 additions & 0 deletions
50
editor.planx.uk/src/pages/FlowEditor/lib/__tests__/preview/captureNodeState.test.ts
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,50 @@ | ||
import { TYPES } from "@planx/components/types"; | ||
|
||
import { vanillaStore } from "../../store"; | ||
import { Store } from './../../store/index'; | ||
|
||
const { getState, setState } = vanillaStore; | ||
const { record } = getState(); | ||
|
||
test("record() captures state in breadcrumbs", () => { | ||
setState({ | ||
flow: { | ||
_root: { | ||
edges: ["a", "b"], | ||
}, | ||
a: { | ||
type: TYPES.Statement, | ||
edges: ["c"], | ||
}, | ||
b: { | ||
type: TYPES.Statement, | ||
}, | ||
c: { | ||
type: TYPES.Response, | ||
edges: ["d"], | ||
}, | ||
d: { | ||
type: TYPES.Statement, | ||
edges: ["e", "f"], | ||
}, | ||
e: { type: TYPES.Response }, | ||
f: { type: TYPES.Response }, | ||
}, | ||
}); | ||
|
||
const state: Store.NodeState = { | ||
type: TYPES.Statement, someStateData: { hello: "world", number: 42, isLive: true, deepObject: { hello: "again" } } | ||
}; | ||
|
||
const data: Store.userData = { data: { projectType: "extension" } }; | ||
|
||
record("a", { answers: ["c"], data, state }); | ||
|
||
// State captured in breadcrumbs | ||
expect(getState().breadcrumbs).toEqual({ | ||
a: { answers: ["c"], auto: false, data, state }, | ||
}); | ||
|
||
// State not captured in passport | ||
expect(getState().computePassport()).toEqual({ data }); | ||
}); |
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