-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSelect.spec.js
More file actions
34 lines (28 loc) · 1.03 KB
/
Select.spec.js
File metadata and controls
34 lines (28 loc) · 1.03 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
import sinon from 'sinon';
import { componentSetup } from 'utils/componentTestingSetup';
import Select from './Select';
describe('<Select/>', () => {
const defaultProps = {
options: ['option1', 'option2', 'option3'],
value: 'option1',
};
beforeEach(() => {
defaultProps.onValueChange = sinon.spy();
});
const setup = propsOverrides => componentSetup(Select, defaultProps, propsOverrides);
it('should render without crashing', () => {
setup();
});
it('should render with class', () => {
const className = 'search-issues-class';
const { wrapper } = setup({ className });
expect(wrapper.hasClass(className)).toBeTruthy();
});
it('should call onValueChange callback when value is selected', () => {
const { wrapper, props } = setup();
const newValue = props.options[2];
const name = 'inputName';
wrapper.simulate('change', { target: { value: newValue, name } });
expect(props.onValueChange.calledOnce && props.onValueChange.calledWithExactly(newValue, name)).toBeTruthy();
});
});