diff --git a/src/packages/__VUE/calendarcard/__tests__/calendarcard.spec.tsx b/src/packages/__VUE/calendarcard/__tests__/calendarcard.spec.tsx index a4f47e78b7..20b5aee4f6 100644 --- a/src/packages/__VUE/calendarcard/__tests__/calendarcard.spec.tsx +++ b/src/packages/__VUE/calendarcard/__tests__/calendarcard.spec.tsx @@ -1,6 +1,6 @@ import { mount } from '@vue/test-utils'; import CalendarCard from '..'; -import { nextTick } from 'vue'; +import { nextTick, ref } from 'vue'; import { CalendarCardDay } from '../types'; test('CalendarCard: test defaultValue mount(() => ', async () => { @@ -72,11 +72,19 @@ test('CalendarCard: test type multiple', async () => { }); test('CalendarCard: test type range', async () => { - const wrapper = mount(() => ); + const val = ref([new Date('2023-01-25')]); + const wrapper = mount(() => ); // current const currentDays = wrapper.findAll('.nut-calendarcard-day.current'); - currentDays[1].trigger('click'); // 0102 + const active = wrapper.findAll('.nut-calendarcard-day.active'); + expect(active.length).toBe(1); + + currentDays[24].trigger('click'); // 0125 + await nextTick(); + const startAndEnd = wrapper.findAll('.nut-calendarcard-day.start.end'); + expect(startAndEnd.length).toBe(1); + currentDays[3].trigger('click'); // 0104 currentDays[8].trigger('click'); // 0109 await nextTick(); diff --git a/src/packages/__VUE/calendarcard/calendar-card.taro.vue b/src/packages/__VUE/calendarcard/calendar-card.taro.vue index 51ed19b8bd..78023e77f5 100644 --- a/src/packages/__VUE/calendarcard/calendar-card.taro.vue +++ b/src/packages/__VUE/calendarcard/calendar-card.taro.vue @@ -318,7 +318,7 @@ const handleDayClick = (day: CalendarCardDay) => { change([day]); } else if (len === 1) { const t = compareDay(innerValue.value[0], day); - if (t === 0 || t === null || t === undefined) { + if (t === null || t === undefined) { change([]); } else if (t < 0) { change([innerValue.value[0], day]); diff --git a/src/packages/__VUE/calendarcard/calendar-card.vue b/src/packages/__VUE/calendarcard/calendar-card.vue index 065f8b93e9..2aa0a0bb75 100644 --- a/src/packages/__VUE/calendarcard/calendar-card.vue +++ b/src/packages/__VUE/calendarcard/calendar-card.vue @@ -318,7 +318,7 @@ const handleDayClick = (day: CalendarCardDay) => { change([day]); } else if (len === 1) { const t = compareDay(innerValue.value[0], day); - if (t === 0 || t === null || t === undefined) { + if (t === null || t === undefined) { change([]); } else if (t < 0) { change([innerValue.value[0], day]);