From 4bf08d20e966dc892d1e7581b33411b9e3e1d1ff Mon Sep 17 00:00:00 2001 From: whilefoo Date: Wed, 25 Oct 2023 11:53:32 +0200 Subject: [PATCH] fix: types --- src/adapters/supabase/helpers/tables/wallet.test.ts | 13 +++++++------ src/handlers/pricing/pricing-label.ts | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/adapters/supabase/helpers/tables/wallet.test.ts b/src/adapters/supabase/helpers/tables/wallet.test.ts index e53e7471d..2464e9ed9 100644 --- a/src/adapters/supabase/helpers/tables/wallet.test.ts +++ b/src/adapters/supabase/helpers/tables/wallet.test.ts @@ -1,20 +1,21 @@ import dotenv from "dotenv"; dotenv.config(); -import { Context } from "probot"; +import { Context as ProbotContext } from "probot"; import { createAdapters } from "../../.."; import { loadConfig } from "../../../../bindings/config"; -import { User } from "../../../../types"; +import { Context, User } from "../../../../types"; const SUPABASE_URL = process.env.SUPABASE_URL; if (!SUPABASE_URL) throw new Error("SUPABASE_URL is not defined"); const SUPABASE_KEY = process.env.SUPABASE_KEY; if (!SUPABASE_KEY) throw new Error("SUPABASE_KEY is not defined"); -const mockContext = { supabase: { url: SUPABASE_URL, key: SUPABASE_KEY } } as unknown as Context; +const mockContext = { supabase: { url: SUPABASE_URL, key: SUPABASE_KEY } } as unknown as ProbotContext; -async function getWalletAddressAndUrlTest(context: Context) { - const botConfig = await loadConfig(context); - const { wallet } = createAdapters(botConfig).supabase; +async function getWalletAddressAndUrlTest(eventContext: ProbotContext) { + const botConfig = await loadConfig(eventContext); + const context: Context = { event: eventContext, config: botConfig }; + const { wallet } = createAdapters(context).supabase; const userId = 4975670 as User["id"]; const results = [] as unknown[]; try { diff --git a/src/handlers/pricing/pricing-label.ts b/src/handlers/pricing/pricing-label.ts index a8ce46c6e..1c6e9594a 100644 --- a/src/handlers/pricing/pricing-label.ts +++ b/src/handlers/pricing/pricing-label.ts @@ -48,8 +48,8 @@ export async function pricingLabel(context: Context) { const minTimeLabel = sortLabelsByValue(recognizedTimeLabels).shift(); const minPriorityLabel = sortLabelsByValue(recognizedPriorityLabels).shift(); - if (!minTimeLabel) return logger.warn(`No time label to calculate price`); - if (!minPriorityLabel) return logger.warn("No priority label to calculate price"); + if (!minTimeLabel) throw logger.warn(`No time label to calculate price`); + if (!minPriorityLabel) throw logger.warn("No priority label to calculate price"); const targetPriceLabel = setPrice(context, minTimeLabel, minPriorityLabel);