-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(jest): introduce coverage check
- Loading branch information
1 parent
82fe5de
commit f7b1d47
Showing
4 changed files
with
101 additions
and
2 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
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
90 changes: 90 additions & 0 deletions
90
...nes/Application/components/ApplicationSteps/components/__tests__/ApplicationStep.test.tsx
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,90 @@ | ||
import { screen, render } from "@testing-library/react"; | ||
import ApplicationStep from "../ApplicationStep"; | ||
import getLocalApplicationDataStepCompleted from "@/services/helpers/localData/getLocalApplicationDataStepCompleted"; | ||
|
||
jest.mock( | ||
"../../../../../../services/helpers/localData/getLocalApplicationDataStepCompleted" | ||
); | ||
|
||
const renderComponent = ({ | ||
isCompleted, | ||
shouldUseLocalIsCompleted, | ||
isLocalCompleted, | ||
}: { | ||
isCompleted: boolean; | ||
shouldUseLocalIsCompleted: boolean; | ||
isLocalCompleted: boolean; | ||
}) => { | ||
(getLocalApplicationDataStepCompleted as jest.Mock).mockReturnValue( | ||
isLocalCompleted | ||
); | ||
const step = { | ||
id: 1, | ||
position: 1, | ||
title: "Personal Details", | ||
isCompleted, | ||
formFields: [], | ||
}; | ||
render( | ||
<ApplicationStep | ||
step={step} | ||
shouldUseLocalIsCompleted={shouldUseLocalIsCompleted} | ||
/> | ||
); | ||
}; | ||
|
||
describe("ApplicationStep", () => { | ||
it("should render the step with the correct text", () => { | ||
renderComponent({ | ||
isCompleted: false, | ||
shouldUseLocalIsCompleted: false, | ||
isLocalCompleted: false, | ||
}); | ||
expect( | ||
screen.getByRole("link", { name: "1. Personal Details" }) | ||
).toBeVisible(); | ||
expect( | ||
screen.queryByTestId("Step 1 completed icon") | ||
).not.toBeInTheDocument(); | ||
}); | ||
|
||
it("should render the step with the correct text and icon when completed", () => { | ||
renderComponent({ | ||
isCompleted: true, | ||
shouldUseLocalIsCompleted: false, | ||
isLocalCompleted: false, | ||
}); | ||
expect( | ||
screen.getByRole("link", { name: "1. Personal Details" }) | ||
).toBeVisible(); | ||
expect(screen.queryByTestId("Step 1 completed icon")).toBeVisible(); | ||
}); | ||
|
||
describe("when shouldUseLocalIsCompleted is true", () => { | ||
it("should render the step with the correct text and icon when not completed", () => { | ||
renderComponent({ | ||
isCompleted: false, | ||
shouldUseLocalIsCompleted: true, | ||
isLocalCompleted: false, | ||
}); | ||
expect( | ||
screen.getByRole("link", { name: "1. Personal Details" }) | ||
).toBeVisible(); | ||
expect( | ||
screen.queryByTestId("Step 1 completed icon") | ||
).not.toBeInTheDocument(); | ||
}); | ||
|
||
it("should render the step with the correct text and icon when completed", () => { | ||
renderComponent({ | ||
isCompleted: false, | ||
shouldUseLocalIsCompleted: true, | ||
isLocalCompleted: true, | ||
}); | ||
expect( | ||
screen.getByRole("link", { name: "1. Personal Details" }) | ||
).toBeVisible(); | ||
expect(screen.queryByTestId("Step 1 completed icon")).toBeVisible(); | ||
}); | ||
}); | ||
}); |