|
@ -10,6 +10,7 @@ import Group from '../../radio/group'; |
|
|
import Button from '../../radio/radioButton'; |
|
|
import Button from '../../radio/radioButton'; |
|
|
import mountTest from '../../../tests/shared/mountTest'; |
|
|
import mountTest from '../../../tests/shared/mountTest'; |
|
|
import rtlTest from '../../../tests/shared/rtlTest'; |
|
|
import rtlTest from '../../../tests/shared/rtlTest'; |
|
|
|
|
|
import { render, fireEvent } from '../../../tests/utils'; |
|
|
|
|
|
|
|
|
describe('Calendar', () => { |
|
|
describe('Calendar', () => { |
|
|
mountTest(Calendar); |
|
|
mountTest(Calendar); |
|
@ -40,14 +41,21 @@ describe('Calendar', () => { |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
it('Calendar should be selectable', () => { |
|
|
it('Calendar should be selectable', () => { |
|
|
|
|
|
MockDate.set(Moment('2000-01-01').valueOf()); |
|
|
|
|
|
|
|
|
const onSelect = jest.fn(); |
|
|
const onSelect = jest.fn(); |
|
|
const onChange = jest.fn(); |
|
|
const onChange = jest.fn(); |
|
|
const wrapper = mount(<Calendar onSelect={onSelect} onChange={onChange} />); |
|
|
const { container } = render(<Calendar onSelect={onSelect} onChange={onChange} />); |
|
|
wrapper.find('.ant-picker-cell').at(0).simulate('click'); |
|
|
|
|
|
|
|
|
fireEvent.click(container.querySelector('.ant-picker-cell')); |
|
|
expect(onSelect).toHaveBeenCalledWith(expect.anything()); |
|
|
expect(onSelect).toHaveBeenCalledWith(expect.anything()); |
|
|
|
|
|
|
|
|
const value = onSelect.mock.calls[0][0]; |
|
|
const value = onSelect.mock.calls[0][0]; |
|
|
expect(Moment.isMoment(value)).toBe(true); |
|
|
expect(Moment.isMoment(value)).toBe(true); |
|
|
|
|
|
|
|
|
expect(onChange).toHaveBeenCalled(); |
|
|
expect(onChange).toHaveBeenCalled(); |
|
|
|
|
|
|
|
|
|
|
|
MockDate.reset(); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
it('only Valid range should be selectable', () => { |
|
|
it('only Valid range should be selectable', () => { |
|
|