test(cli): refactor tests for async render utilities (#23252)

This commit is contained in:
Tommaso Sciortino
2026-03-20 20:08:29 +00:00
committed by GitHub
parent 86a3a913b5
commit 6c78eb7a39
198 changed files with 3592 additions and 4802 deletions
@@ -18,10 +18,9 @@ describe('<Checklist />', () => {
];
it('renders nothing when list is empty', async () => {
const { lastFrame, waitUntilReady } = render(
const { lastFrame } = await render(
<Checklist title="Test List" items={[]} isExpanded={true} />,
);
await waitUntilReady();
expect(lastFrame({ allowEmpty: true })).toBe('');
});
@@ -30,15 +29,14 @@ describe('<Checklist />', () => {
{ status: 'completed', label: 'Task 1' },
{ status: 'cancelled', label: 'Task 2' },
];
const { lastFrame, waitUntilReady } = render(
const { lastFrame } = await render(
<Checklist title="Test List" items={inactiveItems} isExpanded={false} />,
);
await waitUntilReady();
expect(lastFrame({ allowEmpty: true })).toBe('');
});
it('renders summary view correctly (collapsed)', async () => {
const { lastFrame, waitUntilReady } = render(
const { lastFrame } = await render(
<Checklist
title="Test List"
items={items}
@@ -46,12 +44,11 @@ describe('<Checklist />', () => {
toggleHint="toggle me"
/>,
);
await waitUntilReady();
expect(lastFrame()).toMatchSnapshot();
});
it('renders expanded view correctly', async () => {
const { lastFrame, waitUntilReady } = render(
const { lastFrame } = await render(
<Checklist
title="Test List"
items={items}
@@ -59,7 +56,6 @@ describe('<Checklist />', () => {
toggleHint="toggle me"
/>,
);
await waitUntilReady();
expect(lastFrame()).toMatchSnapshot();
});
@@ -68,10 +64,9 @@ describe('<Checklist />', () => {
{ status: 'completed', label: 'Task 1' },
{ status: 'pending', label: 'Task 2' },
];
const { lastFrame, waitUntilReady } = render(
const { lastFrame } = await render(
<Checklist title="Test List" items={pendingItems} isExpanded={false} />,
);
await waitUntilReady();
expect(lastFrame()).toMatchSnapshot();
});
});