-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathPickerInput.test.tsx
30 lines (25 loc) · 952 Bytes
/
PickerInput.test.tsx
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
import * as React from 'react';
import { mount, ReactWrapper } from 'enzyme';
import PickerInput from '../src/components/PickerInput';
import * as sinon from 'sinon';
describe('<PickerInput/>', () => {
let onChange: sinon.SinonSpy;
let onClear: sinon.SinonSpy;
let mountComponent: ReactWrapper;
beforeEach(() => {
onChange = sinon.spy();
onClear = sinon.spy();
mountComponent = mount(<PickerInput autoFocus clear onChange={onChange} onClear={onClear} />);
});
it('should props autoFocus correctly', () => {
expect(mountComponent.find('input').getDOMNode()).toEqual(document.activeElement);
});
it('should onClear correctly', () => {
mountComponent.find('.icon-clear').first().simulate('click');
expect(onClear).toHaveProperty('callCount', 1);
});
it('should onChange correctly', () => {
mountComponent.find('input').simulate('change');
expect(onChange).toHaveProperty('callCount', 1);
});
});