mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2024-12-21 04:50:14 +08:00
test(badge): add badge test (#757)
This commit is contained in:
parent
a1a353519a
commit
ff5e302f0a
@ -5,4 +5,53 @@ describe('n-badge', () => {
|
||||
it('should work with import on demand', () => {
|
||||
mount(NBadge)
|
||||
})
|
||||
|
||||
it('should work with `dot` prop', async () => {
|
||||
const wrapper = mount(NBadge, { props: { value: 5 } })
|
||||
expect(wrapper.find('.n-badge').classes('n-badge--dot')).not.toBe(true)
|
||||
expect(wrapper.find('.n-base-slot-machine').exists()).toBe(true)
|
||||
|
||||
await wrapper.setProps({ dot: true })
|
||||
expect(wrapper.find('.n-badge').classes('n-badge--dot')).toBe(true)
|
||||
expect(wrapper.find('.n-base-slot-machine').exists()).not.toBe(true)
|
||||
})
|
||||
|
||||
it('should work with `color` prop', async () => {
|
||||
const wrapper = mount(NBadge, { props: { value: 5, color: 'grey' } })
|
||||
expect(wrapper.find('.n-badge').attributes('style')).toContain(
|
||||
'--color: grey;'
|
||||
)
|
||||
})
|
||||
|
||||
it('should work with `max` prop', async () => {
|
||||
const wrapper = mount(NBadge, { props: { value: 5, max: 5 } })
|
||||
expect(
|
||||
wrapper
|
||||
.find('.n-base-slot-machine-current-number__inner--not-number')
|
||||
.exists()
|
||||
).not.toBe(true)
|
||||
|
||||
await wrapper.setProps({ value: 6 })
|
||||
expect(
|
||||
wrapper
|
||||
.find('.n-base-slot-machine-current-number__inner--not-number')
|
||||
.exists()
|
||||
).toBe(true)
|
||||
})
|
||||
|
||||
it('should work with `processing` prop', async () => {
|
||||
const wrapper = mount(NBadge, { props: { value: 5 } })
|
||||
expect(wrapper.find('.n-base-wave').exists()).not.toBe(true)
|
||||
|
||||
await wrapper.setProps({ processing: true })
|
||||
expect(wrapper.find('.n-base-wave').exists()).toBe(true)
|
||||
})
|
||||
|
||||
it('should work with `show-zero` prop', async () => {
|
||||
const wrapper = mount(NBadge, { props: { value: 0 } })
|
||||
expect(wrapper.find('.n-badge-sup').exists()).not.toBe(true)
|
||||
|
||||
await wrapper.setProps({ 'show-zero': true })
|
||||
expect(wrapper.find('.n-badge-sup').exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user