From d87924489b489e522c45b33f97c3fb1c6bc0522f Mon Sep 17 00:00:00 2001 From: GweesinChan Date: Mon, 3 Mar 2025 21:03:24 +0800 Subject: [PATCH 1/2] style: lint code --- .../vue/src/badge/__tests__/badge.test.tsx | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/vue/src/badge/__tests__/badge.test.tsx b/packages/vue/src/badge/__tests__/badge.test.tsx index 1ff9ca5c75..74775e3e84 100644 --- a/packages/vue/src/badge/__tests__/badge.test.tsx +++ b/packages/vue/src/badge/__tests__/badge.test.tsx @@ -45,8 +45,7 @@ describe('PC Mode', () => { value={5} v-slots={{ content: () =>
自定义
- }} - > + }}> 自定义内容插槽 )) @@ -56,11 +55,15 @@ describe('PC Mode', () => { test('href', () => { const num = 1 const text = '跳转链接' - const wrapper = mount(() => {text}) + const wrapper = mount(() => ( + + {text} + + )) + expect(wrapper.find('.tiny-badge a').exists()).toBe(true) }) - test('default slot', () => { const wrapper = mount(() => { return ( @@ -69,7 +72,7 @@ describe('PC Mode', () => { v-slots={{ default: () =>
插槽内容
}} - > + /> ) }) expect(wrapper.find('.badge__default__slot').exists()).toBe(true) @@ -84,7 +87,7 @@ describe('PC Mode', () => { }, slots: { default: () =>
我的待办
- }, + } }) expect(wrapper.find('.tiny-badge').exists()).toBe(true) @@ -92,12 +95,13 @@ describe('PC Mode', () => { expect(wrapper.find('.badge__default__slot').text()).toEqual('我的待办') await wrapper.setProps({ value: 1 }) - await wrapper.setProps({ hidden: 1 === 0 }) + await wrapper.setProps({ hidden: false }) expect(wrapper.find('.tiny-badge').exists()).toBe(true) expect(wrapper.find('.tiny-badge__content-text').text()).toEqual('1') await wrapper.setProps({ value: 0 }) - await wrapper.setProps({ hidden: 0 === 0 }) + + await wrapper.setProps({ hidden: true }) expect(wrapper.find('.tiny-badge').exists()).toBe(false) }) }) From 9aa2e5133a8462437c367bdb7f92554c6a4c6e6a Mon Sep 17 00:00:00 2001 From: GweesinChan Date: Mon, 3 Mar 2025 21:56:47 +0800 Subject: [PATCH 2/2] fix(badge): fixed the incorrect dot badge style for values --- packages/vue/src/badge/__tests__/badge.test.tsx | 6 ++++++ packages/vue/src/badge/src/pc.vue | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/vue/src/badge/__tests__/badge.test.tsx b/packages/vue/src/badge/__tests__/badge.test.tsx index 74775e3e84..3a6a4b8d4d 100644 --- a/packages/vue/src/badge/__tests__/badge.test.tsx +++ b/packages/vue/src/badge/__tests__/badge.test.tsx @@ -104,4 +104,10 @@ describe('PC Mode', () => { await wrapper.setProps({ hidden: true }) expect(wrapper.find('.tiny-badge').exists()).toBe(false) }) + + test('is-dot with value', () => { + const wrapper = mount(() => ) + expect(wrapper.find('.tiny-badge').exists()).toBe(true) + expect(wrapper.find('.tiny-badge__content-text').text()).toBe('') + }) }) diff --git a/packages/vue/src/badge/src/pc.vue b/packages/vue/src/badge/src/pc.vue index e111ecbd01..4c95aa8eb0 100644 --- a/packages/vue/src/badge/src/pc.vue +++ b/packages/vue/src/badge/src/pc.vue @@ -26,7 +26,11 @@ > {{ state.content }} - {{ state.content }} + + +