2025-11-22 08:17:29 +05:30
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright 2025 Google LLC
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import { render } from '../../../test-utils/render.js';
|
|
|
|
|
import { ErrorMessage } from './ErrorMessage.js';
|
|
|
|
|
import { describe, it, expect } from 'vitest';
|
|
|
|
|
|
|
|
|
|
describe('ErrorMessage', () => {
|
2026-02-18 16:46:50 -08:00
|
|
|
it('renders with the correct prefix and text', async () => {
|
2026-03-20 20:08:29 +00:00
|
|
|
const { lastFrame, unmount } = await render(
|
2026-02-18 16:46:50 -08:00
|
|
|
<ErrorMessage text="Something went wrong" />,
|
|
|
|
|
);
|
2025-11-22 08:17:29 +05:30
|
|
|
const output = lastFrame();
|
|
|
|
|
|
|
|
|
|
expect(output).toMatchSnapshot();
|
2026-02-18 16:46:50 -08:00
|
|
|
unmount();
|
2025-11-22 08:17:29 +05:30
|
|
|
});
|
|
|
|
|
|
2026-02-18 16:46:50 -08:00
|
|
|
it('renders multiline error messages', async () => {
|
2025-11-22 08:17:29 +05:30
|
|
|
const message = 'Error line 1\nError line 2';
|
2026-03-20 20:08:29 +00:00
|
|
|
const { lastFrame, unmount } = await render(
|
2026-02-18 16:46:50 -08:00
|
|
|
<ErrorMessage text={message} />,
|
|
|
|
|
);
|
2025-11-22 08:17:29 +05:30
|
|
|
const output = lastFrame();
|
|
|
|
|
|
|
|
|
|
expect(output).toMatchSnapshot();
|
2026-02-18 16:46:50 -08:00
|
|
|
unmount();
|
2025-11-22 08:17:29 +05:30
|
|
|
});
|
|
|
|
|
});
|