test(badge): add badge test (#757)

This commit is contained in:
XieZongChen 2021-08-02 03:30:34 -05:00 committed by GitHub
parent a1a353519a
commit ff5e302f0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)
})
})