summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts
diff options
context:
space:
mode:
authorHarold Mciver <[email protected]>2025-07-16 22:40:56 -0400
committerGitHub <[email protected]>2025-07-17 02:40:56 +0000
commit9ab44ea9d675cd9d560e22fba50d057f1764f25c (patch)
tree492c12bd893fe0249545a2b4b16a86b11ca86fd1 /packages/cli/src/ui/hooks/slashCommandProcessor.test.ts
parent01e66bb12392c3e8cd0222dc495c8dc61ebe4fba (diff)
updated `/quit` to use new slash command arch (#4259)
Co-authored-by: Abhi <[email protected]>
Diffstat (limited to 'packages/cli/src/ui/hooks/slashCommandProcessor.test.ts')
-rw-r--r--packages/cli/src/ui/hooks/slashCommandProcessor.test.ts56
1 files changed, 1 insertions, 55 deletions
diff --git a/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts b/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts
index 71c18dd7..38d17fc9 100644
--- a/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts
+++ b/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts
@@ -54,16 +54,7 @@ vi.mock('../../utils/version.js', () => ({
}));
import { act, renderHook } from '@testing-library/react';
-import {
- vi,
- describe,
- it,
- expect,
- beforeEach,
- afterEach,
- beforeAll,
- Mock,
-} from 'vitest';
+import { vi, describe, it, expect, beforeEach, beforeAll, Mock } from 'vitest';
import open from 'open';
import { useSlashCommandProcessor } from './slashCommandProcessor.js';
import { SlashCommandProcessorResult } from '../types.js';
@@ -203,8 +194,6 @@ describe('useSlashCommandProcessor', () => {
);
};
- const getProcessor = () => getProcessorHook().result.current;
-
describe('New command registry', () => {
let ActualCommandService: typeof CommandService;
@@ -451,47 +440,4 @@ describe('useSlashCommandProcessor', () => {
);
});
});
-
- describe('/quit and /exit commands', () => {
- beforeEach(() => {
- vi.useFakeTimers();
- });
-
- afterEach(() => {
- vi.useRealTimers();
- });
-
- it.each([['/quit'], ['/exit']])(
- 'should handle %s, set quitting messages, and exit the process',
- async (command) => {
- const { handleSlashCommand } = getProcessor();
- const mockDate = new Date('2025-01-01T01:02:03.000Z');
- vi.setSystemTime(mockDate);
-
- await act(async () => {
- handleSlashCommand(command);
- });
-
- expect(mockAddItem).not.toHaveBeenCalled();
- expect(mockSetQuittingMessages).toHaveBeenCalledWith([
- {
- type: 'user',
- text: command,
- id: expect.any(Number),
- },
- {
- type: 'quit',
- duration: '1h 2m 3s',
- id: expect.any(Number),
- },
- ]);
-
- // Fast-forward timers to trigger process.exit
- await act(async () => {
- vi.advanceTimersByTime(100);
- });
- expect(mockProcessExit).toHaveBeenCalledWith(0);
- },
- );
- });
});