test: update cases for TimePicker

This commit is contained in:
zy410419243 2019-03-07 11:31:36 +08:00
parent be22c9148b
commit 39d648e3b8

View File

@ -40,4 +40,32 @@ describe('TimePicker', () => {
);
expect(wrapper.render()).toMatchSnapshot();
});
it('handleChange should work correctly', done => {
const date = moment('2000-01-01 00:00:00');
const onChange = (value, formattedValue) => {
expect(value).toBe(date);
expect(formattedValue).toBe(date.format('HH:mm:ss'));
done();
};
const wrapper = mount(<TimePicker onChange={onChange} />).instance();
wrapper.handleChange(date);
});
it('handleOpenClose should work correctly', done => {
const onOpenChange = open => {
expect(open).toBe(true);
done();
};
const wrapper = mount(<TimePicker onOpenChange={onOpenChange} />).instance();
wrapper.handleOpenClose({ open: true });
});
it('clearIcon should render correctly', () => {
const clearIcon = <div className="test-clear-icon">test</div>;
const wrapper = mount(<TimePicker clearIcon={clearIcon} />);
expect(wrapper.find('Picker').prop('clearIcon')).toEqual(
<div className="test-clear-icon ant-time-picker-clear">test</div>,
);
});
});