feat(Calendar): add allow-same-day prop (#5688)
This commit is contained in:
@@ -82,6 +82,7 @@ test('select event when type is multiple', async () => {
|
||||
const days = wrapper.findAll('.van-calendar__day');
|
||||
days.at(15).trigger('click');
|
||||
days.at(16).trigger('click');
|
||||
days.at(17).trigger('click');
|
||||
|
||||
await later();
|
||||
days.at(15).trigger('click');
|
||||
@@ -93,7 +94,10 @@ test('select event when type is multiple', async () => {
|
||||
'2010/1/10,2010/1/16,2010/1/17'
|
||||
);
|
||||
expect(formatMultiple(emittedSelect[2][0])).toEqual(
|
||||
'2010/1/10,2010/1/17,2010/1/13'
|
||||
'2010/1/10,2010/1/16,2010/1/17,2010/1/18'
|
||||
);
|
||||
expect(formatMultiple(emittedSelect[3][0])).toEqual(
|
||||
'2010/1/10,2010/1/17,2010/1/18,2010/1/13'
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -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]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user