Skip to content

Commit 037aa74

Browse files
VIA-171 Remove unnecessary navigation mock from page tests
With the back-link component mocked out useRouter is no longer called during the unit tests
1 parent 4b88f3d commit 037aa74

File tree

8 files changed

+2
-26
lines changed

8 files changed

+2
-26
lines changed

src/app/schedule/page.test.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
import { render, screen } from "@testing-library/react";
22
import Schedule from "./page";
33
import { JSX } from "react";
4+
import { assertBackLinkIsPresent } from "@test-data/test-helpers-back-link";
45

56
jest.mock("@src/app/_components/nhs-frontend/BackLink", () =>
67
jest.fn(() => <div data-testid="back-link"></div>),
78
);
89
jest.mock("@src/services/content-api/gateway/content-reader-service");
9-
jest.mock("next/navigation", () => ({
10-
useRouter: jest.fn(),
11-
}));
1210

1311
describe("Schedule Page", () => {
1412
beforeEach(() => {
@@ -97,7 +95,6 @@ describe("Schedule Page", () => {
9795
});
9896

9997
it("should contain back link", () => {
100-
const backLink = screen.getByTestId("back-link");
101-
expect(backLink).toBeInTheDocument();
98+
assertBackLinkIsPresent(screen);
10299
});
103100
});

src/app/vaccines/6-in-1/page.test.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ import { mockStyledContent } from "@test-data/content-api/data";
66
import { VaccineTypes } from "@src/models/vaccine";
77
import { assertBackLinkIsPresent } from "@test-data/test-helpers-back-link";
88

9-
jest.mock("next/navigation", () => ({
10-
useRouter: jest.fn(),
11-
}));
129
jest.mock("@src/services/content-api/gateway/content-reader-service");
1310
jest.mock("@src/app/_components/vaccine/Vaccine", () => jest.fn(() => <div />));
1411
jest.mock("@src/app/_components/nhs-frontend/BackLink", () =>

src/app/vaccines/covid-19/page.test.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ import { mockStyledContent } from "@test-data/content-api/data";
66
import { VaccineTypes } from "@src/models/vaccine";
77
import { assertBackLinkIsPresent } from "@test-data/test-helpers-back-link";
88

9-
jest.mock("next/navigation", () => ({
10-
useRouter: jest.fn(),
11-
}));
129
jest.mock("@src/services/content-api/gateway/content-reader-service");
1310
jest.mock("@src/app/_components/vaccine/Vaccine", () => jest.fn(() => <div />));
1411
jest.mock("@src/app/_components/nhs-frontend/BackLink", () =>

src/app/vaccines/flu/page.test.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ import { mockStyledContent } from "@test-data/content-api/data";
66
import { VaccineTypes } from "@src/models/vaccine";
77
import { assertBackLinkIsPresent } from "@test-data/test-helpers-back-link";
88

9-
jest.mock("next/navigation", () => ({
10-
useRouter: jest.fn(),
11-
}));
129
jest.mock("@src/services/content-api/gateway/content-reader-service");
1310
jest.mock("@src/app/_components/vaccine/Vaccine");
1411
jest.mock("@src/app/_components/nhs-frontend/BackLink", () =>

src/app/vaccines/menacwy/page.test.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ import { VaccineTypes } from "@src/models/vaccine";
66
import VaccineMenACWY from "@src/app/vaccines/menacwy/page";
77
import { assertBackLinkIsPresent } from "@test-data/test-helpers-back-link";
88

9-
jest.mock("next/navigation", () => ({
10-
useRouter: jest.fn(),
11-
}));
129
jest.mock("@src/services/content-api/gateway/content-reader-service");
1310
jest.mock("@src/app/_components/vaccine/Vaccine");
1411
jest.mock("@src/app/_components/nhs-frontend/BackLink", () =>

src/app/vaccines/pneumococcal/page.test.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ import { VaccineTypes } from "@src/models/vaccine";
66
import VaccinePneumococcal from "@src/app/vaccines/pneumococcal/page";
77
import { assertBackLinkIsPresent } from "@test-data/test-helpers-back-link";
88

9-
jest.mock("next/navigation", () => ({
10-
useRouter: jest.fn(),
11-
}));
129
jest.mock("@src/services/content-api/gateway/content-reader-service");
1310
jest.mock("@src/app/_components/vaccine/Vaccine");
1411
jest.mock("@src/app/_components/nhs-frontend/BackLink", () =>

src/app/vaccines/rsv/page.test.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ import { mockStyledContent } from "@test-data/content-api/data";
66
import { VaccineTypes } from "@src/models/vaccine";
77
import { assertBackLinkIsPresent } from "@test-data/test-helpers-back-link";
88

9-
jest.mock("next/navigation", () => ({
10-
useRouter: jest.fn(),
11-
}));
129
jest.mock("@src/services/content-api/gateway/content-reader-service");
1310
jest.mock("@src/app/_components/vaccine/Vaccine", () => jest.fn(() => <div />));
1411
jest.mock("@src/app/_components/nhs-frontend/BackLink", () =>

src/app/vaccines/shingles/page.test.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ import { VaccineTypes } from "@src/models/vaccine";
66
import VaccineShingles from "@src/app/vaccines/shingles/page";
77
import { assertBackLinkIsPresent } from "@test-data/test-helpers-back-link";
88

9-
jest.mock("next/navigation", () => ({
10-
useRouter: jest.fn(),
11-
}));
129
jest.mock("@src/services/content-api/gateway/content-reader-service");
1310
jest.mock("@src/app/_components/vaccine/Vaccine");
1411
jest.mock("@src/app/_components/nhs-frontend/BackLink", () =>

0 commit comments

Comments
 (0)