mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-30 23:14:32 -07:00
test(cli): refactor tests for async render utilities (#23252)
This commit is contained in:
committed by
GitHub
parent
86a3a913b5
commit
6c78eb7a39
@@ -48,19 +48,17 @@ describe('ShellInputPrompt', () => {
|
||||
});
|
||||
|
||||
it('renders nothing', async () => {
|
||||
const { lastFrame, waitUntilReady, unmount } = render(
|
||||
const { lastFrame, unmount } = await render(
|
||||
<ShellInputPrompt activeShellPtyId={1} focus={true} />,
|
||||
);
|
||||
await waitUntilReady();
|
||||
expect(lastFrame({ allowEmpty: true })).toBe('');
|
||||
unmount();
|
||||
});
|
||||
|
||||
it('sends tab to pty', async () => {
|
||||
const { waitUntilReady, unmount } = render(
|
||||
const { waitUntilReady, unmount } = await render(
|
||||
<ShellInputPrompt activeShellPtyId={1} focus={true} />,
|
||||
);
|
||||
await waitUntilReady();
|
||||
|
||||
const handler = mockUseKeypress.mock.calls[0][0];
|
||||
|
||||
@@ -84,10 +82,9 @@ describe('ShellInputPrompt', () => {
|
||||
['a', 'a'],
|
||||
['b', 'b'],
|
||||
])('handles keypress input: %s', async (name, sequence) => {
|
||||
const { waitUntilReady, unmount } = render(
|
||||
const { waitUntilReady, unmount } = await render(
|
||||
<ShellInputPrompt activeShellPtyId={1} focus={true} />,
|
||||
);
|
||||
await waitUntilReady();
|
||||
|
||||
// Get the registered handler
|
||||
const handler = mockUseKeypress.mock.calls[0][0];
|
||||
@@ -113,10 +110,9 @@ describe('ShellInputPrompt', () => {
|
||||
['up', -1],
|
||||
['down', 1],
|
||||
])('handles scroll %s (Command.SCROLL_%s)', async (key, direction) => {
|
||||
const { waitUntilReady, unmount } = render(
|
||||
const { waitUntilReady, unmount } = await render(
|
||||
<ShellInputPrompt activeShellPtyId={1} focus={true} />,
|
||||
);
|
||||
await waitUntilReady();
|
||||
|
||||
const handler = mockUseKeypress.mock.calls[0][0];
|
||||
|
||||
@@ -135,10 +131,9 @@ describe('ShellInputPrompt', () => {
|
||||
])(
|
||||
'handles page scroll %s (Command.PAGE_%s) with default size',
|
||||
async (key, expectedScroll) => {
|
||||
const { waitUntilReady, unmount } = render(
|
||||
const { waitUntilReady, unmount } = await render(
|
||||
<ShellInputPrompt activeShellPtyId={1} focus={true} />,
|
||||
);
|
||||
await waitUntilReady();
|
||||
|
||||
const handler = mockUseKeypress.mock.calls[0][0];
|
||||
|
||||
@@ -159,14 +154,13 @@ describe('ShellInputPrompt', () => {
|
||||
);
|
||||
|
||||
it('respects scrollPageSize prop', async () => {
|
||||
const { waitUntilReady, unmount } = render(
|
||||
const { waitUntilReady, unmount } = await render(
|
||||
<ShellInputPrompt
|
||||
activeShellPtyId={1}
|
||||
focus={true}
|
||||
scrollPageSize={10}
|
||||
/>,
|
||||
);
|
||||
await waitUntilReady();
|
||||
|
||||
const handler = mockUseKeypress.mock.calls[0][0];
|
||||
|
||||
@@ -199,10 +193,9 @@ describe('ShellInputPrompt', () => {
|
||||
});
|
||||
|
||||
it('does not handle input when not focused', async () => {
|
||||
const { waitUntilReady, unmount } = render(
|
||||
const { waitUntilReady, unmount } = await render(
|
||||
<ShellInputPrompt activeShellPtyId={1} focus={false} />,
|
||||
);
|
||||
await waitUntilReady();
|
||||
|
||||
const handler = mockUseKeypress.mock.calls[0][0];
|
||||
|
||||
@@ -223,10 +216,9 @@ describe('ShellInputPrompt', () => {
|
||||
});
|
||||
|
||||
it('does not handle input when no active shell', async () => {
|
||||
const { waitUntilReady, unmount } = render(
|
||||
const { waitUntilReady, unmount } = await render(
|
||||
<ShellInputPrompt activeShellPtyId={null} focus={true} />,
|
||||
);
|
||||
await waitUntilReady();
|
||||
|
||||
const handler = mockUseKeypress.mock.calls[0][0];
|
||||
|
||||
@@ -247,10 +239,9 @@ describe('ShellInputPrompt', () => {
|
||||
});
|
||||
|
||||
it('ignores Command.UNFOCUS_SHELL (Shift+Tab) to allow focus navigation', async () => {
|
||||
const { waitUntilReady, unmount } = render(
|
||||
const { waitUntilReady, unmount } = await render(
|
||||
<ShellInputPrompt activeShellPtyId={1} focus={true} />,
|
||||
);
|
||||
await waitUntilReady();
|
||||
|
||||
const handler = mockUseKeypress.mock.calls[0][0];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user