From a0e333433f53b991472ea6c445d0137d18bc0ad5 Mon Sep 17 00:00:00 2001 From: 0xKurt Date: Tue, 1 Oct 2024 14:27:24 +0200 Subject: [PATCH] fix manager (hopefully) --- .../__tests__/CreateProgramPage.test.tsx | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/packages/round-manager/src/features/program/__tests__/CreateProgramPage.test.tsx b/packages/round-manager/src/features/program/__tests__/CreateProgramPage.test.tsx index 8bea65037..0dd61a49f 100644 --- a/packages/round-manager/src/features/program/__tests__/CreateProgramPage.test.tsx +++ b/packages/round-manager/src/features/program/__tests__/CreateProgramPage.test.tsx @@ -39,18 +39,21 @@ jest.mock("common", () => ({ })); jest.mock("wagmi", () => ({ - useAccount: () => ({ - chainId: 10, - address: "0x0000000000000000000000000000000000000000", - chain: { - id: 10, - }, - }), + useAccount: jest.fn(), })); describe("", () => { beforeEach(() => { - + jest.clearAllMocks(); + + (wagmi.useAccount as jest.Mock).mockReturnValue({ + chainId: 10, + address: "0x0000000000000000000000000000000000000000", + chain: { + id: 10, + name: "Testimism", + }, + } as unknown as ReturnType); }); it("shows program chain tooltip", async () => { @@ -150,16 +153,15 @@ describe("", () => { }); it("displays wrong network when connected to unsupported network", async () => { - jest.spyOn(wagmi, "useAccount").mockImplementation( - () => - ({ - chainId: 9999, - address: "0x0000000000000000000000000000000000000000", - chain: { - id: 9999, - }, - }) as unknown as wagmi.UseAccountReturnType - ); + // Overwriting the mock for this specific test + jest.spyOn(wagmi, "useAccount").mockReturnValue({ + chainId: 9999, + address: "0x0000000000000000000000000000000000000000", + chain: { + id: 9999, + name: "Homer", + }, + } as unknown as ReturnType); renderWithContext();