Skip to content

Commit 4eacd6c

Browse files
added unit test
1 parent 12c5c9c commit 4eacd6c

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

packages/cpt-ui/__tests__/EpsRoleSelectionPage.test.tsx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,43 @@ describe("RoleSelectionPage", () => {
270270
expect(screen.getByText("Admin")).toBeInTheDocument()
271271
})
272272

273+
it("doesnt render the roles without access title or table when no rolesWithoutAccess are present", () => {
274+
mockUseAuth.mockReturnValue({
275+
isSigningIn: false,
276+
selectedRole: {
277+
role_id: "1"
278+
},
279+
rolesWithAccess: [
280+
{
281+
role_id: "2",
282+
role_name: "Pharmacist",
283+
org_code: "ABC",
284+
org_name: "Pharmacy Org"
285+
},
286+
{
287+
role_id: "3",
288+
role_name: "Technician",
289+
org_code: "XYZ",
290+
org_name: "Tech Org"
291+
},
292+
{
293+
role_id: "1", // this one should be filtered out
294+
role_name: "Admin",
295+
org_code: "ZZZ",
296+
org_name: "Same Org"
297+
}
298+
],
299+
rolesWithoutAccess: [],
300+
error: null,
301+
hasSingleRoleAccess: jest.fn().mockReturnValue(false)
302+
})
303+
render(<MemoryRouter>
304+
<RoleSelectionPage contentText={defaultContentText} />
305+
</MemoryRouter>)
306+
expect(screen.queryByText("View your roles without access to the Prescription Tracker.")).not.toBeInTheDocument()
307+
expect(screen.queryByTestId("roles-without-access-table")).not.toBeInTheDocument()
308+
})
309+
273310
it("renders EpsCard components for roles with access", () => {
274311
mockUseAuth.mockReturnValue({
275312
isSigningIn: false,

0 commit comments

Comments
 (0)