Switch from useInput to useKeypress. (#6056)

This commit is contained in:
Jacob Richman 2025-08-12 14:05:49 -07:00 committed by GitHub
parent 74fd0841d0
commit d219f90132
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 350 additions and 259 deletions

View file

@ -5,6 +5,7 @@
*/
import { render } from 'ink-testing-library';
import { waitFor } from '@testing-library/react';
import { vi } from 'vitest';
import { FolderTrustDialog, FolderTrustChoice } from './FolderTrustDialog.js';
@ -18,12 +19,14 @@ describe('FolderTrustDialog', () => {
);
});
it('should call onSelect with DO_NOT_TRUST when escape is pressed', () => {
it('should call onSelect with DO_NOT_TRUST when escape is pressed', async () => {
const onSelect = vi.fn();
const { stdin } = render(<FolderTrustDialog onSelect={onSelect} />);
stdin.write('\u001B'); // Simulate escape key
stdin.write('\x1b');
expect(onSelect).toHaveBeenCalledWith(FolderTrustChoice.DO_NOT_TRUST);
await waitFor(() => {
expect(onSelect).toHaveBeenCalledWith(FolderTrustChoice.DO_NOT_TRUST);
});
});
});