diff --git a/__tests__/config.test.ts b/__tests__/config.test.ts index a6d668cc..c9e9617b 100644 --- a/__tests__/config.test.ts +++ b/__tests__/config.test.ts @@ -1,9 +1,10 @@ -import { expect, test, vi } from "vitest" +import { expect, test } from "vitest" import goConfig from "@/lib/config/config" import MissingConfigurationError from "@/lib/config/errors/MissingConfigurationError" test("That an error is thrown if we ask for unknown config", async () => { + // @ts-ignore expect(() => goConfig("unknown.thingy")).toThrowError(MissingConfigurationError) }) diff --git a/__tests__/refresh-token.test.ts b/__tests__/refresh-token.test.ts index 7dd31ce4..b1068679 100644 --- a/__tests__/refresh-token.test.ts +++ b/__tests__/refresh-token.test.ts @@ -4,6 +4,7 @@ import { IronSession, getIronSession } from "iron-session" import { testApiHandler } from "next-test-api-route-handler" import { afterAll, beforeAll, beforeEach, expect, test, vi } from "vitest" +// @ts-ignore import * as tokenRefreshHandler from "@/app/auth/token/refresh/route" import { TSessionData, accessTokenShouldBeRefreshed } from "@/lib/session/session" @@ -24,6 +25,7 @@ afterAll(() => { }) beforeEach(() => { + // @ts-ignore getIronSession.mockResolvedValue({ isLoggedIn: true, }) @@ -41,6 +43,7 @@ const sessionThatShouldBeRefreshed = () => ({ test("That the refresh endpoint redirects to the frontpage if there is no active session", async () => { // Simulate an anonymous session. + // @ts-ignore getIronSession.mockResolvedValue({ isLoggedIn: false, }) @@ -57,6 +60,7 @@ test("That the refresh endpoint redirects to the frontpage if there is no active test("That the refresh endpoint redirects to the given endpoint after refreshing token", async () => { // This is an authorized session that should be refreshed. + // @ts-ignore getIronSession.mockResolvedValue(sessionThatShouldBeRefreshed()) await testApiHandler({ @@ -69,6 +73,7 @@ test("That the refresh endpoint redirects to the given endpoint after refreshing }) // This is an authorized session that should NOT be refreshed. + // @ts-ignore getIronSession.mockResolvedValue({ isLoggedIn: true, expires: add(new Date(), { seconds: 300 }), diff --git a/__tests__/search.test.ts b/__tests__/search.test.ts index b6d52d41..bec98730 100644 --- a/__tests__/search.test.ts +++ b/__tests__/search.test.ts @@ -32,6 +32,7 @@ export const facets = { } as const beforeEach(() => { + // @ts-ignore ;(goConfig as jest.Mock).mockImplementation((key: string) => { if (key === "search.item.limit") { return 9 // Mocked return value for "search.item.limit" @@ -49,6 +50,7 @@ beforeEach(() => { describe("Facet functionality", () => { it("getMachineNames should return all the facet machine names", () => { + // @ts-ignore goConfig.mockReturnValue(facets) const machineNames = getFacetMachineNames() expect(machineNames).toStrictEqual([ @@ -109,6 +111,7 @@ describe("Facet functionality", () => { }) it("getFacetTranslation should give a translated facet when given a facet machine name", () => { + // @ts-ignore const translation = getFacetTranslation("LIX") expect(translation).toBe("Lix") }) diff --git a/__tests__/url.test.ts b/__tests__/url.test.ts index c12c5ef8..eb160586 100644 --- a/__tests__/url.test.ts +++ b/__tests__/url.test.ts @@ -1,16 +1,16 @@ -import { expect, test, vi } from "vitest" +import { expect, test } from "vitest" import { resolveUrl } from "../lib/helpers/helper.routes" test("That resolveUrl can return a work url", async () => { - const workUrl = resolveUrl({ type: "work", routeParams: { id: 123 } }) + const workUrl = resolveUrl({ type: "work", routeParams: { wid: 123 } }) expect(workUrl).toBe("/work/123") }) test("That resolveUrl can return a work url with a manifestation type", async () => { const workUrl = resolveUrl({ type: "work", - routeParams: { id: 123 }, + routeParams: { wid: 123 }, queryParams: { audio: "true" }, }) expect(workUrl).toBe("/work/123?audio=true")