From 1e7dbea1292a402afa06082c9b28bac53a09e90b Mon Sep 17 00:00:00 2001 From: hypercross Date: Mon, 6 Apr 2026 11:12:20 +0800 Subject: [PATCH] fix: api tests --- tests/utils/command-runner.test.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/utils/command-runner.test.ts b/tests/utils/command-runner.test.ts index 28ad5cc..abb1e03 100644 --- a/tests/utils/command-runner.test.ts +++ b/tests/utils/command-runner.test.ts @@ -277,7 +277,7 @@ describe('prompt', () => { const chooseRunner: CommandRunner = { schema: parseCommandSchema('choose'), run: async function () { - const result = await this.prompt('select ', (cmd) => cmd.params[0] as string); + const result = await this.prompt('select ', (card) => card as string); this.context.log.push(`selected ${result}`); return result; }, @@ -317,7 +317,7 @@ describe('prompt', () => { schema: parseCommandSchema('choose'), run: async function () { try { - await this.prompt('select ', (cmd) => cmd.params[0] as string); + await this.prompt('select ', (card) => card as string); return 'unexpected success'; } catch (e) { return (e as Error).message; @@ -356,7 +356,7 @@ describe('prompt', () => { const pickRunner: CommandRunner = { schema: parseCommandSchema('pick'), run: async function () { - const result = await this.prompt(schema, (cmd) => cmd.params[0] as string); + const result = await this.prompt(schema, (item) => item as string); return result; }, }; @@ -393,8 +393,8 @@ describe('prompt', () => { const multiPromptRunner: CommandRunner = { schema: parseCommandSchema('multi'), run: async function () { - const first = await this.prompt('first ', (cmd) => cmd.params[0] as string); - const second = await this.prompt('second ', (cmd) => cmd.params[0] as string); + const first = await this.prompt('first ', (a) => a as string); + const second = await this.prompt('second ', (b) => b as string); return [first, second]; }, }; @@ -440,12 +440,12 @@ describe('prompt', () => { run: async function () { const result = await this.prompt( 'select ', - (cmd) => { - const card = cmd.params[0] as string; - if (!['Ace', 'King', 'Queen'].includes(card)) { - throw `Invalid card: ${card}. Must be Ace, King, or Queen.`; + (card) => { + const cardStr = card as string; + if (!['Ace', 'King', 'Queen'].includes(cardStr)) { + throw `Invalid card: ${cardStr}. Must be Ace, King, or Queen.`; } - return card; + return cardStr; } ); return result;