Skip to content

Commit

Permalink
Merge pull request #459 from w2xi/test-components/badge
Browse files Browse the repository at this point in the history
test(components): [badge] cover remaining props
  • Loading branch information
Tyh2001 authored Apr 11, 2024
2 parents a0da3ed + bfbebb0 commit 3d6bd91
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions packages/fighting-design/badge/__test__/badge.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ describe('FBadge', () => {
test('class', () => {
const wrapper = mount(FBadge)
expect(wrapper.classes()).toContain('f-badge')
expect(wrapper.find('sup')).toBeDefined()
expect(wrapper.find('sup').classes()).toEqual(['f-badge__content'])
expect(wrapper.find('sup').classes()).toContain('f-badge__content')
})

test('type', () => {
Expand Down Expand Up @@ -47,13 +46,29 @@ describe('FBadge', () => {
props: { dot: true }
})
expect(wrapper.classes()).toContain('f-badge__dot')
expect(wrapper.find('sup').text()).toBe('')
})

test('dot with type', () => {
test('show', async () => {
const wrapper = mount(FBadge, {
props: { dot: true, type: 'success' }
props: { show: true }
})
expect(wrapper.classes()).toContain('f-badge__dot')
expect(wrapper.classes()).toContain('f-badge__success')
expect(wrapper.find('sup').exists()).toBeTruthy()
await wrapper.setProps({ show: false })
expect(wrapper.find('sup').exists()).toBeFalsy()
})

test('background', () => {
const wrapper = mount(FBadge, {
props: { background: 'orange' }
})
expect(wrapper.attributes('style')).toContain('--badge-background: orange')
})

test('color', () => {
const wrapper = mount(FBadge, {
props: { color: 'orange' }
})
expect(wrapper.attributes('style')).toContain('--badge-color: orange')
})
})

0 comments on commit 3d6bd91

Please sign in to comment.