Skip to content

Commit

Permalink
test: Find property
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed Oct 16, 2024
1 parent 1a9a619 commit 3a89f10
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ComponentType } from "@opensystemslab/planx-core/types";
import { useStore } from "pages/FlowEditor/lib/store";

import { mockChecklistOptionResult, mockChecklistResult, mockConfirmationResult, mockContentResult, mockFileUploadAndLabelResult, mockFlow, mockNextStepsOptionResult, mockNumberInputResult, mockPayResult, mockQuestionResult, mockSchemaResult, mockTaskListResult } from "../mocks/allFacetFlow";
import { mockChecklistOptionResult, mockChecklistResult, mockConfirmationResult, mockContentResult, mockFileUploadAndLabelResult, mockFindPropertyResult, mockFlow, mockNextStepsOptionResult, mockNumberInputResult, mockPayResult, mockQuestionResult, mockSchemaResult, mockTaskListResult } from "../mocks/allFacetFlow";
import { getDisplayDetailsForResult } from "./getDisplayDetailsForResult";

type Output = ReturnType<typeof getDisplayDetailsForResult>;
Expand Down Expand Up @@ -453,9 +453,47 @@ describe("confirmation fields", () => {
});

describe("findProperty fields", () => {
it.todo("renders data.newAddressTitle");
it.todo("renders data.newAddressDescription");
it.todo("renders data.newAddressDescriptionLabel");
it("renders data.newAddressTitle", () => {
const output = getDisplayDetailsForResult(mockFindPropertyResult);

expect(output).toStrictEqual<Output>({
key: "Title (new address)",
iconKey: ComponentType.FindProperty,
componentType: "Find property",
title: ".",
headline: "Mouse",
});
});

it("renders data.newAddressDescription", () => {
const output = getDisplayDetailsForResult({
...mockFindPropertyResult,
key: "data.newAddressDescription",
});

expect(output).toStrictEqual<Output>({
key: "Description (new address)",
iconKey: ComponentType.FindProperty,
componentType: "Find property",
title: ".",
headline: "<p>Stingray</p>",
});
});

it("renders data.newAddressDescriptionLabel", () => {
const output = getDisplayDetailsForResult({
...mockFindPropertyResult,
key: "data.newAddressDescriptionLabel",
});

expect(output).toStrictEqual<Output>({
key: "Description label (new address)",
iconKey: ComponentType.FindProperty,
componentType: "Find property",
title: ".",
headline: "Scorpion",
});
});
});

describe("drawBoundary fields", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,3 +525,26 @@ export const mockConfirmationResult: SearchResult<IndexedNode> = {
matchIndices: [[0, 4]],
refIndex: 0,
};

export const mockFindPropertyResult: SearchResult<IndexedNode> = {
item: {
id: "uUQq7w7zDy",
parentId: "_root",
type: 9,
data: {
title: ".",
newAddressTitle: "Mouse",
allowNewAddresses: true,
newAddressDescription: "<p>Stingray</p>",
newAddressDescriptionLabel: "Scorpion"
}
},
key: "data.newAddressTitle",
matchIndices: [
[
0,
4
]
],
refIndex: 0
};
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const components: {
"external-portal": ExternalPortal,
"file-upload": FileUpload,
filter: Filter,
"find-property-merged": FindProperty,
"find-property": FindProperty,
flow: EmptyComponent,
"internal-portal": InternalPortal,
"file-upload-and-label": FileUploadAndLabel,
Expand Down
2 changes: 1 addition & 1 deletion editor.planx.uk/src/pages/FlowEditor/data/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const SLUGS: {
[TYPES.ExternalPortal]: "external-portal",
[TYPES.FileUpload]: "file-upload",
[TYPES.Filter]: "filter",
[TYPES.FindProperty]: "find-property-merged",
[TYPES.FindProperty]: "find-property",
[TYPES.Flow]: "flow",
[TYPES.InternalPortal]: "internal-portal",
[TYPES.FileUploadAndLabel]: "file-upload-and-label",
Expand Down

0 comments on commit 3a89f10

Please sign in to comment.