forked from d2-projects/d2-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathd2-container-card-bs.spec.js
55 lines (47 loc) · 1.57 KB
/
d2-container-card-bs.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { mount } from '@vue/test-utils'
import D2ContainerCardBs from '@/components/d2-container/components/d2-container-card-bs.vue'
describe('d2-container-card-bs', () => {
// 存在且是Vue组件实例
it('is a vue instance', () => {
const wrapper = mount(D2ContainerCardBs)
expect(wrapper.exists()).toBeTruthy()
expect(wrapper.isVueInstance()).toBeTruthy()
})
// 包含特定类名
it('contains specific classnames', () => {
const wrapper = mount(D2ContainerCardBs, {
slots: {
default: '<div>body</div>',
header: '<div>header</div>',
footer: '<div>footer</div>'
}
})
expect(wrapper.is('.d2-container-card-bs')).toBeTruthy()
expect(wrapper.contains('.d2-container-card-bs__header')).toBeTruthy()
expect(wrapper.contains('.d2-container-card-bs__body')).toBeTruthy()
expect(wrapper.contains('.d2-container-card-bs__body-card')).toBeTruthy()
expect(wrapper.contains('.d2-container-card-bs__footer')).toBeTruthy()
})
// props
it('has props', () => {
const wrapper = mount(D2ContainerCardBs, {
propsData: {
betterScrollOptions: {}
}
})
expect(wrapper.props().betterScrollOptions).toEqual({})
})
// 渲染slot
it('has one or more slots', () => {
const wrapper = mount(D2ContainerCardBs, {
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')
})
})