Skip to content

Commit f526ec4

Browse files
committed
test: add parameterized tests for exit/quit variants
1 parent 3762958 commit f526ec4

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

packages/cli/src/ui/hooks/slashCommandProcessor.test.tsx

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -574,24 +574,30 @@ describe('useSlashCommandProcessor', () => {
574574
expect(mockSetQuittingMessages).toHaveBeenCalledWith(['bye']);
575575
});
576576

577-
it('should handle "exit" command without a slash', async () => {
578-
const quitAction = vi
579-
.fn()
580-
.mockResolvedValue({ type: 'quit', messages: ['bye'] });
581-
const command = createTestCommand({
582-
name: 'exit',
583-
action: quitAction,
584-
});
585-
const result = await setupProcessorHook([command]);
577+
it.each(['exit', 'quit', 'EXIT', 'Quit'])(
578+
'should handle "%s" command without a slash',
579+
async (cmd) => {
580+
const quitAction = vi
581+
.fn()
582+
.mockResolvedValue({ type: 'quit', messages: ['bye'] });
583+
const command = createTestCommand({
584+
name: 'quit',
585+
altNames: ['exit'],
586+
action: quitAction,
587+
});
588+
const result = await setupProcessorHook([command]);
586589

587-
await waitFor(() => expect(result.current.slashCommands).toHaveLength(1));
590+
await waitFor(() =>
591+
expect(result.current.slashCommands).toHaveLength(1),
592+
);
588593

589-
await act(async () => {
590-
await result.current.handleSlashCommand('exit');
591-
});
594+
await act(async () => {
595+
await result.current.handleSlashCommand(cmd);
596+
});
592597

593-
expect(quitAction).toHaveBeenCalled();
594-
});
598+
expect(quitAction).toHaveBeenCalled();
599+
},
600+
);
595601
it('should handle "submit_prompt" action returned from a file-based command', async () => {
596602
const fileCommand = createTestCommand(
597603
{

0 commit comments

Comments
 (0)