2019-09-07 10:31:22 +00:00
|
|
|
import React from 'react';
|
2019-11-01 06:21:59 +00:00
|
|
|
import { mount, shallow } from 'enzyme';
|
2019-09-07 10:31:22 +00:00
|
|
|
import DropDownItem from '.';
|
|
|
|
|
2019-11-01 06:21:59 +00:00
|
|
|
const baseProps = {
|
|
|
|
isSeparator: false,
|
|
|
|
isHeader: false,
|
|
|
|
tabIndex: -1,
|
|
|
|
label: 'test',
|
|
|
|
disabled: false,
|
|
|
|
icon: 'NavLogoIcon',
|
|
|
|
noHover: false,
|
|
|
|
onClick: jest.fn()
|
|
|
|
}
|
|
|
|
|
2019-09-07 10:31:22 +00:00
|
|
|
describe('<DropDownItem />', () => {
|
|
|
|
it('renders without error', () => {
|
|
|
|
const wrapper = mount(
|
2019-11-01 06:21:59 +00:00
|
|
|
<DropDownItem {...baseProps} />
|
2019-09-07 10:31:22 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
expect(wrapper).toExist();
|
|
|
|
});
|
2019-11-01 06:21:59 +00:00
|
|
|
|
|
|
|
it('check disabled props', () => {
|
|
|
|
const wrapper = mount(
|
|
|
|
<DropDownItem {...baseProps} disabled={true} />
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(wrapper.prop('disabled')).toEqual(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('check isSeparator props', () => {
|
|
|
|
const wrapper = mount(
|
|
|
|
<DropDownItem {...baseProps} isSeparator={true} />
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(wrapper.prop('isSeparator')).toEqual(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('check isHeader props', () => {
|
|
|
|
const wrapper = mount(
|
|
|
|
<DropDownItem {...baseProps} isHeader={true} />
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(wrapper.prop('isHeader')).toEqual(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('check noHover props', () => {
|
|
|
|
const wrapper = mount(
|
|
|
|
<DropDownItem {...baseProps} noHover={true} />
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(wrapper.prop('noHover')).toEqual(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('causes function onClick()', () => {
|
|
|
|
const onClick = jest.fn();
|
|
|
|
|
|
|
|
const wrapper = shallow(<DropDownItem id='test' {...baseProps} onClick={onClick} />);
|
|
|
|
|
|
|
|
wrapper.find("#test").simulate("click")
|
|
|
|
|
|
|
|
expect(onClick).toHaveBeenCalled();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('render without child', () => {
|
|
|
|
const wrapper = shallow(
|
|
|
|
<DropDownItem >
|
|
|
|
test
|
|
|
|
</DropDownItem>
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(wrapper.props.children).toEqual(undefined);
|
|
|
|
});
|
2019-11-27 13:39:21 +00:00
|
|
|
|
|
|
|
it('accepts id', () => {
|
|
|
|
const wrapper = mount(
|
|
|
|
<DropDownItem {...baseProps} id="testId" />
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(wrapper.prop('id')).toEqual('testId');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('accepts className', () => {
|
|
|
|
const wrapper = mount(
|
|
|
|
<DropDownItem {...baseProps} className="test" />
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(wrapper.prop('className')).toEqual('test');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('accepts style', () => {
|
|
|
|
const wrapper = mount(
|
|
|
|
<DropDownItem {...baseProps} style={{ color: 'red' }} />
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(wrapper.getDOMNode().style).toHaveProperty('color', 'red');
|
|
|
|
});
|
2019-09-07 10:31:22 +00:00
|
|
|
});
|