Skip to content

Commit

Permalink
chore: tests for permit generation
Browse files Browse the repository at this point in the history
  • Loading branch information
gentlementlegen committed Apr 21, 2024
1 parent 6d2ff7b commit 4b2fb40
Show file tree
Hide file tree
Showing 9 changed files with 370 additions and 44 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@octokit/rest": "20.1.0",
"@sinclair/typebox": "0.32.20",
"@supabase/supabase-js": "2.42.0",
"@ubiquibot/permit-generation": "1.2.1",
"@ubiquibot/permit-generation": "1.2.2",
"commander": "12.0.0",
"decimal.js": "10.4.3",
"dotenv": "16.4.5",
Expand Down
2 changes: 1 addition & 1 deletion src/parser/command-line.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if (process.env.NODE_ENV === "test") {
process.argv.push("-n");
process.argv.push("100");
process.argv.push("-e");
process.argv.push("privateKey");
process.argv.push(`${process.env.EVM_PRIVATE_ENCRYPTED}`);
}

const program = new Command()
Expand Down
8 changes: 2 additions & 6 deletions src/parser/permit-generation-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,14 @@ export class PermitGenerationModule implements Module {
const eventName = context.eventName as SupportedEvents;
const octokit = getOctokitInstance();
const logger = {
debug(message: unknown, optionalParams: unknown) {
console.log(message, optionalParams);
},
debug() {},
error(message: unknown, optionalParams: unknown) {
console.error(message, optionalParams);
},
fatal(message: unknown, optionalParams: unknown) {
console.error(message, optionalParams);
},
info(message: unknown, optionalParams: unknown) {
console.log(message, optionalParams);
},
info() {},
warn(message: unknown, optionalParams: unknown) {
console.warn(message, optionalParams);
},
Expand Down
6 changes: 3 additions & 3 deletions tests/__mocks__/db-seed.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,17 @@
{
"id": 1,
"userId": 41552663,
"address": "0x0000000000000000000000000000000000000001"
"address": "0x4D0704f400D57Ba93eEa88765C3FcDBD826dCFc4"
},
{
"id": 2,
"userId": 4975670,
"address": "0x0000000000000000000000000000000000000002"
"address": "0x4D0704f400D57Ba93eEa88765C3FcDBD826dCFc4"
},
{
"id": 3,
"userId": 88761781,
"address": "0x0000000000000000000000000000000000000003"
"address": "0x4D0704f400D57Ba93eEa88765C3FcDBD826dCFc4"
}
]
}
24 changes: 0 additions & 24 deletions tests/__mocks__/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,28 +46,4 @@ export const handlers = [
}
return HttpResponse.json(user);
}),
http.get(`${process.env.SUPABASE_URL}/rest/v1/users`, ({ request }) => {
const url = new URL(request.url);
const select = url.searchParams.get("select");
const userId = url.searchParams.get("id");
if (!select || !userId || !select?.includes("wallets")) {
return HttpResponse.json("Wrong params.", { status: 400 });
}
const id = Number(userId.split(".")[1]);
const wallet = db.wallets.findFirst({
where: {
userId: {
equals: id,
},
},
});
if (!wallet) {
return HttpResponse.json("Wallet was not found", { status: 404 });
}
return HttpResponse.json([
{
wallets: wallet,
},
]);
}),
];
Loading

0 comments on commit 4b2fb40

Please sign in to comment.