unit test: d2-container-full
Former-commit-id: 4bc2b877ea4c3d8cfaa05554e9f9f7e5350b6e25 [formerly 4bc2b877ea4c3d8cfaa05554e9f9f7e5350b6e25 [formerly 4bc2b877ea4c3d8cfaa05554e9f9f7e5350b6e25 [formerly 4bc2b877ea4c3d8cfaa05554e9f9f7e5350b6e25 [formerly 70126561aeab08652824a7f17b6a570cb1e9dd87 [formerly fe236bdaadef752c31ba9c21b43ffcc4c98fbcbf]]]]] Former-commit-id: 95f590e4a7ae9f8c27ff386887f6eb53309e5e25 Former-commit-id: 6db59439578a4af63444b378eee9566211e25457 Former-commit-id: 0203ff26b3d18211749bf747b5bbe337d65c8917 [formerly cdc91f18bb39d2bbeb6c7f4553d31acc3ab89a7e] Former-commit-id: a4b0181e8181265c6763c22d6accd0796d186e8f Former-commit-id: 240d166967d9a894e38b8ba39cbb222714533ae3 Former-commit-id: 64a23cf1415c54a325976b4d35768b708c16d541 Former-commit-id: 3cc60fa0e2527105042fbcbae219acc65da95eb1 Former-commit-id: de843fe7336dd261875465bcd8e1b3be0b00d101
This commit is contained in:
parent
a1d5dcf4e3
commit
63f557bd69
|
|
@ -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', () => {
|
||||
// 存在且是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()
|
||||
})
|
||||
|
||||
// 节流间隔prop
|
||||
it('has a property named \'scrollDelay\'', () => {
|
||||
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')
|
||||
})
|
||||
})
|
||||
Loading…
Reference in New Issue