mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-23 01:20:24 +03:00
24 lines
948 B
TypeScript
24 lines
948 B
TypeScript
import { render, screen } from '@testing-library/react';
|
|
import { SimpleCard } from '../../shlink-frontend-kit/src/block/SimpleCard';
|
|
|
|
describe('<SimpleCard />', () => {
|
|
it('does not render title if not provided', () => {
|
|
render(<SimpleCard />);
|
|
expect(screen.queryByRole('heading')).not.toBeInTheDocument();
|
|
});
|
|
|
|
it('renders provided title', () => {
|
|
render(<SimpleCard title="Cool title" />);
|
|
expect(screen.getByRole('heading')).toHaveTextContent('Cool title');
|
|
});
|
|
|
|
it('renders children inside body', () => {
|
|
render(<SimpleCard>Hello world</SimpleCard>);
|
|
expect(screen.getByText('Hello world')).toBeInTheDocument();
|
|
});
|
|
|
|
it.each(['primary', 'danger', 'warning'])('passes extra props to nested card', (color) => {
|
|
const { container } = render(<SimpleCard className="foo" color={color}>Hello world</SimpleCard>);
|
|
expect(container.firstChild).toHaveAttribute('class', `foo card bg-${color}`);
|
|
});
|
|
});
|