From ccad4e93a4256f0e8b0019cc073b7e5b209419a9 Mon Sep 17 00:00:00 2001 From: astrovm <5521045+astrovm@users.noreply.github.com> Date: Sat, 28 Nov 2026 21:49:59 -0300 Subject: [PATCH] test(withdraw): check the parse context by behavior, not source text --- tests/bot-commands.flows.test.ts | 11 ++++++++++- tests/withdraw.sol.parsing.test.ts | 15 --------------- 2 files changed, 10 insertions(+), 16 deletions(-) delete mode 100644 tests/withdraw.sol.parsing.test.ts diff --git a/tests/bot-commands.flows.test.ts b/tests/bot-commands.flows.test.ts index 1192cdcf..1ff91c27 100644 --- a/tests/bot-commands.flows.test.ts +++ b/tests/bot-commands.flows.test.ts @@ -32,6 +32,7 @@ let warnSpy: ReturnType; let errorSpy: ReturnType; let savedTokenManager: any; let parseResult: any; +let parseAmount: ReturnType; beforeEach(async () => { USER += 1; @@ -52,8 +53,9 @@ beforeEach(async () => { tokenWasSpecified: true, }, }; + parseAmount = mock(async () => parseResult); botModule.__test_setTokenManager({ - parseAmount: async () => parseResult, + parseAmount, resolveSwapToken: async (mint: string) => ({ token_mint: mint, token_ticker: "BONK", @@ -137,6 +139,13 @@ describe("/withdraw", () => { await withdraw(`${recipient} 2 SOL`); + // SOL is not a game token, so the amount is read like a tip, not a bet. + expect(parseAmount.mock.calls[0]).toEqual([ + ["/withdraw", recipient, "2", "SOL"], + 2, + USER, + "tip", + ]); expect((transferSol.mock.calls[0] as any[])[2]).toBe(2 * LAMPORTS); expect(lastText()).toContain("✅ Withdrawal of 2 SOL sent"); }); diff --git a/tests/withdraw.sol.parsing.test.ts b/tests/withdraw.sol.parsing.test.ts deleted file mode 100644 index 096b1a67..00000000 --- a/tests/withdraw.sol.parsing.test.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { describe, test, expect } from "bun:test"; -import * as fs from "fs"; -import * as path from "path"; - -describe("/withdraw command", () => { - test("parses SOL in non-game context (uses 'tip')", () => { - const botPath = path.join(process.cwd(), "src", "bot.ts"); - const content = fs.readFileSync(botPath, "utf-8"); - - // Ensure the withdraw handler uses the SOL-friendly context - const needle = 'const parsed = await tokenManager.parseAmount(args, 2, ctx.chat?.id, "tip")'; - - expect(content.replace(/\s+/g, " ")).toContain(needle); - }); -});