unit test: d2-container-ghost d2-container-ghost-bs
Former-commit-id: a3bd22f5d907c9b001c21d8e0e5e1a448e4a479d [formerly a3bd22f5d907c9b001c21d8e0e5e1a448e4a479d [formerly a3bd22f5d907c9b001c21d8e0e5e1a448e4a479d [formerly a3bd22f5d907c9b001c21d8e0e5e1a448e4a479d [formerly 93ea6d53bd1ba2ba7670725357950bb0cb8f252f [formerly d753e72f3acc433edf54816392664e4879def36e]]]]] Former-commit-id: 3b70ea51df338250db8381c176d72a1e5bf2f14d Former-commit-id: b5963a8de1dbb6a72a96d9e742ce252f096095be Former-commit-id: e9e410815bd4ed055a2902a584ec85ef6135871c [formerly 0a0fe15a5cc62fb43daf67ffb9cdc0bfbff768e4] Former-commit-id: 67fe141b4c8f69884d5e01e48ea92dad742fc7ab Former-commit-id: 0481b77c2ff5dfdb542414db7b228a0f5110f7e8 Former-commit-id: 816185b58edb34b955b176a97e7801f3e8e74b2f Former-commit-id: c28a3c03c9c48b9e5a2c40f87e101957ce745733 Former-commit-id: 502aaf18d8b17acb8b16421998ce47277bf56818
This commit is contained in:
parent
ccc5c5f631
commit
0caf2fde79
|
|
@ -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', () => {
|
||||
// 存在且是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()
|
||||
})
|
||||
|
||||
// betterScrollOptions prop
|
||||
it('has a property named \'betterScrollOptions\'', () => {
|
||||
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')
|
||||
})
|
||||
})
|
||||
|
|
@ -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', () => {
|
||||
// 存在且是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()
|
||||
})
|
||||
|
||||
// 节流间隔prop
|
||||
it('has a property named \'scrollDelay\'', () => {
|
||||
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')
|
||||
})
|
||||
})
|
||||
Loading…
Reference in New Issue