unit test: d2-container-card
Former-commit-id: ec0d88699b516228939350bc91d2a19660e2daa1 [formerly ec0d88699b516228939350bc91d2a19660e2daa1 [formerly ec0d88699b516228939350bc91d2a19660e2daa1 [formerly ec0d88699b516228939350bc91d2a19660e2daa1 [formerly ed5f0a35cfeee08b444029b74ad8755cf2a8e35e [formerly 5235553320b656a9c12222faa18225b2b1ed54d8]]]]] Former-commit-id: 634539e313a27a71aab2d2e18982ec4e735dc93b Former-commit-id: f1537450ffea60639b8f11cbbe40058c5aece33a Former-commit-id: 58b5ae217a39f20c038b2d999f178359e49828d5 [formerly 105e09af8933da9f89591fae6acb2468ba706c96] Former-commit-id: 96c2b40a5b857599958ce75a75073983788b3fbe Former-commit-id: cecafe15a08e8f279767a45933c814bf948240cc Former-commit-id: ed8e45510ec0f518185555c9ebdc9e460d995614 Former-commit-id: 574e00143fbaabfbb4f462ff883b65c5d427c649 Former-commit-id: 5e667452de548c6482700f6c0ad1956af21bb1ed
This commit is contained in:
@@ -2,7 +2,16 @@ import { mount } from '@vue/test-utils'
|
|||||||
import D2ContainerCard from '@/components/d2-container/components/d2-container-card.vue'
|
import D2ContainerCard from '@/components/d2-container/components/d2-container-card.vue'
|
||||||
|
|
||||||
describe('d2-container-card.vue', () => {
|
describe('d2-container-card.vue', () => {
|
||||||
it('渲染slot', () => {
|
// 存在且是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, {
|
const wrapper = mount(D2ContainerCard, {
|
||||||
slots: {
|
slots: {
|
||||||
default: '<div>body</div>',
|
default: '<div>body</div>',
|
||||||
@@ -11,8 +20,25 @@ describe('d2-container-card.vue', () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(wrapper.html()).toContain('<div class="d2-container-card__body"><div class="d2-container-card__body-card"><div>body</div></div>')
|
expect(wrapper.is('.d2-container-card')).toBeTruthy()
|
||||||
expect(wrapper.html()).toContain('<div class="d2-container-card__header"><div>header</div></div>')
|
expect(wrapper.contains('.d2-container-card__header')).toBeTruthy()
|
||||||
expect(wrapper.html()).toContain('<div class="d2-container-card__footer"><div>footer</div></div>')
|
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()
|
||||||
|
});
|
||||||
|
|
||||||
|
// 渲染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')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user