refactor: Update Card tests to use renderWithProviders and add new card states

This commit is contained in:
Mark McLaughlin
2026-02-10 12:00:13 -08:00
parent 861a72906d
commit 85446fdfd3

View File

@@ -4,11 +4,11 @@
* SPDX-License-Identifier: Apache-2.0
*/
import { render } from '../../../test-utils/render.js';
import { renderWithProviders } from '../../../test-utils/render.js';
import { Card } from './Card.js';
import { Text } from 'ink';
import { describe, it, expect, afterEach, vi } from 'vitest';
import { ToolCallStatus } from '../../types.js';
import { ToolCallStatus, StreamingState } from '../../types.js';
describe('Card', () => {
afterEach(() => {
@@ -51,6 +51,20 @@ describe('Card', () => {
showStatusIndicator: true,
body: 'Listed 39 item(s).',
},
{
status: ToolCallStatus.Executing,
title: 'Searching',
suffix: 'ripgrep',
showStatusIndicator: true,
body: 'Searching for pattern in directory...',
},
{
status: ToolCallStatus.Pending,
title: 'No Status Indicator',
suffix: 'Hidden',
showStatusIndicator: false,
body: 'The status indicator should be hidden.',
},
{
status: ToolCallStatus.Pending,
title: 'Fixed Width Card',
@@ -62,7 +76,7 @@ describe('Card', () => {
] as const)(
"renders '$title' card with status=$status and showStatusIndicator=$showStatusIndicator",
({ status, title, suffix, showStatusIndicator, body, width }) => {
const { lastFrame } = render(
const { lastFrame } = renderWithProviders(
<Card
status={status}
title={title}
@@ -72,6 +86,11 @@ describe('Card', () => {
>
<Text>{body}</Text>
</Card>,
{
uiState: {
streamingState: StreamingState.Responding,
},
},
);
const output = lastFrame();