mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-18 01:51:20 -07:00
67 lines
1.9 KiB
TypeScript
67 lines
1.9 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright 2025 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
import { GeminiMessage } from './GeminiMessage.js';
|
|
import { StreamingState } from '../../types.js';
|
|
import { renderWithProviders } from '../../../test-utils/render.js';
|
|
|
|
describe('<GeminiMessage /> - Raw Markdown Display Snapshots', () => {
|
|
const baseProps = {
|
|
text: 'Test **bold** and `code` markdown\n\n```javascript\nconst x = 1;\n```',
|
|
isPending: false,
|
|
terminalWidth: 80,
|
|
};
|
|
|
|
it.each([
|
|
{ renderMarkdown: true, description: '(default)' },
|
|
{
|
|
renderMarkdown: false,
|
|
description: '(raw markdown with syntax highlighting, no line numbers)',
|
|
},
|
|
])(
|
|
'renders with renderMarkdown=$renderMarkdown $description',
|
|
({ renderMarkdown }) => {
|
|
const { lastFrame } = renderWithProviders(
|
|
<GeminiMessage {...baseProps} />,
|
|
{
|
|
uiState: { renderMarkdown, streamingState: StreamingState.Idle },
|
|
},
|
|
);
|
|
expect(lastFrame()).toMatchSnapshot();
|
|
},
|
|
);
|
|
|
|
it.each([{ renderMarkdown: true }, { renderMarkdown: false }])(
|
|
'renders pending state with renderMarkdown=$renderMarkdown',
|
|
({ renderMarkdown }) => {
|
|
const { lastFrame } = renderWithProviders(
|
|
<GeminiMessage {...baseProps} isPending={true} />,
|
|
{
|
|
uiState: { renderMarkdown, streamingState: StreamingState.Idle },
|
|
},
|
|
);
|
|
expect(lastFrame()).toMatchSnapshot();
|
|
},
|
|
);
|
|
|
|
it('wraps long lines correctly in raw markdown mode', () => {
|
|
const terminalWidth = 20;
|
|
const text =
|
|
'This is a long line that should wrap correctly without truncation';
|
|
const { lastFrame } = renderWithProviders(
|
|
<GeminiMessage
|
|
text={text}
|
|
isPending={false}
|
|
terminalWidth={terminalWidth}
|
|
/>,
|
|
{
|
|
uiState: { renderMarkdown: false, streamingState: StreamingState.Idle },
|
|
},
|
|
);
|
|
expect(lastFrame()).toMatchSnapshot();
|
|
});
|
|
});
|