Merge tag 'test_unit' into develop
no message Former-commit-id: 41a31d965279f2776840f9c951e466f533ff09b0 [formerly 41a31d965279f2776840f9c951e466f533ff09b0 [formerly 41a31d965279f2776840f9c951e466f533ff09b0 [formerly 41a31d965279f2776840f9c951e466f533ff09b0 [formerly ffa42e4bc23dcbe274158c7e55c54cf6f1c55d56 [formerly 531b99327d43850d77ece49368a480b9ad4e4f45]]]]] Former-commit-id: 00dde9995ed33882bfeec21ed929d33c1ee4be38 Former-commit-id: 1e7c98c7865c00aac9a948df58076e91cf784e47 Former-commit-id: b25d9b8edace6c73c5b1841a2f42410ab1d7d028 [formerly 007ac04e8f37ae9c9d7a25c944cee02c7942b71f] Former-commit-id: 2ae2dfa1a427892b43f047a4c9a83cffb67b2d44 Former-commit-id: 4de15fbc5ec525c7dbb93eae372bc4567f45a21e Former-commit-id: 80fd1f241a7f28d3ee2a0eb8429a7976c8724bed Former-commit-id: 1887eae73e3dd4af259b00d60a259edb8f2da883 Former-commit-id: 5638a89a61369761cb43abf9300031f303be6ede
This commit is contained in:
@@ -56,10 +56,10 @@
|
||||
"@kazupon/vue-i18n-loader": "^0.3.0",
|
||||
"@vue/cli-plugin-babel": "^3.0.0",
|
||||
"@vue/cli-plugin-eslint": "^3.0.0",
|
||||
"@vue/cli-plugin-unit-jest": "^3.0.0",
|
||||
"@vue/cli-plugin-unit-jest": "^3.2.3",
|
||||
"@vue/cli-service": "^3.0.0",
|
||||
"@vue/eslint-config-standard": "^3.0.0",
|
||||
"@vue/test-utils": "^1.0.0-beta.20",
|
||||
"@vue/test-utils": "^1.0.0-beta.28",
|
||||
"babel-core": "7.0.0-bridge.0",
|
||||
"babel-jest": "^23.0.1",
|
||||
"lint-staged": "^7.2.0",
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
// 暂时 D2 没有单元测试代码 此文件为自动生成
|
||||
|
||||
import { shallowMount } from '@vue/test-utils'
|
||||
import HelloWorld from '@/components/HelloWorld.vue'
|
||||
|
||||
describe('HelloWorld.vue', () => {
|
||||
it('renders props.msg when passed', () => {
|
||||
const msg = 'new message'
|
||||
const wrapper = shallowMount(HelloWorld, {
|
||||
propsData: { msg }
|
||||
})
|
||||
expect(wrapper.text()).toMatch(msg)
|
||||
})
|
||||
})
|
||||
55
tests/unit/d2-container-card-bs.spec.js
Normal file
55
tests/unit/d2-container-card-bs.spec.js
Normal file
@@ -0,0 +1,55 @@
|
||||
import { mount } from '@vue/test-utils'
|
||||
import D2ContainerCardBs from '@/components/d2-container/components/d2-container-card-bs.vue'
|
||||
|
||||
describe('d2-container-card-bs', () => {
|
||||
// 存在且是Vue组件实例
|
||||
it('is a vue instance', () => {
|
||||
const wrapper = mount(D2ContainerCardBs)
|
||||
|
||||
expect(wrapper.exists()).toBeTruthy()
|
||||
expect(wrapper.isVueInstance()).toBeTruthy()
|
||||
})
|
||||
|
||||
// 包含特定类名
|
||||
it('contains specific classnames', () => {
|
||||
const wrapper = mount(D2ContainerCardBs, {
|
||||
slots: {
|
||||
default: '<div>body</div>',
|
||||
header: '<div>header</div>',
|
||||
footer: '<div>footer</div>'
|
||||
}
|
||||
})
|
||||
|
||||
expect(wrapper.is('.d2-container-card-bs')).toBeTruthy()
|
||||
expect(wrapper.contains('.d2-container-card-bs__header')).toBeTruthy()
|
||||
expect(wrapper.contains('.d2-container-card-bs__body')).toBeTruthy()
|
||||
expect(wrapper.contains('.d2-container-card-bs__body-card')).toBeTruthy()
|
||||
expect(wrapper.contains('.d2-container-card-bs__footer')).toBeTruthy()
|
||||
})
|
||||
|
||||
// props
|
||||
it('has props', () => {
|
||||
const wrapper = mount(D2ContainerCardBs, {
|
||||
propsData: {
|
||||
betterScrollOptions: {}
|
||||
}
|
||||
})
|
||||
|
||||
expect(wrapper.props().betterScrollOptions).toEqual({})
|
||||
})
|
||||
|
||||
// 渲染slot
|
||||
it('has one or more slots', () => {
|
||||
const wrapper = mount(D2ContainerCardBs, {
|
||||
slots: {
|
||||
default: '<div>body</div>',
|
||||
header: '<div>header</div>',
|
||||
footer: '<div>footer</div>'
|
||||
}
|
||||
})
|
||||
|
||||
expect(wrapper.text()).toMatch('header')
|
||||
expect(wrapper.text()).toMatch('body')
|
||||
expect(wrapper.text()).toMatch('footer')
|
||||
})
|
||||
})
|
||||
55
tests/unit/d2-container-card.spec.js
Normal file
55
tests/unit/d2-container-card.spec.js
Normal file
@@ -0,0 +1,55 @@
|
||||
import { mount } from '@vue/test-utils'
|
||||
import D2ContainerCard from '@/components/d2-container/components/d2-container-card.vue'
|
||||
|
||||
describe('d2-container-card', () => {
|
||||
// 存在且是Vue组件实例
|
||||
it('is a vue instance', () => {
|
||||
const wrapper = mount(D2ContainerCard)
|
||||
|
||||
expect(wrapper.exists()).toBeTruthy()
|
||||
expect(wrapper.isVueInstance()).toBeTruthy()
|
||||
})
|
||||
|
||||
// 包含特定类名
|
||||
it('contains specific classnames', () => {
|
||||
const wrapper = mount(D2ContainerCard, {
|
||||
slots: {
|
||||
default: '<div>body</div>',
|
||||
header: '<div>header</div>',
|
||||
footer: '<div>footer</div>'
|
||||
}
|
||||
})
|
||||
|
||||
expect(wrapper.is('.d2-container-card')).toBeTruthy()
|
||||
expect(wrapper.contains('.d2-container-card__header')).toBeTruthy()
|
||||
expect(wrapper.contains('.d2-container-card__body')).toBeTruthy()
|
||||
expect(wrapper.contains('.d2-container-card__body-card')).toBeTruthy()
|
||||
expect(wrapper.contains('.d2-container-card__footer')).toBeTruthy()
|
||||
})
|
||||
|
||||
// props
|
||||
it('has props', () => {
|
||||
const wrapper = mount(D2ContainerCard, {
|
||||
propsData: {
|
||||
scrollDelay: 30
|
||||
}
|
||||
})
|
||||
|
||||
expect(wrapper.props().scrollDelay).toEqual(30)
|
||||
})
|
||||
|
||||
// 渲染slot
|
||||
it('has one or more slots', () => {
|
||||
const wrapper = mount(D2ContainerCard, {
|
||||
slots: {
|
||||
default: '<div>body</div>',
|
||||
header: '<div>header</div>',
|
||||
footer: '<div>footer</div>'
|
||||
}
|
||||
})
|
||||
|
||||
expect(wrapper.text()).toMatch('header')
|
||||
expect(wrapper.text()).toMatch('body')
|
||||
expect(wrapper.text()).toMatch('footer')
|
||||
})
|
||||
})
|
||||
35
tests/unit/d2-container-frame.spec.js
Normal file
35
tests/unit/d2-container-frame.spec.js
Normal file
@@ -0,0 +1,35 @@
|
||||
import { mount } from '@vue/test-utils'
|
||||
import D2ContainerFrame from '@/components/d2-container-frame/index.vue'
|
||||
|
||||
describe('d2-container-frame', () => {
|
||||
// 存在且是Vue组件实例
|
||||
it('is a vue instance', () => {
|
||||
const wrapper = mount(D2ContainerFrame, {
|
||||
stubs: ['d2-container']
|
||||
})
|
||||
|
||||
expect(wrapper.exists()).toBeTruthy()
|
||||
expect(wrapper.isVueInstance()).toBeTruthy()
|
||||
})
|
||||
|
||||
// 包含特定类名
|
||||
it('contains specific classnames', () => {
|
||||
const wrapper = mount(D2ContainerFrame, {
|
||||
stubs: ['d2-container']
|
||||
})
|
||||
|
||||
expect(wrapper.contains('.d2-container-frame')).toBeTruthy()
|
||||
})
|
||||
|
||||
// props
|
||||
it('has props', () => {
|
||||
const wrapper = mount(D2ContainerFrame, {
|
||||
stubs: ['d2-container'],
|
||||
propsData: {
|
||||
src: 'https://doc.d2admin.fairyever.com/zh/'
|
||||
}
|
||||
})
|
||||
|
||||
expect(wrapper.props().src).toEqual('https://doc.d2admin.fairyever.com/zh/')
|
||||
})
|
||||
})
|
||||
55
tests/unit/d2-container-full-bs.spec.js
Normal file
55
tests/unit/d2-container-full-bs.spec.js
Normal file
@@ -0,0 +1,55 @@
|
||||
import { mount } from '@vue/test-utils'
|
||||
import D2ContainerFullBs from '@/components/d2-container/components/d2-container-full-bs.vue'
|
||||
|
||||
describe('d2-container-full-bs', () => {
|
||||
// 存在且是Vue组件实例
|
||||
it('is a vue instance', () => {
|
||||
const wrapper = mount(D2ContainerFullBs)
|
||||
|
||||
expect(wrapper.exists()).toBeTruthy()
|
||||
expect(wrapper.isVueInstance()).toBeTruthy()
|
||||
})
|
||||
|
||||
// 包含特定类名
|
||||
it('contains specific classnames', () => {
|
||||
const wrapper = mount(D2ContainerFullBs, {
|
||||
slots: {
|
||||
default: '<div>body</div>',
|
||||
header: '<div>header</div>',
|
||||
footer: '<div>footer</div>'
|
||||
}
|
||||
})
|
||||
|
||||
expect(wrapper.is('.d2-container-full-bs')).toBeTruthy()
|
||||
expect(wrapper.contains('.d2-container-full-bs__header')).toBeTruthy()
|
||||
expect(wrapper.contains('.d2-container-full-bs__body')).toBeTruthy()
|
||||
expect(wrapper.contains('.d2-container-full-bs__body-wrapper-inner')).toBeTruthy()
|
||||
expect(wrapper.contains('.d2-container-full-bs__footer')).toBeTruthy()
|
||||
})
|
||||
|
||||
// props
|
||||
it('has props', () => {
|
||||
const wrapper = mount(D2ContainerFullBs, {
|
||||
propsData: {
|
||||
betterScrollOptions: {}
|
||||
}
|
||||
})
|
||||
|
||||
expect(wrapper.props().betterScrollOptions).toEqual({})
|
||||
})
|
||||
|
||||
// 渲染slot
|
||||
it('has one or more slots', () => {
|
||||
const wrapper = mount(D2ContainerFullBs, {
|
||||
slots: {
|
||||
default: '<div>body</div>',
|
||||
header: '<div>header</div>',
|
||||
footer: '<div>footer</div>'
|
||||
}
|
||||
})
|
||||
|
||||
expect(wrapper.text()).toMatch('header')
|
||||
expect(wrapper.text()).toMatch('body')
|
||||
expect(wrapper.text()).toMatch('footer')
|
||||
})
|
||||
})
|
||||
54
tests/unit/d2-container-full.spec.js
Normal file
54
tests/unit/d2-container-full.spec.js
Normal file
@@ -0,0 +1,54 @@
|
||||
import { mount } from '@vue/test-utils'
|
||||
import D2ContainerFull from '@/components/d2-container/components/d2-container-full.vue'
|
||||
|
||||
describe('d2-container-full', () => {
|
||||
// 存在且是Vue组件实例
|
||||
it('is a vue instance', () => {
|
||||
const wrapper = mount(D2ContainerFull)
|
||||
|
||||
expect(wrapper.exists()).toBeTruthy()
|
||||
expect(wrapper.isVueInstance()).toBeTruthy()
|
||||
})
|
||||
|
||||
// 包含特定类名
|
||||
it('contains specific classnames', () => {
|
||||
const wrapper = mount(D2ContainerFull, {
|
||||
slots: {
|
||||
default: '<div>body</div>',
|
||||
header: '<div>header</div>',
|
||||
footer: '<div>footer</div>'
|
||||
}
|
||||
})
|
||||
|
||||
expect(wrapper.is('.d2-container-full')).toBeTruthy()
|
||||
expect(wrapper.contains('.d2-container-full__header')).toBeTruthy()
|
||||
expect(wrapper.contains('.d2-container-full__body')).toBeTruthy()
|
||||
expect(wrapper.contains('.d2-container-full__footer')).toBeTruthy()
|
||||
})
|
||||
|
||||
// props
|
||||
it('has props', () => {
|
||||
const wrapper = mount(D2ContainerFull, {
|
||||
propsData: {
|
||||
scrollDelay: 30
|
||||
}
|
||||
})
|
||||
|
||||
expect(wrapper.props().scrollDelay).toEqual(30)
|
||||
})
|
||||
|
||||
// 渲染slot
|
||||
it('has one or more slots', () => {
|
||||
const wrapper = mount(D2ContainerFull, {
|
||||
slots: {
|
||||
default: '<div>body</div>',
|
||||
header: '<div>header</div>',
|
||||
footer: '<div>footer</div>'
|
||||
}
|
||||
})
|
||||
|
||||
expect(wrapper.text()).toMatch('header')
|
||||
expect(wrapper.text()).toMatch('body')
|
||||
expect(wrapper.text()).toMatch('footer')
|
||||
})
|
||||
})
|
||||
65
tests/unit/d2-container-ghost-bs.spec.js
Normal file
65
tests/unit/d2-container-ghost-bs.spec.js
Normal file
@@ -0,0 +1,65 @@
|
||||
import { mount } from '@vue/test-utils'
|
||||
import D2ContainerGhostBs from '@/components/d2-container/components/d2-container-ghost-bs.vue'
|
||||
|
||||
describe('d2-container-ghost-bs', () => {
|
||||
// 存在且是Vue组件实例
|
||||
it('is a vue instance', () => {
|
||||
const wrapper = mount(D2ContainerGhostBs, {
|
||||
slots: {
|
||||
default: '<div>body</div>',
|
||||
header: '<div>header</div>',
|
||||
footer: '<div>footer</div>'
|
||||
}
|
||||
})
|
||||
|
||||
expect(wrapper.exists()).toBeTruthy()
|
||||
expect(wrapper.isVueInstance()).toBeTruthy()
|
||||
})
|
||||
|
||||
// 包含特定类名
|
||||
it('contains specific classnames', () => {
|
||||
const wrapper = mount(D2ContainerGhostBs, {
|
||||
slots: {
|
||||
default: '<div>body</div>',
|
||||
header: '<div>header</div>',
|
||||
footer: '<div>footer</div>'
|
||||
}
|
||||
})
|
||||
|
||||
expect(wrapper.is('.d2-container-ghost-bs')).toBeTruthy()
|
||||
expect(wrapper.contains('.d2-container-ghost-bs__header')).toBeTruthy()
|
||||
expect(wrapper.contains('.d2-container-ghost-bs__body')).toBeTruthy()
|
||||
expect(wrapper.contains('.d2-container-ghost-bs__footer')).toBeTruthy()
|
||||
})
|
||||
|
||||
// props
|
||||
it('has props', () => {
|
||||
const wrapper = mount(D2ContainerGhostBs, {
|
||||
slots: {
|
||||
default: '<div>body</div>',
|
||||
header: '<div>header</div>',
|
||||
footer: '<div>footer</div>'
|
||||
},
|
||||
propsData: {
|
||||
betterScrollOptions: {}
|
||||
}
|
||||
})
|
||||
|
||||
expect(wrapper.props().betterScrollOptions).toEqual({})
|
||||
})
|
||||
|
||||
// 渲染slot
|
||||
it('has one or more slots', () => {
|
||||
const wrapper = mount(D2ContainerGhostBs, {
|
||||
slots: {
|
||||
default: '<div>body</div>',
|
||||
header: '<div>header</div>',
|
||||
footer: '<div>footer</div>'
|
||||
}
|
||||
})
|
||||
|
||||
expect(wrapper.text()).toMatch('header')
|
||||
expect(wrapper.text()).toMatch('body')
|
||||
expect(wrapper.text()).toMatch('footer')
|
||||
})
|
||||
})
|
||||
54
tests/unit/d2-container-ghost.spec.js
Normal file
54
tests/unit/d2-container-ghost.spec.js
Normal file
@@ -0,0 +1,54 @@
|
||||
import { mount } from '@vue/test-utils'
|
||||
import D2ContainerGhost from '@/components/d2-container/components/d2-container-ghost.vue'
|
||||
|
||||
describe('d2-container-ghost', () => {
|
||||
// 存在且是Vue组件实例
|
||||
it('is a vue instance', () => {
|
||||
const wrapper = mount(D2ContainerGhost)
|
||||
|
||||
expect(wrapper.exists()).toBeTruthy()
|
||||
expect(wrapper.isVueInstance()).toBeTruthy()
|
||||
})
|
||||
|
||||
// 包含特定类名
|
||||
it('contains specific classnames', () => {
|
||||
const wrapper = mount(D2ContainerGhost, {
|
||||
slots: {
|
||||
default: '<div>body</div>',
|
||||
header: '<div>header</div>',
|
||||
footer: '<div>footer</div>'
|
||||
}
|
||||
})
|
||||
|
||||
expect(wrapper.is('.d2-container-ghost')).toBeTruthy()
|
||||
expect(wrapper.contains('.d2-container-ghost__header')).toBeTruthy()
|
||||
expect(wrapper.contains('.d2-container-ghost__body')).toBeTruthy()
|
||||
expect(wrapper.contains('.d2-container-ghost__footer')).toBeTruthy()
|
||||
})
|
||||
|
||||
// props
|
||||
it('has props', () => {
|
||||
const wrapper = mount(D2ContainerGhost, {
|
||||
propsData: {
|
||||
scrollDelay: 30
|
||||
}
|
||||
})
|
||||
|
||||
expect(wrapper.props().scrollDelay).toEqual(30)
|
||||
})
|
||||
|
||||
// 渲染slot
|
||||
it('has one or more slots', () => {
|
||||
const wrapper = mount(D2ContainerGhost, {
|
||||
slots: {
|
||||
default: '<div>body</div>',
|
||||
header: '<div>header</div>',
|
||||
footer: '<div>footer</div>'
|
||||
}
|
||||
})
|
||||
|
||||
expect(wrapper.text()).toMatch('header')
|
||||
expect(wrapper.text()).toMatch('body')
|
||||
expect(wrapper.text()).toMatch('footer')
|
||||
})
|
||||
})
|
||||
72
tests/unit/d2-count-up.spec.js
Normal file
72
tests/unit/d2-count-up.spec.js
Normal file
@@ -0,0 +1,72 @@
|
||||
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)
|
||||
})
|
||||
})
|
||||
39
tests/unit/d2-icon-select.spec.js
Normal file
39
tests/unit/d2-icon-select.spec.js
Normal file
@@ -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', () => {
|
||||
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)
|
||||
// })
|
||||
})
|
||||
27
tests/unit/d2-icon-svg.spec.js
Normal file
27
tests/unit/d2-icon-svg.spec.js
Normal file
@@ -0,0 +1,27 @@
|
||||
import { mount } from '@vue/test-utils'
|
||||
import D2IconSvg from '@/components/d2-icon-svg/index.vue'
|
||||
|
||||
describe('d2-icon-svg', () => {
|
||||
// 存在且是Vue组件实例
|
||||
it('is a vue instance', () => {
|
||||
const wrapper = mount(D2IconSvg, {
|
||||
propsData: {
|
||||
name: 'add'
|
||||
}
|
||||
})
|
||||
|
||||
expect(wrapper.exists()).toBeTruthy()
|
||||
expect(wrapper.isVueInstance()).toBeTruthy()
|
||||
})
|
||||
|
||||
// props
|
||||
it('has props', () => {
|
||||
const wrapper = mount(D2IconSvg, {
|
||||
propsData: {
|
||||
name: 'add'
|
||||
}
|
||||
})
|
||||
|
||||
expect(wrapper.props().name).toEqual('add')
|
||||
})
|
||||
})
|
||||
31
tests/unit/d2-icon.spec.js
Normal file
31
tests/unit/d2-icon.spec.js
Normal file
@@ -0,0 +1,31 @@
|
||||
import { mount } from '@vue/test-utils'
|
||||
import D2Icon from '@/components/d2-icon/index.vue'
|
||||
|
||||
describe('d2-icon', () => {
|
||||
// 存在且是Vue组件实例
|
||||
it('is a vue instance', () => {
|
||||
const wrapper = mount(D2Icon)
|
||||
|
||||
expect(wrapper.exists()).toBeTruthy()
|
||||
expect(wrapper.isVueInstance()).toBeTruthy()
|
||||
})
|
||||
|
||||
// 包含特定类名
|
||||
it('contains specific classnames', () => {
|
||||
const wrapper = mount(D2Icon)
|
||||
|
||||
expect(wrapper.is('.fa')).toBeTruthy()
|
||||
expect(wrapper.contains('.fa-font-awesome')).toBeTruthy()
|
||||
})
|
||||
|
||||
// props
|
||||
it('has props', () => {
|
||||
const wrapper = mount(D2Icon, {
|
||||
propsData: {
|
||||
name: 'font-awesome'
|
||||
}
|
||||
})
|
||||
|
||||
expect(wrapper.props().name).toEqual('font-awesome')
|
||||
})
|
||||
})
|
||||
30
tests/unit/d2-link-btn.spec.js
Normal file
30
tests/unit/d2-link-btn.spec.js
Normal file
@@ -0,0 +1,30 @@
|
||||
import { mount } from '@vue/test-utils'
|
||||
import D2LinkBtn from '@/components/d2-link-btn/index.vue'
|
||||
|
||||
describe('d2-link-btn', () => {
|
||||
// 存在且是Vue组件实例
|
||||
it('is a vue instance', () => {
|
||||
const wrapper = mount(D2LinkBtn, {
|
||||
stubs: ['el-button-group', 'el-button', 'd2-icon']
|
||||
})
|
||||
|
||||
expect(wrapper.exists()).toBeTruthy()
|
||||
expect(wrapper.isVueInstance()).toBeTruthy()
|
||||
})
|
||||
|
||||
// props
|
||||
it('has props', () => {
|
||||
const wrapper = mount(D2LinkBtn, {
|
||||
stubs: ['el-button-group', 'el-button', 'd2-icon'],
|
||||
propsData: {
|
||||
title: 'title',
|
||||
icon: 'icon',
|
||||
link: 'link'
|
||||
}
|
||||
})
|
||||
|
||||
expect(wrapper.props().title).toEqual('title')
|
||||
expect(wrapper.props().icon).toEqual('icon')
|
||||
expect(wrapper.props().link).toEqual('link')
|
||||
})
|
||||
})
|
||||
30
tests/unit/d2-module-index-banner.spec.js
Normal file
30
tests/unit/d2-module-index-banner.spec.js
Normal file
@@ -0,0 +1,30 @@
|
||||
import { mount } from '@vue/test-utils'
|
||||
import D2ModuleIndexBanner from '@/components/d2-module-index-banner/index.vue'
|
||||
|
||||
describe('d2-module-index-banner', () => {
|
||||
// 存在且是Vue组件实例
|
||||
it('is a vue instance', () => {
|
||||
const wrapper = mount(D2ModuleIndexBanner, {
|
||||
stubs: ['d2-icon']
|
||||
})
|
||||
|
||||
expect(wrapper.exists()).toBeTruthy()
|
||||
expect(wrapper.isVueInstance()).toBeTruthy()
|
||||
})
|
||||
|
||||
// props
|
||||
it('has props', () => {
|
||||
const wrapper = mount(D2ModuleIndexBanner, {
|
||||
stubs: ['d2-icon'],
|
||||
propsData: {
|
||||
title: 'title',
|
||||
subTitle: 'subTitle',
|
||||
link: 'link'
|
||||
}
|
||||
})
|
||||
|
||||
expect(wrapper.props().title).toEqual('title')
|
||||
expect(wrapper.props().subTitle).toEqual('subTitle')
|
||||
expect(wrapper.props().link).toEqual('link')
|
||||
})
|
||||
})
|
||||
36
tests/unit/d2-module-index-menu.spec.js
Normal file
36
tests/unit/d2-module-index-menu.spec.js
Normal file
@@ -0,0 +1,36 @@
|
||||
import { mount } from '@vue/test-utils'
|
||||
import D2ModuleIndexMenu from '@/components/d2-module-index-menu/index.vue'
|
||||
import menu from '@/menu/modules/demo-business'
|
||||
|
||||
describe('d2-module-index-menu', () => {
|
||||
// 存在且是Vue组件实例
|
||||
it('is a vue instance', () => {
|
||||
const wrapper = mount(D2ModuleIndexMenu, {
|
||||
stubs: ['el-button'],
|
||||
propsData: {
|
||||
menu
|
||||
}
|
||||
})
|
||||
|
||||
expect(wrapper.exists()).toBeTruthy()
|
||||
expect(wrapper.isVueInstance()).toBeTruthy()
|
||||
})
|
||||
|
||||
// 300m后正确渲染,包含特定类名
|
||||
it('contains specific classnames', (done) => {
|
||||
const wrapper = mount(D2ModuleIndexMenu, {
|
||||
stubs: ['el-button'],
|
||||
propsData: {
|
||||
menu: menu
|
||||
}
|
||||
})
|
||||
|
||||
setTimeout(() => {
|
||||
expect(wrapper.is('.d2-module-index-menu')).toBeTruthy()
|
||||
expect(wrapper.contains('.d2-module-index-menu-group')).toBeTruthy()
|
||||
expect(wrapper.contains('.d2-module-index-menu-group--title')).toBeTruthy()
|
||||
expect(wrapper.contains('.d2-module-index-menu-item')).toBeTruthy()
|
||||
done()
|
||||
}, 400)
|
||||
})
|
||||
})
|
||||
41
tests/unit/d2-page-cover.spec.js
Normal file
41
tests/unit/d2-page-cover.spec.js
Normal file
@@ -0,0 +1,41 @@
|
||||
import { mount } from '@vue/test-utils'
|
||||
import D2PageCover from '@/components/d2-page-cover/index.vue'
|
||||
|
||||
describe('d2-page-cover', () => {
|
||||
// 存在且是Vue组件实例
|
||||
it('is a vue instance', () => {
|
||||
const wrapper = mount(D2PageCover)
|
||||
|
||||
expect(wrapper.exists()).toBeTruthy()
|
||||
expect(wrapper.isVueInstance()).toBeTruthy()
|
||||
})
|
||||
|
||||
// 包含特定类名
|
||||
it('contains specific classnames', () => {
|
||||
const wrapper = mount(D2PageCover, {
|
||||
slots: {
|
||||
default: '<div>default</div>',
|
||||
footer: '<div>footer</div>'
|
||||
}
|
||||
})
|
||||
|
||||
expect(wrapper.is('.d2-page-cover')).toBeTruthy()
|
||||
expect(wrapper.contains('.d2-page-cover__logo')).toBeTruthy()
|
||||
expect(wrapper.contains('.d2-page-cover__title')).toBeTruthy()
|
||||
expect(wrapper.contains('.d2-page-cover__sub-title')).toBeTruthy()
|
||||
expect(wrapper.contains('.d2-page-cover__build-time')).toBeTruthy()
|
||||
})
|
||||
|
||||
// 渲染slot
|
||||
it('has one or more slots', () => {
|
||||
const wrapper = mount(D2PageCover, {
|
||||
slots: {
|
||||
default: '<div>default</div>',
|
||||
footer: '<div>footer</div>'
|
||||
}
|
||||
})
|
||||
|
||||
expect(wrapper.text()).toMatch('default')
|
||||
expect(wrapper.text()).toMatch('footer')
|
||||
})
|
||||
})
|
||||
39
tests/unit/d2-source.spec.js
Normal file
39
tests/unit/d2-source.spec.js
Normal file
@@ -0,0 +1,39 @@
|
||||
import { mount, createLocalVue } from '@vue/test-utils'
|
||||
import D2Source from '@/components/d2-container/components/d2-source.vue'
|
||||
|
||||
describe('d2-source', () => {
|
||||
// 存在且是Vue组件实例
|
||||
it('is a vue instance', () => {
|
||||
const wrapper = mount(D2Source, {
|
||||
stubs: ['d2-icon']
|
||||
})
|
||||
|
||||
expect(wrapper.exists()).toBeTruthy()
|
||||
expect(wrapper.isVueInstance()).toBeTruthy()
|
||||
})
|
||||
|
||||
// 包含特定类名
|
||||
it('contains specific classnames', (done) => {
|
||||
const wrapper = mount(D2Source, {
|
||||
stubs: ['d2-icon']
|
||||
})
|
||||
|
||||
expect(wrapper.is('.d2-source')).toBeTruthy()
|
||||
setTimeout(() => {
|
||||
expect(wrapper.contains('.d2-source--active')).toBeTruthy()
|
||||
done()
|
||||
}, 600)
|
||||
})
|
||||
|
||||
// props
|
||||
it('has props', () => {
|
||||
const wrapper = mount(D2Source, {
|
||||
stubs: ['d2-icon'],
|
||||
propsData: {
|
||||
filename: ''
|
||||
}
|
||||
})
|
||||
|
||||
expect(wrapper.props().filename).toEqual('')
|
||||
})
|
||||
})
|
||||
@@ -1 +1 @@
|
||||
f087314ad07f2b4d7658559be7838c8dd75bf499
|
||||
13dd0eb82ec0a73b25d0a39fe23a367f31a2aaf8
|
||||
Reference in New Issue
Block a user