unit test: d2-page-cover
Former-commit-id: b8af4e80b700b9dd89a83979e76c386c9673100f [formerly b8af4e80b700b9dd89a83979e76c386c9673100f [formerly b8af4e80b700b9dd89a83979e76c386c9673100f [formerly b8af4e80b700b9dd89a83979e76c386c9673100f [formerly d5214134e68bdedeb74b120641a5840a2af10b84 [formerly 76488a335bc0512b0bc637a6790cff8a0189abe1]]]]] Former-commit-id: e6b5fcd65ace783df85f8069a499f4f3f0f0dc59 Former-commit-id: 688e557e62c24ffdccbcd47ca72eab77dd41b5b8 Former-commit-id: 3bd0f57f281affe5fe3961a560fedc4d34e15033 [formerly 477e3ca31e3c90105f27e667f1c810e06a270264] Former-commit-id: 4734aee87fe4ebfc6b53f4807b74827479c34052 Former-commit-id: 76238a54f93938981d6a44ab6f5d2b1e900c05df Former-commit-id: 5cfbe6b537d02530f9455400b725b881a28ffabd Former-commit-id: 97fdf0aedf6afc759d707c56f0414b2888043c53 Former-commit-id: 807db838e760e4c85691899e2cf3ab7f88c909be
This commit is contained in:
parent
69551c5afa
commit
a5a5214768
|
|
@ -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')
|
||||
})
|
||||
})
|
||||
Loading…
Reference in New Issue