diff options
| author | christine betts <[email protected]> | 2025-08-08 15:38:30 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-08-08 15:38:30 +0000 |
| commit | 3af4913ef3f00de71744de551a568aa713a3beec (patch) | |
| tree | ca71aae771662435a4c01400a701b48a4c5dbcf3 /packages/cli/src/ui/hooks/slashCommandProcessor.test.ts | |
| parent | 5ec4ea9b4d425269c9e9052503ad85b5caaa976e (diff) | |
[ide-mode] Close all open diffs when the CLI gets closed (#5792)
Diffstat (limited to 'packages/cli/src/ui/hooks/slashCommandProcessor.test.ts')
| -rw-r--r-- | packages/cli/src/ui/hooks/slashCommandProcessor.test.ts | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts b/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts index a37af262..37407689 100644 --- a/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts +++ b/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts @@ -60,6 +60,14 @@ vi.mock('../contexts/SessionContext.js', () => ({ useSessionStats: vi.fn(() => ({ stats: {} })), })); +const { mockRunExitCleanup } = vi.hoisted(() => ({ + mockRunExitCleanup: vi.fn(), +})); + +vi.mock('../../utils/cleanup.js', () => ({ + runExitCleanup: mockRunExitCleanup, +})); + import { act, renderHook, waitFor } from '@testing-library/react'; import { vi, describe, it, expect, beforeEach, type Mock } from 'vitest'; import { useSlashCommandProcessor } from './slashCommandProcessor.js'; @@ -405,6 +413,37 @@ describe('useSlashCommandProcessor', () => { vi.useRealTimers(); } }); + + it('should call runExitCleanup when handling a "quit" action', async () => { + const quitAction = vi + .fn() + .mockResolvedValue({ type: 'quit', messages: [] }); + const command = createTestCommand({ + name: 'exit', + action: quitAction, + }); + const result = setupProcessorHook([command]); + + await waitFor(() => + expect(result.current.slashCommands).toHaveLength(1), + ); + + vi.useFakeTimers(); + + try { + await act(async () => { + await result.current.handleSlashCommand('/exit'); + }); + + await act(async () => { + await vi.advanceTimersByTimeAsync(200); + }); + + expect(mockRunExitCleanup).toHaveBeenCalledTimes(1); + } finally { + vi.useRealTimers(); + } + }); }); it('should handle "submit_prompt" action returned from a file-based command', async () => { |
