summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts
diff options
context:
space:
mode:
authorAbhi <[email protected]>2025-06-11 16:40:31 -0400
committerGitHub <[email protected]>2025-06-11 16:40:31 -0400
commit7a72d255d8effec1396170306cc6be57f598a6d8 (patch)
treeeab86a4d4d5f145a033eed06d16dedeba7b23a37 /packages/cli/src/ui/hooks/slashCommandProcessor.test.ts
parent4160d904da8328eb7168b5b652d4c0f17682546c (diff)
feat: Add exit UI w/ stats (#924)
Diffstat (limited to 'packages/cli/src/ui/hooks/slashCommandProcessor.test.ts')
-rw-r--r--packages/cli/src/ui/hooks/slashCommandProcessor.test.ts37
1 files changed, 37 insertions, 0 deletions
diff --git a/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts b/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts
index f16d3239..0c12d855 100644
--- a/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts
+++ b/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts
@@ -396,6 +396,43 @@ Add any other context about the problem here.
});
});
+ describe('/quit and /exit commands', () => {
+ beforeEach(() => {
+ vi.useFakeTimers();
+ });
+
+ afterEach(() => {
+ vi.useRealTimers();
+ });
+
+ it.each([['/quit'], ['/exit']])(
+ 'should handle %s, add a quit message, 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).toHaveBeenCalledTimes(2);
+ expect(mockAddItem).toHaveBeenNthCalledWith(
+ 2,
+ expect.objectContaining({
+ type: MessageType.QUIT,
+ duration: '1h 2m 3s',
+ }),
+ expect.any(Number),
+ );
+
+ // Fast-forward timers to trigger process.exit
+ vi.advanceTimersByTime(100);
+ expect(mockProcessExit).toHaveBeenCalledWith(0);
+ },
+ );
+ });
+
describe('Unknown command', () => {
it('should show an error and return true for a general unknown command', async () => {
const { handleSlashCommand } = getProcessor();