diff --git a/src/components/DatePicker.spec.ts b/src/components/DatePicker.spec.ts index 54fefe4..8d0ae95 100644 --- a/src/components/DatePicker.spec.ts +++ b/src/components/DatePicker.spec.ts @@ -68,6 +68,19 @@ describe('DatePicker', () => { expect(wrapper.emitted('update:modelValue')).toEqual([[null]]) }) + /** + * jsdom 不做布局,量不到真实高度,所以这里锁的是「机制」: + * 按钮必须靠 self-stretch 跟着整行走,而不是写死 py。 + * 曾经写死 py-1,比输入框矮 8px;输入框内边距一改还会再次错位。 + */ + it('清除按钮靠 self-stretch 对齐输入框高度,不写死内边距', () => { + const button = mountPicker('2026-10-20').find('button') + expect(button.classes()).toContain('self-stretch') + expect(button.classes()).toContain('items-center') + expect(button.classes()).not.toContain('py-1') + expect(button.classes()).not.toContain('py-1.5') + }) + it('默认带「截止日期」可访问性标签,可覆盖', () => { expect(mountPicker(null).find('input').attributes('aria-label')).toBe('截止日期') expect(mountPicker(null, '开始日期').find('input').attributes('aria-label')).toBe('开始日期') diff --git a/src/components/DatePicker.vue b/src/components/DatePicker.vue index 7ca1bc5..55ead3c 100644 --- a/src/components/DatePicker.vue +++ b/src/components/DatePicker.vue @@ -86,10 +86,14 @@ function openPicker(): void { +