test(components): [badge] complete test cases (#17628)

This commit is contained in:
chouchouji 2024-07-24 13:39:19 +08:00 committed by GitHub
parent 213b489c29
commit ff5ba6a764
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -94,4 +94,43 @@ describe('Badge', () => {
await nextTick()
expect(wrapper.find('.el-badge__content').text()).toEqual('-1+')
})
test('color', () => {
const badgeValue = ref(20)
const wrapper = mount(() => <Badge value={badgeValue.value} color="blue" />)
expect(wrapper.find('.el-badge__content').attributes('style')).toContain(
'background-color: blue'
)
})
test('badgeStyle', () => {
const badgeValue = ref(20)
const wrapper = mount(() => (
<Badge value={badgeValue.value} badgeStyle={{ background: 'blue' }} />
))
expect(wrapper.find('.el-badge__content').attributes('style')).toContain(
'background: blue'
)
})
test('badgeClass', () => {
const badgeValue = ref(20)
const wrapper = mount(() => (
<Badge value={badgeValue.value} badgeClass="test-badge-class" />
))
expect(wrapper.find('.test-badge-class').exists()).toBe(true)
})
test('offset', () => {
const badgeValue = ref(20)
const wrapper = mount(() => (
<Badge value={badgeValue.value} offset={[10, 10]} />
))
expect(wrapper.find('.el-badge__content').attributes('style')).toContain(
'margin-right: -10px'
)
expect(wrapper.find('.el-badge__content').attributes('style')).toContain(
'margin-top: 10px'
)
})
})