From 024b92bd9cb9ef1f18db81282dac6fdb6e246c5c Mon Sep 17 00:00:00 2001 From: Ryan Goree Date: Thu, 17 Oct 2024 10:56:29 -0500 Subject: [PATCH] Update test types for vitest v2 --- .../clide-js/test/units/core/resolve.test.ts | 6 ++-- .../clide-js/test/utils/command-modules.ts | 2 +- .../src/command-menu.test.ts | 28 +++++++++---------- yarn.lock | 9 ------ 4 files changed, 18 insertions(+), 27 deletions(-) diff --git a/packages/clide-js/test/units/core/resolve.test.ts b/packages/clide-js/test/units/core/resolve.test.ts index 7bdb094..99d6673 100644 --- a/packages/clide-js/test/units/core/resolve.test.ts +++ b/packages/clide-js/test/units/core/resolve.test.ts @@ -54,7 +54,7 @@ describe('resolve', () => { subcommandsDir: 'commands/foo', } as ResolvedCommand); - resolved = await resolved.resolveNext?.(); + resolved = await resolved.resolveNext!(); expect(resolved).toMatchObject({ command: commandModules['commands/foo/bar.js'], @@ -66,7 +66,7 @@ describe('resolve', () => { subcommandsDir: 'commands/foo/bar', } as ResolvedCommand); - resolved = await resolved.resolveNext?.(); + resolved = await resolved.resolveNext!(); expect(resolved).toMatchObject({ command: commandModules['commands/foo/bar/baz.js'], @@ -109,7 +109,7 @@ describe('resolve', () => { subcommandsDir: 'commands/[qux]', } as ResolvedCommand); - resolved = await resolved.resolveNext?.(); + resolved = await resolved.resolveNext!(); expect(resolved).toEqual({ command: commandModules['commands/[qux]/[...quux].js'], diff --git a/packages/clide-js/test/utils/command-modules.ts b/packages/clide-js/test/utils/command-modules.ts index e0c6b54..55b8e06 100644 --- a/packages/clide-js/test/utils/command-modules.ts +++ b/packages/clide-js/test/utils/command-modules.ts @@ -186,7 +186,7 @@ export function mockCommandStringModules( } type MockCommandModule = { - handler: Mock<[state: Readonly]>; + handler: Mock<(state: Readonly) => any>; }; /** diff --git a/packages/clide-plugin-command-menu/src/command-menu.test.ts b/packages/clide-plugin-command-menu/src/command-menu.test.ts index f3ffaa4..6a0fdd5 100644 --- a/packages/clide-plugin-command-menu/src/command-menu.test.ts +++ b/packages/clide-plugin-command-menu/src/command-menu.test.ts @@ -13,21 +13,21 @@ vi.mock('./command-menu-prompt', async (importOriginal) => { const original: any = await importOriginal(); return { ...original, - commandMenuPrompt: vi.fn<[CommandMenuPromptOptions], ResolvedCommand[]>( - ({ commandsDir }): ResolvedCommand[] => [ - { - command: { - handler: vi.fn(({ next, data }) => next(data)), - }, - commandName: 'mock-command', - remainingCommandString: '', - commandPath: `${commandsDir}/mock-command`, - commandTokens: ['mock-command'], - subcommandsDir: `${commandsDir}/mock-command`, - params: {}, + commandMenuPrompt: vi.fn< + (options: CommandMenuPromptOptions) => ResolvedCommand[] + >(({ commandsDir }): ResolvedCommand[] => [ + { + command: { + handler: vi.fn(({ next, data }) => next(data)), }, - ], - ), + commandName: 'mock-command', + remainingCommandString: '', + commandPath: `${commandsDir}/mock-command`, + commandTokens: ['mock-command'], + subcommandsDir: `${commandsDir}/mock-command`, + params: {}, + }, + ]), }; }); diff --git a/yarn.lock b/yarn.lock index 6c19cdf..cfd7c88 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1159,15 +1159,6 @@ ci-info@^3.7.0: resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-3.9.0.tgz#4279a62028a7b1f262f3473fc9605f5e218c59b4" integrity sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ== -clide-js@^0.2.2: - version "0.2.2" - resolved "https://registry.yarnpkg.com/clide-js/-/clide-js-0.2.2.tgz#6f87cff52f7f24efaaa1fa6c3a5d24f840d2e833" - integrity sha512-doO/LiXmkcwogkoJddNZQct1vH5i8MGH44LNVWcFnUBeA5xHl45h5kSjZkosT++Z867ryeNRB9xA+lnKgbzQpQ== - dependencies: - cliui "^8.0.1" - prompts "^2.4.2" - yargs-parser "^21.1.1" - cliui@^8.0.1: version "8.0.1" resolved "https://registry.yarnpkg.com/cliui/-/cliui-8.0.1.tgz#0c04b075db02cbfe60dc8e6cf2f5486b1a3608aa"