Files
mes-ui-d2/tests/unit/d2-count-up.spec.js
孙昊翔 59c5ffd751 no message
Former-commit-id: faefc4c6e727523a2e3cfee920c7f6b2f0b059aa [formerly faefc4c6e727523a2e3cfee920c7f6b2f0b059aa [formerly faefc4c6e727523a2e3cfee920c7f6b2f0b059aa [formerly faefc4c6e727523a2e3cfee920c7f6b2f0b059aa [formerly bdde2f0b3e39efac98f19601130b7ad9277284ab [formerly bc029c9b4beffa1cbfb2cf770a095fd02ae76b62]]]]]
Former-commit-id: b8e2d229a71661a8450363150629f205ad8a1fee
Former-commit-id: 3c4084ff94884082ad4e7f9b620b0270285ac56b
Former-commit-id: 2631c293b256421423f26b01acfe6fc7e7f81153 [formerly 04739fef9aea219063b7683b0f7396fb969c2275]
Former-commit-id: 5306047eae9b783386d3090cdf9f9431d4b57deb
Former-commit-id: 1d04632c22798a967256c7a5e6b5392f62c07e54
Former-commit-id: 437f55ac3308b54cf5e0c3ed0e8bf258fc4acb09
Former-commit-id: 340153cd8d7760323a6df93c9513f935b13d9440
Former-commit-id: c472df368e6f81c21531fd40f1fd09c440b337ac
2019-01-05 10:18:44 +08:00

73 lines
1.5 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { mount } from '@vue/test-utils'
import D2CountUp from '@/components/d2-count-up/index.vue'
describe('d2-count-up', () => {
// 存在且是Vue组件实例
it('is a vue instance', () => {
const wrapper = mount(D2CountUp, {
propsData: {
end: 100
}
})
expect(wrapper.exists()).toBeTruthy()
expect(wrapper.isVueInstance()).toBeTruthy()
})
// props
it('has props', () => {
const wrapper = mount(D2CountUp, {
propsData: {
start: 0,
end: 100,
decimals: 0,
duration: 2,
options: {}
}
})
expect(wrapper.props().start).toEqual(0)
expect(wrapper.props().end).toEqual(100)
expect(wrapper.props().decimals).toEqual(0)
expect(wrapper.props().duration).toEqual(2)
expect(wrapper.props().options).toEqual({})
})
// 开始数字1秒后结束数字
it('start number is 1, 1s later, end number is 99', (done) => {
const wrapper = mount(D2CountUp, {
propsData: {
start: 1,
end: 99,
duration: 1
}
})
expect(wrapper.text()).toBe('1')
setTimeout(() => {
expect(wrapper.text()).toBe('99')
done()
}, 1100)
})
// 小数位数
it('start number is 1.00, 1s later, end number is 99.00', (done) => {
const wrapper = mount(D2CountUp, {
propsData: {
start: 1,
end: 99,
decimals: 2,
duration: 1
}
})
expect(wrapper.text()).toBe('1.00')
setTimeout(() => {
expect(wrapper.text()).toBe('99.00')
done()
}, 1100)
})
})