mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-07-14 03:50:49 -07:00
test(cli): refactor tests for async render utilities (#23252)
This commit is contained in:
committed by
GitHub
parent
757bb3854a
commit
d0bab49ef7
@@ -13,7 +13,7 @@ describe('ExpandableText', () => {
|
||||
const flat = (s: string | undefined) => (s ?? '').replace(/\n/g, '');
|
||||
|
||||
it('renders plain label when no match (short label)', async () => {
|
||||
const renderResult = render(
|
||||
const renderResult = await render(
|
||||
<ExpandableText
|
||||
label="simple command"
|
||||
userInput=""
|
||||
@@ -22,15 +22,14 @@ describe('ExpandableText', () => {
|
||||
isExpanded={false}
|
||||
/>,
|
||||
);
|
||||
const { waitUntilReady, unmount } = renderResult;
|
||||
await waitUntilReady();
|
||||
const { unmount } = renderResult;
|
||||
await expect(renderResult).toMatchSvgSnapshot();
|
||||
unmount();
|
||||
});
|
||||
|
||||
it('truncates long label when collapsed and no match', async () => {
|
||||
const long = 'x'.repeat(MAX_WIDTH + 25);
|
||||
const renderResult = render(
|
||||
const renderResult = await render(
|
||||
<ExpandableText
|
||||
label={long}
|
||||
userInput=""
|
||||
@@ -38,8 +37,7 @@ describe('ExpandableText', () => {
|
||||
isExpanded={false}
|
||||
/>,
|
||||
);
|
||||
const { lastFrame, waitUntilReady, unmount } = renderResult;
|
||||
await waitUntilReady();
|
||||
const { lastFrame, unmount } = renderResult;
|
||||
const out = lastFrame();
|
||||
const f = flat(out);
|
||||
expect(f.endsWith('...')).toBe(true);
|
||||
@@ -50,7 +48,7 @@ describe('ExpandableText', () => {
|
||||
|
||||
it('shows full long label when expanded and no match', async () => {
|
||||
const long = 'y'.repeat(MAX_WIDTH + 25);
|
||||
const renderResult = render(
|
||||
const renderResult = await render(
|
||||
<ExpandableText
|
||||
label={long}
|
||||
userInput=""
|
||||
@@ -58,8 +56,7 @@ describe('ExpandableText', () => {
|
||||
isExpanded={true}
|
||||
/>,
|
||||
);
|
||||
const { lastFrame, waitUntilReady, unmount } = renderResult;
|
||||
await waitUntilReady();
|
||||
const { lastFrame, unmount } = renderResult;
|
||||
const out = lastFrame();
|
||||
const f = flat(out);
|
||||
expect(f.length).toBe(long.length);
|
||||
@@ -71,7 +68,7 @@ describe('ExpandableText', () => {
|
||||
const label = 'run: git commit -m "feat: add search"';
|
||||
const userInput = 'commit';
|
||||
const matchedIndex = label.indexOf(userInput);
|
||||
const renderResult = render(
|
||||
const renderResult = await render(
|
||||
<ExpandableText
|
||||
label={label}
|
||||
userInput={userInput}
|
||||
@@ -81,8 +78,7 @@ describe('ExpandableText', () => {
|
||||
/>,
|
||||
100,
|
||||
);
|
||||
const { waitUntilReady, unmount } = renderResult;
|
||||
await waitUntilReady();
|
||||
const { unmount } = renderResult;
|
||||
await expect(renderResult).toMatchSvgSnapshot();
|
||||
unmount();
|
||||
});
|
||||
@@ -93,7 +89,7 @@ describe('ExpandableText', () => {
|
||||
const suffix = '/and/then/some/more/components/'.repeat(3);
|
||||
const label = prefix + core + suffix;
|
||||
const matchedIndex = prefix.length;
|
||||
const renderResult = render(
|
||||
const renderResult = await render(
|
||||
<ExpandableText
|
||||
label={label}
|
||||
userInput={core}
|
||||
@@ -103,8 +99,7 @@ describe('ExpandableText', () => {
|
||||
/>,
|
||||
100,
|
||||
);
|
||||
const { lastFrame, waitUntilReady, unmount } = renderResult;
|
||||
await waitUntilReady();
|
||||
const { lastFrame, unmount } = renderResult;
|
||||
const out = lastFrame();
|
||||
const f = flat(out);
|
||||
expect(f.includes(core)).toBe(true);
|
||||
@@ -120,7 +115,7 @@ describe('ExpandableText', () => {
|
||||
const suffix = ' in this text';
|
||||
const label = prefix + core + suffix;
|
||||
const matchedIndex = prefix.length;
|
||||
const renderResult = render(
|
||||
const renderResult = await render(
|
||||
<ExpandableText
|
||||
label={label}
|
||||
userInput={core}
|
||||
@@ -129,8 +124,7 @@ describe('ExpandableText', () => {
|
||||
isExpanded={false}
|
||||
/>,
|
||||
);
|
||||
const { lastFrame, waitUntilReady, unmount } = renderResult;
|
||||
await waitUntilReady();
|
||||
const { lastFrame, unmount } = renderResult;
|
||||
const out = lastFrame();
|
||||
const f = flat(out);
|
||||
expect(f.includes('...')).toBe(true);
|
||||
@@ -144,7 +138,7 @@ describe('ExpandableText', () => {
|
||||
it('respects custom maxWidth', async () => {
|
||||
const customWidth = 50;
|
||||
const long = 'z'.repeat(100);
|
||||
const renderResult = render(
|
||||
const renderResult = await render(
|
||||
<ExpandableText
|
||||
label={long}
|
||||
userInput=""
|
||||
@@ -153,8 +147,7 @@ describe('ExpandableText', () => {
|
||||
maxWidth={customWidth}
|
||||
/>,
|
||||
);
|
||||
const { lastFrame, waitUntilReady, unmount } = renderResult;
|
||||
await waitUntilReady();
|
||||
const { lastFrame, unmount } = renderResult;
|
||||
const out = lastFrame();
|
||||
const f = flat(out);
|
||||
expect(f.endsWith('...')).toBe(true);
|
||||
|
||||
Reference in New Issue
Block a user