Skip to content

Commit

Permalink
add test for page
Browse files Browse the repository at this point in the history
  • Loading branch information
HatiDev committed Dec 10, 2024
1 parent 07a91dd commit 72af4d8
Showing 1 changed file with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import request from "supertest";
import { LocalesService } from "@companieshouse/ch-node-utils";
import * as config from "../../../../config/constants";
import enTranslationText from "../../../../../locales/en/translations.json";
import cyTranslationText from "../../../../../locales/cy/translations.json";
import app from "../app";
import {
LIMITED_PARTNERS_URL,
} from "../../../controller/registration/Routing";

describe("Limited Partners Page", () => {
beforeEach(() => {
setLocalesEnabled(false);
});

const setLocalesEnabled = (bool: boolean) => {
jest.spyOn(config, "isLocalesEnabled").mockReturnValue(bool);
LocalesService.getInstance().enabled = bool;
};

it("should load the limited partners page with Welsh text", async () => {
setLocalesEnabled(true);
const res = await request(app).get(LIMITED_PARTNERS_URL + "?lang=cy");

expect(res.status).toBe(200);
expect(res.text).toContain(cyTranslationText.limitedPartnersPage.title);
});

it("should load the limited partners page with English text", async () => {
setLocalesEnabled(true);
const res = await request(app).get(LIMITED_PARTNERS_URL + "?lang=en");

expect(res.status).toBe(200);
expect(res.text).toContain(enTranslationText.limitedPartnersPage.title);
});
});

0 comments on commit 72af4d8

Please sign in to comment.