From 59a9e351416d9796784e62ace75a0581cb889a54 Mon Sep 17 00:00:00 2001 From: Erdi Maden Date: Mon, 20 May 2024 14:02:04 -0500 Subject: [PATCH] Updating Coinbase Class tests --- src/coinbase/tests/coinbase_test.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/coinbase/tests/coinbase_test.ts b/src/coinbase/tests/coinbase_test.ts index 9be5428e..f0fdf8a7 100644 --- a/src/coinbase/tests/coinbase_test.ts +++ b/src/coinbase/tests/coinbase_test.ts @@ -67,20 +67,21 @@ describe("Coinbase tests", () => { const faucetTransaction = await wallet?.faucet(); expect(faucetTransaction.getTransactionHash()).toBe("0xdeadbeef"); expect(addressesApiMock.requestFaucetFunds).toHaveBeenCalledWith( - wallet.getId(), - wallet.defaultAddress()?.getId(), + defaultAddress.getWalletId(), + defaultAddress?.getId(), ); expect(addressesApiMock.requestFaucetFunds).toHaveBeenCalledTimes(1); }); }); it("should raise an error if the user is not found", async () => { - jest.mock("../../client/api", () => ({ - UsersApiFactory: jest.fn().mockReturnValue({ - me: jest.fn().mockRejectedValue(new APIError("")), - }), - })); + Coinbase.apiClients.user = { + ...usersApiMock, + getCurrentUser: jest.fn().mockRejectedValue(new APIError("User not found")), + }; const cbInstance = Coinbase.configureFromJson(`${PATH_PREFIX}/coinbase_cloud_api_key.json`); await expect(cbInstance.getDefaultUser()).rejects.toThrow(APIError); + expect(usersApiMock.getCurrentUser).toHaveBeenCalledWith(); + expect(usersApiMock.getCurrentUser).toHaveBeenCalledTimes(1); }); });