Skip to content

Commit

Permalink
Add Printview Test for integret component
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsummers1 committed Sep 9, 2024
1 parent 6ff0f5c commit 1e5733b
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions services/ui-src/src/components/fields/Integer.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const buildInteger = (intProps) => {
</Provider>
);
};

describe("<Integer />", () => {
it("should render correctly", () => {
const props = { question: { id: "2023-00-a-01-01", answer: 1 } };
Expand All @@ -29,7 +30,7 @@ describe("<Integer />", () => {
const props = {
question: {
id: "2023-00-a-01-01",
label: "How many lightbulbs does it take to change a man?",
label: "Example Question",
answer: { entry: 123 },
},
};
Expand All @@ -45,7 +46,7 @@ describe("<Integer />", () => {
const props = {
question: {
id: "2023-00-a-01-01",
label: "How many lightbulbs does it take to change a man?",
label: "Example Question",
answer: { entry: 123 },
},
};
Expand All @@ -61,7 +62,7 @@ describe("<Integer />", () => {
const props = {
question: {
id: "2023-00-a-01-01",
label: "How many lightbulbs does it take to change a man?",
label: "Example Question",
answer: { entry: "hope" },
},
};
Expand All @@ -73,4 +74,20 @@ describe("<Integer />", () => {
expect(screen.queryByDisplayValue("raw text")).not.toBeInTheDocument();
expect(screen.getByRole("alert")).toBeInTheDocument();
});

it("should show <11 if in printView and passed the mask", () => {
const props = {
question: {
id: "2023-00-a-01-01",
label: "Example Question",
answer: { entry: "5" },
mask: "lessThanEleven",
},
printView: true,
};

render(buildInteger(props));
expect(screen.getByDisplayValue("<11")).toBeInTheDocument();
expect(screen.queryByDisplayValue("5")).not.toBeInTheDocument();
});
});

0 comments on commit 1e5733b

Please sign in to comment.