Files
qwen-code/packages/cli/src/ui/commands/helpCommand.test.ts
Pyush Sinha e506b40c27 fix: /help remove flickering and respect clear shortcut (ctr+l) (#3611)
Co-authored-by: Jacob Richman <jacob314@gmail.com>
Co-authored-by: Allen Hutchison <adh@google.com>
2025-08-04 16:53:50 +00:00

53 lines
1.4 KiB
TypeScript

/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import { helpCommand } from './helpCommand.js';
import { type CommandContext } from './types.js';
import { createMockCommandContext } from '../../test-utils/mockCommandContext.js';
import { MessageType } from '../types.js';
import { CommandKind } from './types.js';
describe('helpCommand', () => {
let mockContext: CommandContext;
const originalEnv = { ...process.env };
beforeEach(() => {
mockContext = createMockCommandContext({
ui: {
addItem: vi.fn(),
},
} as unknown as CommandContext);
});
afterEach(() => {
process.env = { ...originalEnv };
vi.clearAllMocks();
});
it('should add a help message to the UI history', async () => {
if (!helpCommand.action) {
throw new Error('Help command has no action');
}
await helpCommand.action(mockContext, '');
expect(mockContext.ui.addItem).toHaveBeenCalledWith(
expect.objectContaining({
type: MessageType.HELP,
timestamp: expect.any(Date),
}),
expect.any(Number),
);
});
it('should have the correct command properties', () => {
expect(helpCommand.name).toBe('help');
expect(helpCommand.kind).toBe(CommandKind.BUILT_IN);
expect(helpCommand.description).toBe('for help on gemini-cli');
});
});