2022-05-02 11:01:29 +03:00
|
|
|
import { render, screen } from '@testing-library/react';
|
2023-07-31 22:36:44 +03:00
|
|
|
import { SimpleCard } from '../../shlink-frontend-kit/src/block/SimpleCard';
|
2020-12-08 21:10:29 +03:00
|
|
|
|
|
|
|
describe('<SimpleCard />', () => {
|
2022-05-02 11:01:29 +03:00
|
|
|
it('does not render title if not provided', () => {
|
|
|
|
render(<SimpleCard />);
|
|
|
|
expect(screen.queryByRole('heading')).not.toBeInTheDocument();
|
|
|
|
});
|
2020-12-08 21:10:29 +03:00
|
|
|
|
2022-05-02 11:01:29 +03:00
|
|
|
it('renders provided title', () => {
|
|
|
|
render(<SimpleCard title="Cool title" />);
|
|
|
|
expect(screen.getByRole('heading')).toHaveTextContent('Cool title');
|
2020-12-08 21:10:29 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('renders children inside body', () => {
|
2022-05-02 11:01:29 +03:00
|
|
|
render(<SimpleCard>Hello world</SimpleCard>);
|
|
|
|
expect(screen.getByText('Hello world')).toBeInTheDocument();
|
2020-12-08 21:10:29 +03:00
|
|
|
});
|
|
|
|
|
2022-05-02 11:01:29 +03:00
|
|
|
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}`);
|
2020-12-08 21:10:29 +03:00
|
|
|
});
|
|
|
|
});
|