unit test: d2-count-up
Former-commit-id: a4acc0021635513dbaa33d55a4e9ed4b0022dc9d [formerly a4acc0021635513dbaa33d55a4e9ed4b0022dc9d [formerly a4acc0021635513dbaa33d55a4e9ed4b0022dc9d [formerly a4acc0021635513dbaa33d55a4e9ed4b0022dc9d [formerly 108b6440007edfaa758005622c935b53d1608015 [formerly 623ddae983522b2475b7fd6d3bcce69c981079ec]]]]] Former-commit-id: 057065402397ae93d4a60415b8c056161608461b Former-commit-id: e9938c5514818c1b0e6e224a000cb888f5b704f2 Former-commit-id: af905c62535a6a00e6a4325bdcda06ab07f5d793 [formerly 598b5cc95bc01db05a3ffdb184c312670ca6bdc1] Former-commit-id: bb1cdabc4436ea871f0bee153304ea039b4cb711 Former-commit-id: e7fbf5cb746ed3329d3b044e3ddbe1b074c06b68 Former-commit-id: 21c5ec79779a24df010d33e0058706596a3d622b Former-commit-id: 2a0211c9e99d4bbb0abf897867dfa3cd53ae60d2 Former-commit-id: abb484aa78b08668d297bd6bef1a7e2dadceb37f
This commit is contained in:
parent
4ef91111e3
commit
cc87950772
|
|
@ -13,4 +13,60 @@ describe('d2-count-up.vue', () => {
|
||||||
expect(wrapper.exists()).toBeTruthy()
|
expect(wrapper.exists()).toBeTruthy()
|
||||||
expect(wrapper.isVueInstance()).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)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
import { mount, createLocalVue } from '@vue/test-utils'
|
||||||
|
import D2IconSelect from '@/components/d2-icon-select/index.vue'
|
||||||
|
import ElementUI from 'element-ui'
|
||||||
|
|
||||||
|
describe('d2-icon-select.vue', () => {
|
||||||
|
const localVue = createLocalVue()
|
||||||
|
localVue.use(ElementUI)
|
||||||
|
|
||||||
|
// 存在且是Vue组件实例
|
||||||
|
it('is a vue instance', () => {
|
||||||
|
const wrapper = mount(D2IconSelect, {
|
||||||
|
stubs: ['el-popover', 'el-button', 'el-input', 'el-collapse', 'el-collapse-item', 'el-col', 'el-row']
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(wrapper.exists()).toBeTruthy()
|
||||||
|
expect(wrapper.isVueInstance()).toBeTruthy()
|
||||||
|
})
|
||||||
|
|
||||||
|
// // props
|
||||||
|
// it('has props', () => {
|
||||||
|
// const wrapper = mount(D2IconSelect, {
|
||||||
|
// propsData: {
|
||||||
|
// value: 'value',
|
||||||
|
// placeholder: '请选择',
|
||||||
|
// placement: 'right',
|
||||||
|
// clearable: true,
|
||||||
|
// userInput: false,
|
||||||
|
// autoClose: false
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
|
||||||
|
// expect(wrapper.props().value).toEqual('value')
|
||||||
|
// expect(wrapper.props().placeholder).toEqual('请选择')
|
||||||
|
// expect(wrapper.props().placement).toEqual('right')
|
||||||
|
// expect(wrapper.props().clearable).toEqual(true)
|
||||||
|
// expect(wrapper.props().userInput).toEqual(false)
|
||||||
|
// expect(wrapper.props().autoClose).toEqual(false)
|
||||||
|
// })
|
||||||
|
})
|
||||||
|
|
@ -13,7 +13,7 @@ describe('d2-source.vue', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
// 包含特定类名
|
// 包含特定类名
|
||||||
it('contains specific classnames', () => {
|
it('contains specific classnames', (done) => {
|
||||||
const wrapper = mount(D2Source, {
|
const wrapper = mount(D2Source, {
|
||||||
stubs: ['d2-icon']
|
stubs: ['d2-icon']
|
||||||
})
|
})
|
||||||
|
|
@ -21,7 +21,8 @@ describe('d2-source.vue', () => {
|
||||||
expect(wrapper.is('.d2-source')).toBeTruthy()
|
expect(wrapper.is('.d2-source')).toBeTruthy()
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
expect(wrapper.contains('.d2-source--active')).toBeTruthy()
|
expect(wrapper.contains('.d2-source--active')).toBeTruthy()
|
||||||
}, 500)
|
done()
|
||||||
|
}, 600)
|
||||||
})
|
})
|
||||||
|
|
||||||
// filename prop
|
// filename prop
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue