summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/hooks/useGeminiStream.test.tsx
diff options
context:
space:
mode:
authorJacob Richman <[email protected]>2025-08-12 14:05:49 -0700
committerGitHub <[email protected]>2025-08-12 21:05:49 +0000
commitd219f9013206aad5a1361e436ad4a45114e9cd49 (patch)
tree58216dc659e809bc896b03de21a9a1c713126d6b /packages/cli/src/ui/hooks/useGeminiStream.test.tsx
parent74fd0841d0d7148127e586fce4c550a01ff40e90 (diff)
Switch from useInput to useKeypress. (#6056)
Diffstat (limited to 'packages/cli/src/ui/hooks/useGeminiStream.test.tsx')
-rw-r--r--packages/cli/src/ui/hooks/useGeminiStream.test.tsx25
1 files changed, 14 insertions, 11 deletions
diff --git a/packages/cli/src/ui/hooks/useGeminiStream.test.tsx b/packages/cli/src/ui/hooks/useGeminiStream.test.tsx
index 751b869e..37d63e9a 100644
--- a/packages/cli/src/ui/hooks/useGeminiStream.test.tsx
+++ b/packages/cli/src/ui/hooks/useGeminiStream.test.tsx
@@ -8,7 +8,7 @@
import { describe, it, expect, vi, beforeEach, Mock } from 'vitest';
import { renderHook, act, waitFor } from '@testing-library/react';
import { useGeminiStream, mergePartListUnions } from './useGeminiStream.js';
-import { useInput } from 'ink';
+import { useKeypress } from './useKeypress.js';
import {
useReactToolScheduler,
TrackedToolCall,
@@ -71,10 +71,9 @@ vi.mock('./useReactToolScheduler.js', async (importOriginal) => {
};
});
-vi.mock('ink', async (importOriginal) => {
- const actualInkModule = (await importOriginal()) as any;
- return { ...(actualInkModule || {}), useInput: vi.fn() };
-});
+vi.mock('./useKeypress.js', () => ({
+ useKeypress: vi.fn(),
+}));
vi.mock('./shellCommandProcessor.js', () => ({
useShellCommandProcessor: vi.fn().mockReturnValue({
@@ -899,19 +898,23 @@ describe('useGeminiStream', () => {
});
describe('User Cancellation', () => {
- let useInputCallback: (input: string, key: any) => void;
- const mockUseInput = useInput as Mock;
+ let keypressCallback: (key: any) => void;
+ const mockUseKeypress = useKeypress as Mock;
beforeEach(() => {
- // Capture the callback passed to useInput
- mockUseInput.mockImplementation((callback) => {
- useInputCallback = callback;
+ // Capture the callback passed to useKeypress
+ mockUseKeypress.mockImplementation((callback, options) => {
+ if (options.isActive) {
+ keypressCallback = callback;
+ } else {
+ keypressCallback = () => {};
+ }
});
});
const simulateEscapeKeyPress = () => {
act(() => {
- useInputCallback('', { escape: true });
+ keypressCallback({ name: 'escape' });
});
};