2020-07-28 13:44:22 +08:00
|
|
|
import { mount } from '@vue/test-utils'
|
2020-07-24 22:22:21 +08:00
|
|
|
import Badge from '../src/index.vue'
|
|
|
|
|
|
|
|
const AXIOM = 'Rem is the best girl'
|
|
|
|
|
2020-07-25 13:54:19 +08:00
|
|
|
describe('Badge', () => {
|
|
|
|
test('has value', () => {
|
|
|
|
const wrapper = mount(Badge, {
|
2020-07-28 13:44:22 +08:00
|
|
|
props: { value: 80 },
|
2020-07-25 13:54:19 +08:00
|
|
|
})
|
|
|
|
expect(wrapper.vm.content).toEqual(80)
|
|
|
|
})
|
|
|
|
|
|
|
|
test('is fixed', () => {
|
|
|
|
const wrapper = mount(Badge, {
|
2020-07-28 13:44:22 +08:00
|
|
|
slots: { default: AXIOM },
|
2020-07-25 13:54:19 +08:00
|
|
|
})
|
|
|
|
expect(wrapper.find('.el-badge__content.is-fixed')).toBeDefined()
|
|
|
|
})
|
|
|
|
|
|
|
|
test('is dot', () => {
|
|
|
|
const wrapper = mount(Badge, {
|
2020-07-28 13:44:22 +08:00
|
|
|
props: { isDot: true },
|
|
|
|
slots: { default: AXIOM },
|
2020-07-25 13:54:19 +08:00
|
|
|
})
|
|
|
|
expect(wrapper.find('.el-badge__content.is-fixed')).toBeDefined()
|
|
|
|
})
|
|
|
|
|
|
|
|
test('max', async () => {
|
|
|
|
const wrapper = mount(Badge, {
|
2020-07-28 13:44:22 +08:00
|
|
|
props: { max: 100, value: 200 },
|
2020-07-25 13:54:19 +08:00
|
|
|
})
|
|
|
|
expect(wrapper.vm.content).toEqual('100+')
|
2020-07-28 13:44:22 +08:00
|
|
|
await wrapper.setProps({ value: 80 })
|
2020-07-25 13:54:19 +08:00
|
|
|
expect(wrapper.vm.content).toEqual(80)
|
2020-07-24 22:22:21 +08:00
|
|
|
})
|
|
|
|
})
|