import dayjs from 'dayjs'; import customParseFormat from 'dayjs/plugin/customParseFormat'; import { mount } from 'enzyme'; import React from 'react'; import TimePicker from '..'; import focusTest from '../../../tests/shared/focusTest'; import mountTest from '../../../tests/shared/mountTest'; import rtlTest from '../../../tests/shared/rtlTest'; import { resetWarned } from '../../_util/warning'; dayjs.extend(customParseFormat); describe('TimePicker', () => { const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); afterEach(() => { errorSpy.mockReset(); }); afterAll(() => { errorSpy.mockRestore(); }); focusTest(TimePicker, { refFocus: true }); mountTest(TimePicker); rtlTest(TimePicker); it('warning for addon', () => { resetWarned(); const addon = () => ( ); const wrapper = mount(); expect(wrapper.find('.my-btn').length).toBeTruthy(); expect(errorSpy).toHaveBeenCalledWith( 'Warning: [antd: TimePicker] `addon` is deprecated. Please use `renderExtraFooter` instead.', ); }); it('not render clean icon when allowClear is false', () => { const wrapper = mount( , ); expect(wrapper.render()).toMatchSnapshot(); }); it('clearIcon should render correctly', () => { const clearIcon =
test
; const wrapper = mount(); expect(wrapper.find('Picker').last().prop('clearIcon')).toEqual(
test
, ); }); it('prop locale should works', () => { const locale = { placeholder: 'Избери дата', }; const wrapper = mount( , ); expect(wrapper.render()).toMatchSnapshot(); }); it('should pass popupClassName prop to Picker as dropdownClassName prop', () => { const popupClassName = 'myCustomClassName'; const wrapper = mount( , ); expect(wrapper.find('Picker').last().prop('dropdownClassName')).toEqual(popupClassName); }); it('should pass popupClassName prop to RangePicker as dropdownClassName prop', () => { const popupClassName = 'myCustomClassName'; const wrapper = mount( , ); expect(wrapper.find('RangePicker').last().prop('dropdownClassName')).toEqual(popupClassName); }); it('RangePicker should show warning when use dropdownClassName', () => { mount(); expect(errorSpy).toHaveBeenCalledWith( 'Warning: [antd: RangePicker] `dropdownClassName` is deprecated which will be removed in next major version. Please use `popupClassName` instead.', ); }); it('TimePicker should show warning when use dropdownClassName', () => { mount(); expect(errorSpy).toHaveBeenCalledWith( 'Warning: [antd: TimePicker] `dropdownClassName` is deprecated which will be removed in next major version. Please use `popupClassName` instead.', ); }); it('should support bordered', () => { const wrapper = mount( , ); expect(wrapper.render()).toMatchSnapshot(); }); });