2019-01-12 03:33:27 +00:00
|
|
|
import { mount } from '@vue/test-utils';
|
|
|
|
import VcTimePicker from '../../vc-time-picker/TimePicker';
|
|
|
|
import TimePicker from '..';
|
2019-04-17 01:00:27 +00:00
|
|
|
import moment from 'moment';
|
2019-01-12 03:33:27 +00:00
|
|
|
import focusTest from '../../../tests/shared/focusTest';
|
2020-03-07 11:45:13 +00:00
|
|
|
import mountTest from '../../../tests/shared/mountTest';
|
2018-06-17 07:57:09 +00:00
|
|
|
|
|
|
|
describe('TimePicker', () => {
|
2019-04-17 01:00:27 +00:00
|
|
|
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
errorSpy.mockReset();
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(() => {
|
|
|
|
errorSpy.mockRestore();
|
|
|
|
});
|
|
|
|
|
2019-01-12 03:33:27 +00:00
|
|
|
focusTest(TimePicker);
|
2020-03-07 11:45:13 +00:00
|
|
|
mountTest(TimePicker);
|
2018-06-17 07:57:09 +00:00
|
|
|
|
|
|
|
it('renders addon correctly', () => {
|
|
|
|
const wrapper = mount({
|
2019-01-12 03:33:27 +00:00
|
|
|
render() {
|
|
|
|
return <TimePicker addon={() => <button type="button">Ok</button>} />;
|
2018-06-17 07:57:09 +00:00
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
});
|
|
|
|
const vcTimePicker = wrapper.find({ name: VcTimePicker.name });
|
2018-06-17 07:57:09 +00:00
|
|
|
const addonWrapper = mount({
|
2019-01-12 03:33:27 +00:00
|
|
|
render() {
|
|
|
|
return vcTimePicker.vm.addon();
|
2018-06-17 07:57:09 +00:00
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
});
|
|
|
|
expect(addonWrapper.html()).toMatchSnapshot();
|
|
|
|
});
|
2019-04-17 01:00:27 +00:00
|
|
|
|
|
|
|
it('allowEmpty deprecated', () => {
|
|
|
|
mount({
|
|
|
|
render() {
|
|
|
|
return <TimePicker allowEmpty />;
|
|
|
|
},
|
|
|
|
});
|
|
|
|
expect(errorSpy).toBeCalledWith(
|
2020-03-07 11:45:13 +00:00
|
|
|
'Warning: [antdv: TimePicker] `allowEmpty` is deprecated. Please use `allowClear` instead.',
|
2019-04-17 01:00:27 +00:00
|
|
|
);
|
|
|
|
});
|
|
|
|
it('not render clean icon when allowClear is false', () => {
|
2019-05-28 03:37:38 +00:00
|
|
|
const wrapper = mount({
|
|
|
|
render() {
|
|
|
|
return <TimePicker defaultValue={moment('2000-01-01 00:00:00')} allowClear={false} />;
|
|
|
|
},
|
|
|
|
});
|
2019-04-17 01:00:27 +00:00
|
|
|
expect(wrapper.html()).toMatchSnapshot();
|
|
|
|
});
|
2019-01-12 03:33:27 +00:00
|
|
|
});
|