import { render } from '@testing-library/react';
import { expect, it } from 'vitest';
// Import the toBeInTheDocument function
import type { ITextElement } from '@chainlit/react-client';
import { MessageContent } from 'components/chat/Messages/Message/Content';
it('renders the message content', () => {
const { getByText } = render(
);
expect(getByText('Hello World')).toBeInTheDocument();
});
it('highlights multiple sources correctly (no substring matching)', () => {
const { getByRole } = render(
);
expect(getByRole('link', { name: 'source_1' })).toBeInTheDocument();
expect(getByRole('link', { name: 'source_12' })).toBeInTheDocument();
expect(getByRole('link', { name: 'source_121' })).toBeInTheDocument();
});
it('highlights sources containing regex characters correctly', () => {
const { getByRole } = render(
);
expect(getByRole('link', { name: 'Document[1]' })).toBeInTheDocument();
expect(getByRole('link', { name: 'source(12)' })).toBeInTheDocument();
expect(getByRole('link', { name: 'page{12}' })).toBeInTheDocument();
});