refactor(cli): simplify keypress and mouse providers and update tests (#22853)

This commit is contained in:
Tommaso Sciortino
2026-03-18 16:38:56 +00:00
committed by GitHub
parent 81a97e78f1
commit d7dfcf7f99
40 changed files with 923 additions and 863 deletions

View File

@@ -5,9 +5,8 @@
*/
import { act } from 'react';
import { render } from '../../test-utils/render.js';
import { renderHookWithProviders } from '../../test-utils/render.js';
import { useKeypress } from './useKeypress.js';
import { KeypressProvider } from '../contexts/KeypressContext.js';
import { useStdin } from 'ink';
import { EventEmitter } from 'node:events';
import type { Mock } from 'vitest';
@@ -44,17 +43,8 @@ describe(`useKeypress`, () => {
const onKeypress = vi.fn();
let originalNodeVersion: string;
const renderKeypressHook = (isActive = true) => {
function TestComponent() {
useKeypress(onKeypress, { isActive });
return null;
}
return render(
<KeypressProvider>
<TestComponent />
</KeypressProvider>,
);
};
const renderKeypressHook = (isActive = true) =>
renderHookWithProviders(() => useKeypress(onKeypress, { isActive }));
beforeEach(() => {
vi.clearAllMocks();