From f0c257d7270d8e7f0ec9a9c962973ab3c93c9fda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dafydd=20Ll=C5=B7r=20Pearson?= Date: Mon, 26 Aug 2024 13:23:16 +0100 Subject: [PATCH] test: Handle default export in `swr` (#3559) --- .../FindProperty/Public/Public.test.tsx | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/editor.planx.uk/src/@planx/components/FindProperty/Public/Public.test.tsx b/editor.planx.uk/src/@planx/components/FindProperty/Public/Public.test.tsx index 138bca2573..fd486ccf56 100644 --- a/editor.planx.uk/src/@planx/components/FindProperty/Public/Public.test.tsx +++ b/editor.planx.uk/src/@planx/components/FindProperty/Public/Public.test.tsx @@ -123,15 +123,17 @@ const proposedAddressProps = { "findProperty.action": "Proposed a new address", }; -// vi.spyOn(SWR, "default").mockImplementation((url: any) => { -// return { -// data: url()?.startsWith("https://www.planning.data.gov.uk") -// ? localAuthorityMock -// : null, -// } as any; -// }); - -describe.skip("render states", () => { +vi.mock("swr", () => ({ + default: vi.fn((url: any) => { + return { + data: url()?.startsWith("https://www.planning.data.gov.uk") + ? localAuthorityMock + : null, + }; + }), +})); + +describe("render states", () => { it("renders correctly and defaults to the address autocomplete page", async () => { const handleSubmit = vi.fn(); @@ -299,7 +301,7 @@ describe.skip("render states", () => { }); }); -describe.skip("picking an OS address", () => { +describe("picking an OS address", () => { it("displays an error if you submit an invalid postcode", async () => { const handleSubmit = vi.fn(); @@ -384,7 +386,7 @@ describe.skip("picking an OS address", () => { }); }); -describe.skip("plotting a new address that does not have a uprn yet", () => { +describe("plotting a new address that does not have a uprn yet", () => { it("displays an error if you haven't entered a site address", async () => { const handleSubmit = vi.fn();