Skip to content

Commit

Permalink
chore: fixed test mock values
Browse files Browse the repository at this point in the history
  • Loading branch information
gentlementlegen committed Apr 8, 2024
1 parent a230c4f commit 1585826
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 8,850 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
"@cspell/dict-node": "^4.0.3",
"@cspell/dict-software-terms": "^3.3.18",
"@cspell/dict-typescript": "^3.1.2",
"@jest/globals": "^29.7.0",
"@jest/types": "^29.6.3",
"@jest/globals": "29.7.0",
"@jest/types": "29.6.3",
"@rollup/plugin-commonjs": "25.0.7",
"@rollup/plugin-json": "6.1.0",
"@rollup/plugin-node-resolve": "15.2.3",
Expand Down
2 changes: 1 addition & 1 deletion tests/generate-erc20-permit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe("generateErc20PermitSignature", () => {
eq: jest.fn().mockReturnValue({
select: jest.fn().mockReturnValue({
eq: jest.fn().mockReturnValue({
single: jest.fn().mockReturnValueOnce({ id: 123 }),
single: jest.fn().mockReturnValue({ id: 123 }),
}),
}),
}),
Expand Down
10 changes: 5 additions & 5 deletions tests/generate-erc721-permit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe("generateErc721PermitSignature", () => {
eq: jest.fn().mockReturnValue({
select: jest.fn().mockReturnValue({
eq: jest.fn().mockReturnValue({
single: jest.fn().mockReturnValueOnce({ id: 123 }),
single: jest.fn().mockReturnValue({ id: 123 }),
}),
}),
}),
Expand Down Expand Up @@ -99,18 +99,18 @@ describe("generateErc721PermitSignature", () => {

it("should throw an error if RPC is not defined", async () => {
context.config.evmNetworkId = 123;
await expect(generateErc721PermitSignature("tester", "contribution", context)).rejects.toThrow("No config setup for" + " evmNetworkId: 123");
await expect(generateErc721PermitSignature("tester", "contribution", context)).rejects.toThrow("No config setup for evmNetworkId: 123");
});

it("should throw an error if NFT minter private key is not defined", async () => {
delete process.env.NFT_MINTER_PRIVATE_KEY;
await expect(generateErc721PermitSignature("tester", "contribution", context)).rejects.toThrow("Failed to instantiate" + " wallet");
await expect(generateErc721PermitSignature("tester", "contribution", context)).rejects.toThrow("Failed to instantiate wallet");
expect(context.logger.error).toHaveBeenCalled();
});

it("should throw an error if NFT contract address is not defined", async () => {
delete process.env.NFT_CONTRACT_ADDRESS;
await expect(generateErc721PermitSignature("tester", "contribution", context)).rejects.toThrow("NFT contract address is" + " not defined");
await expect(generateErc721PermitSignature("tester", "contribution", context)).rejects.toThrow("NFT contract address is not defined");
expect(context.logger.error).toHaveBeenCalled();
});

Expand All @@ -122,7 +122,7 @@ describe("generateErc721PermitSignature", () => {

(context.adapters.supabase.user.getUserIdByWallet as jest.Mock).mockReturnValue(null);

await expect(generateErc721PermitSignature("tester", "contribution", context)).rejects.toThrow("No wallet found for" + " user");
await expect(generateErc721PermitSignature("tester", "contribution", context)).rejects.toThrow("No wallet found for user");
expect(context.logger.error).toHaveBeenCalledWith("No wallet found for user");
});
});
1 change: 0 additions & 1 deletion tests/register-wallet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ describe("registerWallet", () => {
});

it("should skip registration when address is null address", async () => {
context.payload.sender;
expect(await registerWallet(context, "0x0000000000000000000000000000000000000000")).toBe(false);
expect(context.logger.error).toHaveBeenCalledWith("Skipping to register a wallet address because user is trying to set their address to null address");
expect(context.adapters.supabase.wallet.upsertWallet).not.toHaveBeenCalled();
Expand Down
Loading

0 comments on commit 1585826

Please sign in to comment.