From 9f42ce8694d962ecc3b19d0a55790d7a2373d4f5 Mon Sep 17 00:00:00 2001 From: LIUCHAO <50739490+Tsong-LC@users.noreply.github.com> Date: Mon, 4 Jul 2022 21:41:15 +0800 Subject: [PATCH] fix(components): [date-picker] disabled year not selectable (#8414) closed #8409 --- .../date-picker/__tests__/date-picker.test.ts | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/packages/components/date-picker/__tests__/date-picker.test.ts b/packages/components/date-picker/__tests__/date-picker.test.ts index bcd8608ecd..416dda43f9 100644 --- a/packages/components/date-picker/__tests__/date-picker.test.ts +++ b/packages/components/date-picker/__tests__/date-picker.test.ts @@ -1482,4 +1482,38 @@ describe('MonthRange', () => { expect(formItem.attributes().role).toBe('group') }) }) + + it('The year which is disabled should not be selectable', async () => { + const pickHandler = vi.fn() + const wrapper = _mount( + ``, + () => ({ + yearValue: '2022', + validateYear: (date) => { + if (date.getFullYear() > 2022) { + return true + } else { + return false + } + }, + onPick(e) { + return pickHandler(e) + }, + }) + ) + const input = wrapper.find('input') + input.trigger('focus') + await nextTick() + ;(document.querySelector('td.disabled') as HTMLElement).click() + await nextTick() + expect(pickHandler).toHaveBeenCalledTimes(0) + ;(document.querySelector('td.available') as HTMLElement).click() + await nextTick() + expect(pickHandler).toHaveBeenCalledTimes(1) + }) })