-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathSelectBox.spec.jsx
More file actions
executable file
·45 lines (39 loc) · 1.32 KB
/
Copy pathSelectBox.spec.jsx
File metadata and controls
executable file
·45 lines (39 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import React from 'react';
import { shallow, mount } from 'enzyme';
import SelectBox from './SelectBox';
describe('SelectBox', () => {
it('renders', () => {
const wrapper = shallow(<SelectBox options={[]} />);
expect(wrapper.find('div.SelectBox').length).toBeTruthy();
});
it('whole box can be disabled', () => {
const wrapper = shallow(<SelectBox isDisabled options={[]} />);
expect(wrapper.find('div.SelectBox.disabled').length).toBeTruthy();
});
it('uses passed component for options', () => {
const FakeComp = () => <div />;
const wrapper = shallow(
<SelectBox
isDisabled
options={[
{ value: 'abc', title: 'def' },
{ value: 'ghi', title: 'jkl' },
]}
component={FakeComp}
/>
);
expect(wrapper.find(FakeComp)).toHaveLength(2);
});
it('selected options have is-active class', () => {
const options = [
{ value: 'abc', title: 'def' },
{ value: 'ghi', title: 'jkl' },
];
const wrapper = mount(<SelectBox isDisabled options={options} />);
expect(wrapper.find('.is-active')).toHaveLength(0);
wrapper.setProps({ selected: 'ghi' });
expect(wrapper.find('.is-active')).toHaveLength(1);
wrapper.setProps({ selected: ['abc', 'ghi'] });
expect(wrapper.find('.is-active')).toHaveLength(2);
});
});