mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-05 05:42:44 +08:00
fix(Calendar): fix getInitialDate function error (#13075)
Co-authored-by: neverland <jait.chen@foxmail.com>
This commit is contained in:
parent
8aeeba497e
commit
8dd13eae11
@ -165,6 +165,11 @@ export default defineComponent({
|
||||
defaultDate = [];
|
||||
}
|
||||
|
||||
// reset invalid default date
|
||||
if (defaultDate.length === 1 && compareDay(defaultDate[0], now) === 1) {
|
||||
defaultDate = [];
|
||||
}
|
||||
|
||||
const min = minDate.value;
|
||||
const max = maxDate.value;
|
||||
|
||||
|
@ -655,3 +655,19 @@ test('should render confirm-text slot correctly', async () => {
|
||||
|
||||
expect(wrapper.find('.van-calendar__confirm').html()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('the defaultDate length of 1 should be handled correctly', async () => {
|
||||
const wrapper = mount(Calendar, {
|
||||
props: {
|
||||
poppable: false,
|
||||
defaultDate: [getNextDay(now)],
|
||||
type: 'range',
|
||||
},
|
||||
});
|
||||
|
||||
wrapper.find('.van-calendar__confirm').trigger('click');
|
||||
expect(wrapper.emitted<[Date]>('confirm')![0][0]).toEqual([
|
||||
now,
|
||||
getNextDay(now),
|
||||
]);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user