feat(Calendar): add allow-same-day prop (#5688)

This commit is contained in:
chenjiahan
2020-03-17 19:37:12 +08:00
parent 8d6adce9a2
commit 0a3ed53187
13 changed files with 68 additions and 13 deletions
+30
View File
@@ -64,3 +64,33 @@ test('hide close icon when there is no title', () => {
});
expect(wrapper.contains('.van-popup__close-icon')).toBeFalsy();
});
test('allow-same-day prop', async () => {
const select = jest.fn();
const wrapper = mount(Calendar, {
propsData: {
type: 'range',
minDate,
maxDate,
poppable: false,
},
listeners: {
select,
},
});
await later();
const days = wrapper.findAll('.van-calendar__day');
days.at(9).trigger('click');
days.at(9).trigger('click');
expect(select).toHaveBeenLastCalledWith([minDate, null]);
wrapper.setProps({
allowSameDay: true,
});
days.at(9).trigger('click');
expect(select).toHaveBeenLastCalledWith([minDate, minDate]);
});