From e8dff517bad67166da9e01db64efe42e673faff7 Mon Sep 17 00:00:00 2001 From: invalid w Date: Tue, 13 Aug 2024 20:58:47 +0800 Subject: [PATCH] fix(@vben/common-ui): text omission component expansion exception (#4139) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(@vben/common-ui): 修复文本省略组件展开异常 * chore: 增加点击展开切换的测试 --- .../__tests__/ellipsis-text.test.ts | 9 ++++- .../ellipsis-text/ellipsis-text.vue | 34 ++++++------------- 2 files changed, 19 insertions(+), 24 deletions(-) diff --git a/packages/effects/common-ui/src/components/ellipsis-text/__tests__/ellipsis-text.test.ts b/packages/effects/common-ui/src/components/ellipsis-text/__tests__/ellipsis-text.test.ts index b297c3c9..9e2d13b8 100644 --- a/packages/effects/common-ui/src/components/ellipsis-text/__tests__/ellipsis-text.test.ts +++ b/packages/effects/common-ui/src/components/ellipsis-text/__tests__/ellipsis-text.test.ts @@ -31,9 +31,16 @@ describe('ellipsis-text.vue', () => { default: 'This is a very long text that should be truncated.', }, }); - const ellipsis = wrapper.find('.truncate'); + + // 点击 ellipsis,应该触发 expandChange,参数为 false await ellipsis.trigger('click'); expect(wrapper.emitted('expandChange')).toBeTruthy(); + expect(wrapper.emitted('expandChange')?.[0]).toEqual([true]); + + // 再次点击,应该触发 expandChange,参数为 false + await ellipsis.trigger('click'); + expect(wrapper.emitted('expandChange')?.length).toBe(2); + expect(wrapper.emitted('expandChange')?.[1]).toEqual([false]); }); }); diff --git a/packages/effects/common-ui/src/components/ellipsis-text/ellipsis-text.vue b/packages/effects/common-ui/src/components/ellipsis-text/ellipsis-text.vue index f57cccc9..4455a00a 100644 --- a/packages/effects/common-ui/src/components/ellipsis-text/ellipsis-text.vue +++ b/packages/effects/common-ui/src/components/ellipsis-text/ellipsis-text.vue @@ -1,5 +1,5 @@