diff --git a/components/calendar/__tests__/index.test.js b/components/calendar/__tests__/index.test.js
index 33dc25d249..957031d259 100644
--- a/components/calendar/__tests__/index.test.js
+++ b/components/calendar/__tests__/index.test.js
@@ -10,6 +10,7 @@ import Group from '../../radio/group';
import Button from '../../radio/radioButton';
import mountTest from '../../../tests/shared/mountTest';
import rtlTest from '../../../tests/shared/rtlTest';
+import { render, fireEvent } from '../../../tests/utils';
describe('Calendar', () => {
mountTest(Calendar);
@@ -40,14 +41,21 @@ describe('Calendar', () => {
});
it('Calendar should be selectable', () => {
+ MockDate.set(Moment('2000-01-01').valueOf());
+
const onSelect = jest.fn();
const onChange = jest.fn();
- const wrapper = mount();
- wrapper.find('.ant-picker-cell').at(0).simulate('click');
+ const { container } = render();
+
+ fireEvent.click(container.querySelector('.ant-picker-cell'));
expect(onSelect).toHaveBeenCalledWith(expect.anything());
+
const value = onSelect.mock.calls[0][0];
expect(Moment.isMoment(value)).toBe(true);
+
expect(onChange).toHaveBeenCalled();
+
+ MockDate.reset();
});
it('only Valid range should be selectable', () => {
diff --git a/components/calendar/generateCalendar.tsx b/components/calendar/generateCalendar.tsx
index f31fff7936..e6c6d4a473 100644
--- a/components/calendar/generateCalendar.tsx
+++ b/components/calendar/generateCalendar.tsx
@@ -139,6 +139,8 @@ function generateCalendar(generateConfig: GenerateConfig) {
};
const triggerChange = (date: DateType) => {
+ console.log('trigger change!!!', isSameDate(date, mergedValue));
+ console.log('trigger change!!!', String(date), String(mergedValue));
setMergedValue(date);
if (!isSameDate(date, mergedValue)) {