diff options
| author | Jacob MacDonald <[email protected]> | 2025-06-17 08:44:54 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-06-17 15:44:54 +0000 |
| commit | e59c872b3dea9dee8206f990a761e3bfee3a1194 (patch) | |
| tree | 88ee78b1ba1957dd5c504f577bee0db00078cb43 /packages/cli/src/ui/hooks/slashCommandProcessor.test.ts | |
| parent | c3971754bf4bd5877d7a57c523b981c09d4fa35d (diff) | |
code review followup for compress command (#1097)
Followup to https://github.com/google-gemini/gemini-cli/pull/986
Diffstat (limited to 'packages/cli/src/ui/hooks/slashCommandProcessor.test.ts')
| -rw-r--r-- | packages/cli/src/ui/hooks/slashCommandProcessor.test.ts | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts b/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts index 68dc3ea9..2eec29ca 100644 --- a/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts +++ b/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts @@ -159,8 +159,8 @@ describe('useSlashCommandProcessor', () => { process.env = { ...globalThis.process.env }; }); - const getProcessor = (showToolDescriptions: boolean = false) => { - const { result } = renderHook(() => + const getProcessorHook = (showToolDescriptions: boolean = false) => + renderHook(() => useSlashCommandProcessor( mockConfig, [], @@ -178,8 +178,9 @@ describe('useSlashCommandProcessor', () => { mockSetQuittingMessages, ), ); - return result.current; - }; + + const getProcessor = (showToolDescriptions: boolean = false) => + getProcessorHook(showToolDescriptions).result.current; describe('/memory add', () => { it('should return tool scheduling info on valid input', async () => { @@ -1132,10 +1133,20 @@ Add any other context about the problem here. describe('/compress command', () => { it('should call tryCompressChat(true)', async () => { - const { handleSlashCommand } = getProcessor(); + const hook = getProcessorHook(); mockTryCompressChat.mockImplementationOnce(async (force?: boolean) => { - // TODO: Check that we have a pending compression item in the history. expect(force).toBe(true); + await act(async () => { + hook.rerender(); + }); + expect(hook.result.current.pendingHistoryItems).toContainEqual({ + type: MessageType.COMPRESSION, + compression: { + isPending: true, + originalTokenCount: null, + newTokenCount: null, + }, + }); return { originalTokenCount: 100, newTokenCount: 50, @@ -1143,8 +1154,12 @@ Add any other context about the problem here. }); await act(async () => { - handleSlashCommand('/compress'); + hook.result.current.handleSlashCommand('/compress'); + }); + await act(async () => { + hook.rerender(); }); + expect(hook.result.current.pendingHistoryItems).toEqual([]); expect(mockGeminiClient.tryCompressChat).toHaveBeenCalledWith(true); expect(mockAddItem).toHaveBeenNthCalledWith( 2, |
