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 37a2283
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 4 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 @@ -275,6 +275,10 @@ const componentFormatters: ComponentMap = {
return formatted;
}
},
// Find property is referred to internally as "find-property-merged"
[ComponentType.FindProperty]: {
getComponentType: () => "Find property",
}
};

/**
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
};

0 comments on commit 37a2283

Please sign in to comment.