import { matchers } from '@emotion/jest';
import { theme, CheckIcon } from '@expo/styleguide';
import { render, screen } from '@testing-library/react';
import ReactMarkdown from 'react-markdown';
import { Callout } from '.';
expect.extend(matchers);
describe(Callout, () => {
it('renders callout with icon emoji', () => {
render(Hello);
expect(screen.getByText('🎨')).toBeInTheDocument();
expect(screen.getByText('Hello')).toBeInTheDocument();
});
it('renders callout with icon component', () => {
render(Hello);
expect(screen.getByTitle('Check-icon')).toBeInTheDocument();
expect(screen.getByText('Hello')).toBeInTheDocument();
});
it('renders callout with default icon from info type', () => {
render(Hello);
expect(screen.getByTitle('Info-icon')).toBeInTheDocument();
});
it('renders callout with default icon from warning type', () => {
render(Hello);
expect(screen.getByTitle('Warning-icon')).toBeInTheDocument();
});
it('renders callout with default icon from error type', () => {
render(Hello);
expect(screen.getByTitle('Error-icon')).toBeInTheDocument();
});
it('renders callout with warning style from warning type', () => {
render(Hello);
expect(screen.getByTestId('callout-container')).toHaveStyleRule(
'background-color',
theme.background.warning
);
});
it('renders callout with error style from warning type', () => {
render(Hello);
expect(screen.getByTestId('callout-container')).toHaveStyleRule(
'background-color',
theme.background.error
);
});
it('renders callout with info style from warning type', () => {
render(Hello);
expect(screen.getByTestId('callout-container')).toHaveStyleRule(
'background-color',
theme.background.info
);
expect(screen.getByTestId('callout-container')).toHaveStyleRule(
'border-color',
theme.border.info
);
});
it('renders from translated Markdown', () => {
render({'> Hello'});
expect(screen.getByTestId('callout-container')).toBeInTheDocument();
expect(screen.getByText('Hello')).toBeInTheDocument();
});
it('renders correct type from translated Markdown', () => {
render(
{`> **warning** Hello`}
);
expect(screen.getByTestId('callout-container')).toBeInTheDocument();
expect(screen.getByTestId('callout-container')).toHaveStyleRule(
'background-color',
theme.background.warning
);
expect(screen.getByTitle('Warning-icon')).toBeInTheDocument();
expect(screen.getByText('Hello')).toBeInTheDocument();
});
it('renders content starting with emphasized word which is not a type', () => {
render(
{`> **Note**: Hello`}
);
expect(screen.getByTestId('callout-container')).toBeInTheDocument();
expect(screen.getByText('Note')).toBeInTheDocument();
expect(screen.getByText(': Hello')).toBeInTheDocument();
});
});