|
| 1 | +jest.mock("ioredis"); |
| 2 | +jest.mock("../../../src/utils/logger"); |
| 3 | +jest.mock('../../../src/middleware/authentication.middleware'); |
| 4 | +jest.mock('../../../src/middleware/company.authentication.middleware'); |
| 5 | +jest.mock('../../../src/utils/application.data'); |
| 6 | +jest.mock('../../../src/middleware/navigation/update/has.presenter.middleware'); |
| 7 | +jest.mock('../../../src/middleware/service.availability.middleware'); |
| 8 | +jest.mock('../../../src/utils/feature.flag'); |
| 9 | + |
| 10 | +import mockCsrfProtectionMiddleware from "../../__mocks__/csrfProtectionMiddleware.mock"; |
| 11 | +import { NextFunction, Request, Response } from "express"; |
| 12 | +import { beforeEach, expect, jest, test, describe } from "@jest/globals"; |
| 13 | +import request from "supertest"; |
| 14 | + |
| 15 | +import * as config from "../../../src/config"; |
| 16 | +import app from "../../../src/app"; |
| 17 | +import { RELEVANT_PERIOD_SUBMIT_YEAR_BY_PAPER_TITLE } from "../../__mocks__/text.mock"; |
| 18 | +import { APPLICATION_DATA_MOCK } from "../../__mocks__/session.mock"; |
| 19 | +import { getApplicationData } from "../../../src/utils/application.data"; |
| 20 | +import { authentication } from "../../../src/middleware/authentication.middleware"; |
| 21 | +import { companyAuthentication } from "../../../src/middleware/company.authentication.middleware"; |
| 22 | +import { hasUpdatePresenter } from "../../../src/middleware/navigation/update/has.presenter.middleware"; |
| 23 | +import { serviceAvailabilityMiddleware } from "../../../src/middleware/service.availability.middleware"; |
| 24 | +import { isActiveFeature } from "../../../src/utils/feature.flag"; |
| 25 | + |
| 26 | +mockCsrfProtectionMiddleware.mockClear(); |
| 27 | +const mockHasUpdatePresenter = hasUpdatePresenter as jest.Mock; |
| 28 | +mockHasUpdatePresenter.mockImplementation((req: Request, res: Response, next: NextFunction) => next()); |
| 29 | + |
| 30 | +const mockAuthenticationMiddleware = authentication as jest.Mock; |
| 31 | +mockAuthenticationMiddleware.mockImplementation((req: Request, res: Response, next: NextFunction) => next() ); |
| 32 | + |
| 33 | +const mockCompanyAuthenticationMiddleware = companyAuthentication as jest.Mock; |
| 34 | +mockCompanyAuthenticationMiddleware.mockImplementation((req: Request, res: Response, next: NextFunction) => next()); |
| 35 | + |
| 36 | +const mockServiceAvailabilityMiddleware = serviceAvailabilityMiddleware as jest.Mock; |
| 37 | +mockServiceAvailabilityMiddleware.mockImplementation((req: Request, res: Response, next: NextFunction) => next()); |
| 38 | + |
| 39 | +const mockGetApplicationData = getApplicationData as jest.Mock; |
| 40 | + |
| 41 | +const mockIsActiveFeature = isActiveFeature as jest.Mock; |
| 42 | +mockIsActiveFeature.mockReturnValue(true); |
| 43 | + |
| 44 | +describe("Relevant period submit year by paper controller", () => { |
| 45 | + |
| 46 | + beforeEach(() => { |
| 47 | + jest.clearAllMocks(); |
| 48 | + }); |
| 49 | + describe("GET tests", () => { |
| 50 | + test(`renders the ${config.RELEVANT_PERIOD_SUBMIT_YEAR_BY_PAPER_PAGE} page`, async () => { |
| 51 | + mockGetApplicationData.mockReturnValue({ ...APPLICATION_DATA_MOCK }); |
| 52 | + const resp = await request(app).get(config.RELEVANT_PERIOD_SUBMIT_YEAR_BY_PAPER_URL); |
| 53 | + |
| 54 | + expect(resp.status).toEqual(200); |
| 55 | + expect(resp.text).toContain(RELEVANT_PERIOD_SUBMIT_YEAR_BY_PAPER_TITLE); |
| 56 | + }); |
| 57 | + }); |
| 58 | +}); |
0 commit comments