From 69e47aeaf3f44865737b862c27989a38f162c708 Mon Sep 17 00:00:00 2001 From: "Justin R. Evans" Date: Tue, 26 Nov 2024 06:21:49 -0500 Subject: [PATCH] fix: fix tests --- .../src/background/approvals/service.test.ts | 31 ++++++------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/apps/extension/src/background/approvals/service.test.ts b/apps/extension/src/background/approvals/service.test.ts index 437020d55..a3435a05c 100644 --- a/apps/extension/src/background/approvals/service.test.ts +++ b/apps/extension/src/background/approvals/service.test.ts @@ -263,13 +263,12 @@ describe("approvals service", () => { it("should approve connection if it's not already approved", async () => { const interfaceOrigin = "origin"; const tabId = 1; - const chainId = "chain-id"; jest.spyOn(service, "isConnectionApproved").mockResolvedValue(false); jest.spyOn(service as any, "launchApprovalPopup"); service["resolverMap"] = {}; - const promise = service.approveConnection(interfaceOrigin, chainId); + const promise = service.approveConnection(interfaceOrigin); await new Promise((r) => setTimeout(() => { r(); @@ -283,18 +282,17 @@ describe("approvals service", () => { ); expect(service.isConnectionApproved).toHaveBeenCalledWith( interfaceOrigin, - chainId + undefined ); await expect(promise).resolves.toBeDefined(); }); it("should not approve connection if it was already approved", async () => { const interfaceOrigin = "origin"; - const chainId = "chain-id"; jest.spyOn(service, "isConnectionApproved").mockResolvedValue(true); await expect( - service.approveConnection(interfaceOrigin, chainId) + service.approveConnection(interfaceOrigin) ).resolves.toBeUndefined(); }); }); @@ -355,14 +353,13 @@ describe("approvals service", () => { describe("approveDisconnection", () => { it("should approve disconnection if there is a connection already approved", async () => { const interfaceOrigin = "origin"; - const chainId = "chain-id"; const tabId = 1; jest.spyOn(service, "isConnectionApproved").mockResolvedValue(true); jest.spyOn(service as any, "launchApprovalPopup"); service["resolverMap"] = {}; - const promise = service.approveDisconnection(interfaceOrigin, chainId); + const promise = service.approveDisconnection(interfaceOrigin); await new Promise((r) => setTimeout(() => { r(); @@ -376,18 +373,17 @@ describe("approvals service", () => { ); expect(service.isConnectionApproved).toHaveBeenCalledWith( interfaceOrigin, - chainId + undefined ); await expect(promise).resolves.toBeDefined(); }); it("should not approve disconnection if it is NOT already approved", async () => { const interfaceOrigin = "origin"; - const chainId = "chain-id"; jest.spyOn(service, "isConnectionApproved").mockResolvedValue(false); await expect( - service.approveDisconnection(interfaceOrigin, chainId) + service.approveDisconnection(interfaceOrigin) ).resolves.toBeUndefined(); }); }); @@ -547,36 +543,27 @@ describe("approvals service", () => { describe("isConnectionApproved", () => { it("should return true if origin is approved", async () => { const origin = "origin"; - const chainId = "chain-id"; jest .spyOn(localStorage, "getApprovedOrigins") .mockResolvedValue([origin]); - await expect(service.isConnectionApproved(origin, chainId)).resolves.toBe( - true - ); + await expect(service.isConnectionApproved(origin)).resolves.toBe(true); }); it("should return false if origin is not approved", async () => { const origin = "origin"; - const chainId = "chain-id"; jest.spyOn(localStorage, "getApprovedOrigins").mockResolvedValue([]); - await expect(service.isConnectionApproved(origin, chainId)).resolves.toBe( - false - ); + await expect(service.isConnectionApproved(origin)).resolves.toBe(false); }); it("should return false if there are no origins in store", async () => { const origin = "origin"; - const chainId = "chain-id"; jest .spyOn(localStorage, "getApprovedOrigins") .mockResolvedValue(undefined); - await expect(service.isConnectionApproved(origin, chainId)).resolves.toBe( - false - ); + await expect(service.isConnectionApproved(origin)).resolves.toBe(false); }); }); });