4cd4fd28
郭伟龙
feat: 初始化项目
|
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
import { mount } from '@vue/test-utils'
import { BButtonGroup } from './button-group'
describe('button-group', () => {
it('has expected default structure', async () => {
const wrapper = mount(BButtonGroup)
expect(wrapper.element.tagName).toBe('DIV')
expect(wrapper.classes()).toContain('btn-group')
expect(wrapper.classes().length).toBe(1)
expect(wrapper.attributes('role')).toBeDefined()
expect(wrapper.attributes('role')).toBe('group')
expect(wrapper.text()).toBe('')
wrapper.destroy()
})
it('should render default slot', async () => {
const wrapper = mount(BButtonGroup, {
slots: {
default: '<span>foobar</span>'
}
})
expect(wrapper.element.tagName).toBe('DIV')
expect(wrapper.classes()).toContain('btn-group')
expect(wrapper.classes().length).toBe(1)
expect(wrapper.attributes('role')).toBeDefined()
expect(wrapper.attributes('role')).toBe('group')
expect(wrapper.find('span').exists()).toBe(true)
expect(wrapper.text()).toBe('foobar')
wrapper.destroy()
})
it('should apply vertical class', async () => {
const wrapper = mount(BButtonGroup, {
propsData: {
vertical: true
}
})
expect(wrapper.element.tagName).toBe('DIV')
expect(wrapper.classes()).toContain('btn-group-vertical')
expect(wrapper.classes()).not.toContain('btn-group')
expect(wrapper.classes().length).toBe(1)
wrapper.destroy()
})
it('should apply size class', async () => {
const wrapper = mount(BButtonGroup, {
propsData: {
size: 'sm'
}
})
expect(wrapper.element.tagName).toBe('DIV')
expect(wrapper.classes()).toContain('btn-group')
expect(wrapper.classes()).toContain('btn-group-sm')
expect(wrapper.classes().length).toBe(2)
wrapper.destroy()
})
it('should apply size class when vertical', async () => {
const wrapper = mount(BButtonGroup, {
propsData: {
size: 'sm',
vertical: true
}
})
expect(wrapper.element.tagName).toBe('DIV')
expect(wrapper.classes()).toContain('btn-group-sm')
expect(wrapper.classes()).toContain('btn-group-vertical')
expect(wrapper.classes()).not.toContain('btn-group')
expect(wrapper.classes().length).toBe(2)
wrapper.destroy()
})
it('has custom role when aria-role prop set', async () => {
const wrapper = mount(BButtonGroup, {
propsData: {
ariaRole: 'foobar'
}
})
expect(wrapper.element.tagName).toBe('DIV')
expect(wrapper.classes()).toContain('btn-group')
expect(wrapper.classes().length).toBe(1)
expect(wrapper.attributes('role')).toBeDefined()
expect(wrapper.attributes('role')).toBe('foobar')
wrapper.destroy()
})
})
|