mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-14 23:31:13 -07:00
fix(cli): enable typechecking for ui/commands tests (#11413)
This commit is contained in:
@@ -9,7 +9,7 @@ import { describe, it, expect } from 'vitest';
|
||||
import { toolsCommand } from './toolsCommand.js';
|
||||
import { createMockCommandContext } from '../../test-utils/mockCommandContext.js';
|
||||
import { MessageType } from '../types.js';
|
||||
import type { Tool } from '@google/gemini-cli-core';
|
||||
import type { ToolBuilder, ToolResult } from '@google/gemini-cli-core';
|
||||
|
||||
// Mock tools for testing
|
||||
const mockTools = [
|
||||
@@ -25,7 +25,7 @@ const mockTools = [
|
||||
description: 'Edits code files.',
|
||||
schema: {},
|
||||
},
|
||||
] as Tool[];
|
||||
] as unknown as Array<ToolBuilder<object, ToolResult>>;
|
||||
|
||||
describe('toolsCommand', () => {
|
||||
it('should display an error if the tool registry is unavailable', async () => {
|
||||
@@ -53,7 +53,9 @@ describe('toolsCommand', () => {
|
||||
const mockContext = createMockCommandContext({
|
||||
services: {
|
||||
config: {
|
||||
getToolRegistry: () => ({ getAllTools: () => [] as Tool[] }),
|
||||
getToolRegistry: () => ({
|
||||
getAllTools: () => [] as Array<ToolBuilder<object, ToolResult>>,
|
||||
}),
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -83,7 +85,8 @@ describe('toolsCommand', () => {
|
||||
if (!toolsCommand.action) throw new Error('Action not defined');
|
||||
await toolsCommand.action(mockContext, '');
|
||||
|
||||
const [message] = (mockContext.ui.addItem as vi.Mock).mock.calls[0];
|
||||
const [message] = (mockContext.ui.addItem as ReturnType<typeof vi.fn>).mock
|
||||
.calls[0];
|
||||
expect(message.type).toBe(MessageType.TOOLS_LIST);
|
||||
expect(message.showDescriptions).toBe(false);
|
||||
expect(message.tools).toHaveLength(2);
|
||||
@@ -103,7 +106,8 @@ describe('toolsCommand', () => {
|
||||
if (!toolsCommand.action) throw new Error('Action not defined');
|
||||
await toolsCommand.action(mockContext, 'desc');
|
||||
|
||||
const [message] = (mockContext.ui.addItem as vi.Mock).mock.calls[0];
|
||||
const [message] = (mockContext.ui.addItem as ReturnType<typeof vi.fn>).mock
|
||||
.calls[0];
|
||||
expect(message.type).toBe(MessageType.TOOLS_LIST);
|
||||
expect(message.showDescriptions).toBe(true);
|
||||
expect(message.tools).toHaveLength(2);
|
||||
|
||||
Reference in New Issue
Block a user