import React from 'react';
import { mount, shallow } from 'enzyme';
import ComboBox from '.';
import DropDownItem from '../drop-down-item';
const baseOptions = [
{
key: 0,
label: "Select"
},
{
key: 1,
label: "Select"
},
{
key: 2,
label: "Select"
}
];
const advancedOptions = (
<>
Some text
>
);
const baseProps = {
noBorder: false,
isDisabled: false,
selectedOption: {
key: 0,
icon: 'CatalogFolderIcon',
label: "Select"
},
options: baseOptions,
opened: false,
onSelect: () => jest.fn(),
size: 'base',
scaled: true
};
describe('', () => {
it('renders without error', () => {
const wrapper = mount(
);
expect(wrapper).toExist();
});
it('render with advanced options', () => {
const wrapper = mount(
);
expect(wrapper).toExist();
});
it('disabled when isDisabled is passed', () => {
const wrapper = mount();
expect(wrapper.prop('isDisabled')).toEqual(true);
});
it('no border when noBorder is passed', () => {
const wrapper = mount();
expect(wrapper.prop('noBorder')).toEqual(true);
});
it('opened when opened is passed', () => {
const wrapper = mount();
expect(wrapper.prop('opened')).toEqual(true);
});
it('not scaled button', () => {
const wrapper = mount();
expect(wrapper.prop('dropDownMaxHeight')).toEqual(200);
});
it('not scaled button', () => {
const wrapper = mount();
expect(wrapper.prop('scaled')).toEqual(false);
});
it('scaled button', () => {
const wrapper = mount();
expect(wrapper.prop('scaled')).toEqual(true);
});
it('scaled options', () => {
const wrapper = mount();
expect(wrapper.prop('scaledOptions')).toEqual(true);
});
it('middle size options', () => {
const wrapper = mount();
expect(wrapper.prop('size')).toEqual('middle');
});
it('big size options', () => {
const wrapper = mount();
expect(wrapper.prop('size')).toEqual('big');
});
it('huge size options', () => {
const wrapper = mount();
expect(wrapper.prop('size')).toEqual('huge');
});
it('content size options', () => {
const wrapper = mount();
expect(wrapper.prop('size')).toEqual('content');
});
it('with children node', () => {
const wrapper = mount(demo
);
expect(wrapper.contains(
demo
)).toBe(true)
});
it('not re-render test', () => {
const wrapper = shallow().instance();
const shouldUpdate = wrapper.shouldComponentUpdate(wrapper.props, wrapper.state);
expect(shouldUpdate).toBe(false);
});
it('re-render test', () => {
const wrapper = shallow().instance();
const shouldUpdate = wrapper.shouldComponentUpdate({ noBorder: true }, wrapper.state);
expect(shouldUpdate).toBe(true);
});
});