Skip to content

Commit

Permalink
Updating Coinbase Class tests
Browse files Browse the repository at this point in the history
  • Loading branch information
erdimaden committed May 20, 2024
1 parent 65880bb commit 59a9e35
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/coinbase/tests/coinbase_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

0 comments on commit 59a9e35

Please sign in to comment.