mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-22 03:51:22 -07:00
Fix /tool and /mcp commands to not write terminal escape codes directly (#10010)
This commit is contained in:
@@ -62,9 +62,11 @@ describe('toolsCommand', () => {
|
||||
await toolsCommand.action(mockContext, '');
|
||||
|
||||
expect(mockContext.ui.addItem).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
text: expect.stringContaining('No tools available'),
|
||||
}),
|
||||
{
|
||||
type: MessageType.TOOLS_LIST,
|
||||
tools: [],
|
||||
showDescriptions: false,
|
||||
},
|
||||
expect.any(Number),
|
||||
);
|
||||
});
|
||||
@@ -81,10 +83,12 @@ 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][0].text;
|
||||
expect(message).not.toContain('Reads files from the local system.');
|
||||
expect(message).toContain('File Reader');
|
||||
expect(message).toContain('Code Editor');
|
||||
const [message] = (mockContext.ui.addItem as vi.Mock).mock.calls[0];
|
||||
expect(message.type).toBe(MessageType.TOOLS_LIST);
|
||||
expect(message.showDescriptions).toBe(false);
|
||||
expect(message.tools).toHaveLength(2);
|
||||
expect(message.tools[0].displayName).toBe('File Reader');
|
||||
expect(message.tools[1].displayName).toBe('Code Editor');
|
||||
});
|
||||
|
||||
it('should list tools with descriptions when "desc" arg is passed', async () => {
|
||||
@@ -99,8 +103,13 @@ 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][0].text;
|
||||
expect(message).toContain('Reads files from the local system.');
|
||||
expect(message).toContain('Edits code files.');
|
||||
const [message] = (mockContext.ui.addItem as vi.Mock).mock.calls[0];
|
||||
expect(message.type).toBe(MessageType.TOOLS_LIST);
|
||||
expect(message.showDescriptions).toBe(true);
|
||||
expect(message.tools).toHaveLength(2);
|
||||
expect(message.tools[0].description).toBe(
|
||||
'Reads files from the local system.',
|
||||
);
|
||||
expect(message.tools[1].description).toBe('Edits code files.');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user