import dayjs from 'dayjs'; import customParseFormat from 'dayjs/plugin/customParseFormat'; 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'; import { render } from '../../../tests/utils'; 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 { container } = render(); expect(container.querySelectorAll('.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 { container } = render( , ); expect(container.firstChild).toMatchSnapshot(); }); it('clearIcon should render correctly', () => { const clearIcon =
test
; const { container } = render( , ); expect(container.querySelector('.test-clear-icon')).toBeTruthy(); }); it('prop locale should works', () => { const locale = { placeholder: 'Избери дата', }; const { container } = render( , ); expect(Array.from(container.children)).toMatchSnapshot(); }); it('should pass popupClassName prop to Picker as dropdownClassName prop', () => { const popupClassName = 'myCustomClassName'; const { container } = render( , ); expect(container.querySelector(`.${popupClassName}`)).toBeTruthy(); }); it('should pass popupClassName prop to RangePicker as dropdownClassName prop', () => { const popupClassName = 'myCustomClassName'; const { container } = render( , ); expect(container.querySelector(`.${popupClassName}`)).toBeTruthy(); }); it('should support bordered', () => { const { container } = render( , ); expect(container.firstChild).toMatchSnapshot(); }); });