2022-02-14 21:58:20 +03:00
|
|
|
import { shallow } from 'enzyme';
|
|
|
|
import { Card, Nav } from 'reactstrap';
|
|
|
|
import { NavPillItem, NavPills } from '../../src/utils/NavPills';
|
|
|
|
|
|
|
|
describe('<NavPills />', () => {
|
|
|
|
it.each([
|
2022-03-26 14:17:42 +03:00
|
|
|
['Foo'],
|
|
|
|
[<span key="1">Hi!</span>],
|
|
|
|
[[<NavPillItem key="1" to="" />, <span key="2">Hi!</span>]],
|
2022-02-14 21:58:20 +03:00
|
|
|
])('throws error when any of the children is not a NavPillItem', (children) => {
|
|
|
|
expect.assertions(1);
|
|
|
|
|
|
|
|
try {
|
|
|
|
shallow(<NavPills>{children}</NavPills>);
|
|
|
|
} catch (e: any) {
|
|
|
|
expect(e.message).toEqual('Only NavPillItem children are allowed inside NavPills.');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2022-02-14 22:28:28 +03:00
|
|
|
it.each([
|
2022-03-26 14:17:42 +03:00
|
|
|
[undefined],
|
|
|
|
[true],
|
|
|
|
[false],
|
2022-02-14 22:28:28 +03:00
|
|
|
])('renders provided items', (fill) => {
|
2022-02-14 21:58:20 +03:00
|
|
|
const wrapper = shallow(
|
2022-02-14 22:28:28 +03:00
|
|
|
<NavPills fill={fill}>
|
2022-02-14 21:58:20 +03:00
|
|
|
<NavPillItem to="1">1</NavPillItem>
|
|
|
|
<NavPillItem to="2">2</NavPillItem>
|
|
|
|
<NavPillItem to="3">3</NavPillItem>
|
|
|
|
</NavPills>,
|
|
|
|
);
|
|
|
|
const card = wrapper.find(Card);
|
|
|
|
const nav = wrapper.find(Nav);
|
|
|
|
|
|
|
|
expect(card).toHaveLength(1);
|
|
|
|
expect(card.prop('body')).toEqual(true);
|
|
|
|
expect(nav).toHaveLength(1);
|
|
|
|
expect(nav.prop('pills')).toEqual(true);
|
2022-02-14 22:28:28 +03:00
|
|
|
expect(nav.prop('fill')).toEqual(!!fill);
|
2022-02-14 21:58:20 +03:00
|
|
|
});
|
|
|
|
});
|