fix: api tests

This commit is contained in:
2026-04-06 11:12:20 +08:00
parent b3ff589aa5
commit 1e7dbea129
+10 -10
View File
@@ -277,7 +277,7 @@ describe('prompt', () => {
const chooseRunner: CommandRunner<TestContext, string> = {
schema: parseCommandSchema('choose'),
run: async function () {
const result = await this.prompt('select <card>', (cmd) => cmd.params[0] as string);
const result = await this.prompt('select <card>', (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 <card>', (cmd) => cmd.params[0] as string);
await this.prompt('select <card>', (card) => card as string);
return 'unexpected success';
} catch (e) {
return (e as Error).message;
@@ -356,7 +356,7 @@ describe('prompt', () => {
const pickRunner: CommandRunner<TestContext, string> = {
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<TestContext, string[]> = {
schema: parseCommandSchema('multi'),
run: async function () {
const first = await this.prompt('first <a>', (cmd) => cmd.params[0] as string);
const second = await this.prompt('second <b>', (cmd) => cmd.params[0] as string);
const first = await this.prompt('first <a>', (a) => a as string);
const second = await this.prompt('second <b>', (b) => b as string);
return [first, second];
},
};
@@ -440,12 +440,12 @@ describe('prompt', () => {
run: async function () {
const result = await this.prompt(
'select <card>',
(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;