mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-05-02 18:01:59 +03:00
Created SimpleCard component to reduce duplicated code when rendering cards
This commit is contained in:
parent
e60d241fcf
commit
2017ee7456
4 changed files with 126 additions and 93 deletions
test/utils
30
test/utils/SimpleCard.test.tsx
Normal file
30
test/utils/SimpleCard.test.tsx
Normal file
|
@ -0,0 +1,30 @@
|
|||
import { shallow } from 'enzyme';
|
||||
import { Card, CardBody, CardHeader } from 'reactstrap';
|
||||
import { SimpleCard } from '../../src/utils/SimpleCard';
|
||||
|
||||
describe('<SimpleCard />', () => {
|
||||
it.each([
|
||||
[{}, 0 ],
|
||||
[{ title: 'Cool title' }, 1 ],
|
||||
])('renders header only if title is provided', (props, expectedAmountOfHeaders) => {
|
||||
const wrapper = shallow(<SimpleCard {...props} />);
|
||||
|
||||
expect(wrapper.find(CardHeader)).toHaveLength(expectedAmountOfHeaders);
|
||||
});
|
||||
|
||||
it('renders children inside body', () => {
|
||||
const wrapper = shallow(<SimpleCard>Hello world</SimpleCard>);
|
||||
const body = wrapper.find(CardBody);
|
||||
|
||||
expect(body).toHaveLength(1);
|
||||
expect(body.html()).toContain('Hello world');
|
||||
});
|
||||
|
||||
it('passes extra props to nested card', () => {
|
||||
const wrapper = shallow(<SimpleCard className="foo" color="primary">Hello world</SimpleCard>);
|
||||
const card = wrapper.find(Card);
|
||||
|
||||
expect(card.prop('className')).toEqual('foo');
|
||||
expect(card.prop('color')).toEqual('primary');
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue