web: Components: Added tests for ComboBox component.

This commit is contained in:
Ilya Oleshko 2019-09-19 09:14:36 +03:00
parent 12730cebaa
commit d73b569fcc

View File

@ -31,12 +31,14 @@ const baseProps = {
isDisabled: false,
selectedOption: {
key: 0,
icon: 'CatalogFolderIcon',
label: "Select"
},
options: baseOptions,
opened: false,
onSelect: () => jest.fn(),
size: 'base',
dropDownMaxHeight: 200,
scaled: true
};
@ -63,6 +65,66 @@ describe('<ComboBox />', () => {
expect(wrapper.prop('isDisabled')).toEqual(true);
});
it('no border when noBorder is passed', () => {
const wrapper = mount(<ComboBox {...baseProps} noBorder={true} />);
expect(wrapper.prop('noBorder')).toEqual(true);
});
it('opened when opened is passed', () => {
const wrapper = mount(<ComboBox {...baseProps} opened={true} />);
expect(wrapper.prop('opened')).toEqual(true);
});
it('not scaled button', () => {
const wrapper = mount(<ComboBox {...baseProps} scaled={false} />);
expect(wrapper.prop('scaled')).toEqual(false);
});
it('scaled button', () => {
const wrapper = mount(<ComboBox {...baseProps} scaled={true} />);
expect(wrapper.prop('scaled')).toEqual(true);
});
it('scaled options', () => {
const wrapper = mount(<ComboBox {...baseProps} scaledOptions={true} />);
expect(wrapper.prop('scaledOptions')).toEqual(true);
});
it('middle size options', () => {
const wrapper = mount(<ComboBox {...baseProps} size='middle' />);
expect(wrapper.prop('size')).toEqual('middle');
});
it('big size options', () => {
const wrapper = mount(<ComboBox {...baseProps} size='big' />);
expect(wrapper.prop('size')).toEqual('big');
});
it('huge size options', () => {
const wrapper = mount(<ComboBox {...baseProps} size='huge' />);
expect(wrapper.prop('size')).toEqual('huge');
});
it('content size options', () => {
const wrapper = mount(<ComboBox {...baseProps} size='content' />);
expect(wrapper.prop('size')).toEqual('content');
});
it('with children node', () => {
const wrapper = mount(<ComboBox {...baseProps} ><div>demo</div></ComboBox>);
expect(wrapper.contains(<div>demo</div>)).toBe(true)
});
it('not re-render test', () => {
const wrapper = shallow(<ComboBox {...baseProps} />).instance();
@ -74,19 +136,7 @@ describe('<ComboBox />', () => {
it('re-render test', () => {
const wrapper = shallow(<ComboBox {...baseProps} />).instance();
const shouldUpdate = wrapper.shouldComponentUpdate({
noBorder: true,
isDisabled: false,
selectedOption: {
key: 0,
label: "Select"
},
options: baseOptions,
opened: false,
onSelect: () => jest.fn(),
size: 'base',
scaled: true
}, wrapper.state);
const shouldUpdate = wrapper.shouldComponentUpdate({ noBorder: true }, wrapper.state);
expect(shouldUpdate).toBe(true);
});