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
55 lines
1.5 KiB
JavaScript
55 lines
1.5 KiB
JavaScript
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')
|
|
})
|
|
})
|