@gitlab/ui 114.0.1 → 114.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +9 -28
- package/CHANGELOG.md +0 -13132
- package/src/vendor/bootstrap/LICENSE +0 -11
- package/src/vendor/bootstrap-vue/LICENSE +0 -11
- package/src/vendor/bootstrap-vue/package.json +0 -144
- package/src/vendor/bootstrap-vue/src/components/button/MODIFICATIONS.md +0 -16
- package/src/vendor/bootstrap-vue/src/components/button/README.md +0 -240
- package/src/vendor/bootstrap-vue/src/components/button/button-close.spec.js +0 -210
- package/src/vendor/bootstrap-vue/src/components/button/button.spec.js +0 -349
- package/src/vendor/bootstrap-vue/src/components/button/package.json +0 -105
- package/src/vendor/bootstrap-vue/src/components/dropdown/README.md +0 -730
- package/src/vendor/bootstrap-vue/src/components/dropdown/dropdown-divider.spec.js +0 -58
- package/src/vendor/bootstrap-vue/src/components/dropdown/dropdown-form.spec.js +0 -110
- package/src/vendor/bootstrap-vue/src/components/dropdown/dropdown-group.spec.js +0 -94
- package/src/vendor/bootstrap-vue/src/components/dropdown/dropdown-header.spec.js +0 -73
- package/src/vendor/bootstrap-vue/src/components/dropdown/dropdown-item-button.spec.js +0 -117
- package/src/vendor/bootstrap-vue/src/components/dropdown/dropdown-item.spec.js +0 -147
- package/src/vendor/bootstrap-vue/src/components/dropdown/dropdown-text.spec.js +0 -59
- package/src/vendor/bootstrap-vue/src/components/dropdown/dropdown.spec.js +0 -1121
- package/src/vendor/bootstrap-vue/src/components/dropdown/package.json +0 -368
- package/src/vendor/bootstrap-vue/src/components/form/README.md +0 -365
- package/src/vendor/bootstrap-vue/src/components/form/form-invalid-feedback.spec.js +0 -170
- package/src/vendor/bootstrap-vue/src/components/form/form-text.spec.js +0 -93
- package/src/vendor/bootstrap-vue/src/components/form/form-valid-feedback.spec.js +0 -157
- package/src/vendor/bootstrap-vue/src/components/form/form.spec.js +0 -97
- package/src/vendor/bootstrap-vue/src/components/form/package.json +0 -112
- package/src/vendor/bootstrap-vue/src/components/form-checkbox/README.md +0 -691
- package/src/vendor/bootstrap-vue/src/components/form-checkbox/form-checkbox-group.spec.js +0 -525
- package/src/vendor/bootstrap-vue/src/components/form-checkbox/form-checkbox.spec.js +0 -922
- package/src/vendor/bootstrap-vue/src/components/form-checkbox/package.json +0 -172
- package/src/vendor/bootstrap-vue/src/components/form-group/README.md +0 -339
- package/src/vendor/bootstrap-vue/src/components/form-group/form-group.spec.js +0 -477
- package/src/vendor/bootstrap-vue/src/components/form-group/package.json +0 -183
- package/src/vendor/bootstrap-vue/src/components/form-radio/README.md +0 -437
- package/src/vendor/bootstrap-vue/src/components/form-radio/form-radio-group.spec.js +0 -357
- package/src/vendor/bootstrap-vue/src/components/form-radio/form-radio.spec.js +0 -587
- package/src/vendor/bootstrap-vue/src/components/form-radio/package.json +0 -162
- package/src/vendor/bootstrap-vue/src/components/form-select/README.md +0 -504
- package/src/vendor/bootstrap-vue/src/components/form-select/form-select-option-group.spec.js +0 -138
- package/src/vendor/bootstrap-vue/src/components/form-select/form-select-option.spec.js +0 -75
- package/src/vendor/bootstrap-vue/src/components/form-select/form-select.spec.js +0 -723
- package/src/vendor/bootstrap-vue/src/components/form-select/package.json +0 -132
- package/src/vendor/bootstrap-vue/src/components/form-textarea/README.md +0 -453
- package/src/vendor/bootstrap-vue/src/components/form-textarea/form-textarea.spec.js +0 -1000
- package/src/vendor/bootstrap-vue/src/components/form-textarea/package.json +0 -122
- package/src/vendor/bootstrap-vue/src/components/layout/README.md +0 -791
- package/src/vendor/bootstrap-vue/src/components/layout/col.spec.js +0 -192
- package/src/vendor/bootstrap-vue/src/components/layout/form-row.spec.js +0 -45
- package/src/vendor/bootstrap-vue/src/components/layout/package.json +0 -99
- package/src/vendor/bootstrap-vue/src/components/link/README.md +0 -76
- package/src/vendor/bootstrap-vue/src/components/link/link.spec.js +0 -434
- package/src/vendor/bootstrap-vue/src/components/link/package.json +0 -57
- package/src/vendor/bootstrap-vue/src/components/modal/MODIFICATIONS.md +0 -30
- package/src/vendor/bootstrap-vue/src/components/modal/README.md +0 -1067
- package/src/vendor/bootstrap-vue/src/components/modal/helpers/bv-modal-event.class.spec.js +0 -82
- package/src/vendor/bootstrap-vue/src/components/modal/modal.spec.js +0 -1418
- package/src/vendor/bootstrap-vue/src/components/modal/package.json +0 -544
- package/src/vendor/bootstrap-vue/src/components/nav/README.md +0 -362
- package/src/vendor/bootstrap-vue/src/components/nav/nav-item.spec.js +0 -127
- package/src/vendor/bootstrap-vue/src/components/nav/nav.spec.js +0 -177
- package/src/vendor/bootstrap-vue/src/components/nav/package.json +0 -73
- package/src/vendor/bootstrap-vue/src/components/popover/README.md +0 -919
- package/src/vendor/bootstrap-vue/src/components/popover/package.json +0 -261
- package/src/vendor/bootstrap-vue/src/components/popover/popover.spec.js +0 -198
- package/src/vendor/bootstrap-vue/src/components/table/README.md +0 -3157
- package/src/vendor/bootstrap-vue/src/components/table/helpers/default-sort-compare.spec.js +0 -112
- package/src/vendor/bootstrap-vue/src/components/table/helpers/normalize-fields.spec.js +0 -93
- package/src/vendor/bootstrap-vue/src/components/table/package.json +0 -1763
- package/src/vendor/bootstrap-vue/src/components/table/table-busy.spec.js +0 -150
- package/src/vendor/bootstrap-vue/src/components/table/table-caption.spec.js +0 -176
- package/src/vendor/bootstrap-vue/src/components/table/table-colgroup.spec.js +0 -81
- package/src/vendor/bootstrap-vue/src/components/table/table-filtering.spec.js +0 -409
- package/src/vendor/bootstrap-vue/src/components/table/table-item-formatter.spec.js +0 -56
- package/src/vendor/bootstrap-vue/src/components/table/table-lite.spec.js +0 -682
- package/src/vendor/bootstrap-vue/src/components/table/table-pagination.spec.js +0 -133
- package/src/vendor/bootstrap-vue/src/components/table/table-primarykey.spec.js +0 -83
- package/src/vendor/bootstrap-vue/src/components/table/table-provider.spec.js +0 -411
- package/src/vendor/bootstrap-vue/src/components/table/table-row-details.spec.js +0 -459
- package/src/vendor/bootstrap-vue/src/components/table/table-selectable.spec.js +0 -1182
- package/src/vendor/bootstrap-vue/src/components/table/table-simple.spec.js +0 -206
- package/src/vendor/bootstrap-vue/src/components/table/table-sorting.spec.js +0 -858
- package/src/vendor/bootstrap-vue/src/components/table/table-sticky-column.spec.js +0 -377
- package/src/vendor/bootstrap-vue/src/components/table/table-tbody-bottom-row.spec.js +0 -94
- package/src/vendor/bootstrap-vue/src/components/table/table-tbody-row-events.spec.js +0 -529
- package/src/vendor/bootstrap-vue/src/components/table/table-tbody-top-row.spec.js +0 -88
- package/src/vendor/bootstrap-vue/src/components/table/table-tbody-transition.spec.js +0 -83
- package/src/vendor/bootstrap-vue/src/components/table/table-tfoot-custom.spec.js +0 -91
- package/src/vendor/bootstrap-vue/src/components/table/table-tfoot-events.spec.js +0 -137
- package/src/vendor/bootstrap-vue/src/components/table/table-thead-events.spec.js +0 -155
- package/src/vendor/bootstrap-vue/src/components/table/table-thead-top.spec.js +0 -96
- package/src/vendor/bootstrap-vue/src/components/table/table.spec.js +0 -692
- package/src/vendor/bootstrap-vue/src/components/tabs/README.md +0 -433
- package/src/vendor/bootstrap-vue/src/components/tabs/package.json +0 -205
- package/src/vendor/bootstrap-vue/src/components/tabs/tab.spec.js +0 -330
- package/src/vendor/bootstrap-vue/src/components/tabs/tabs.spec.js +0 -778
- package/src/vendor/bootstrap-vue/src/components/toast/README.md +0 -655
- package/src/vendor/bootstrap-vue/src/components/toast/helpers/bv-toast.spec.js +0 -117
- package/src/vendor/bootstrap-vue/src/components/toast/package.json +0 -184
- package/src/vendor/bootstrap-vue/src/components/toast/toast.spec.js +0 -294
- package/src/vendor/bootstrap-vue/src/components/toast/toaster.spec.js +0 -77
- package/src/vendor/bootstrap-vue/src/components/tooltip/README.md +0 -559
- package/src/vendor/bootstrap-vue/src/components/tooltip/package.json +0 -258
- package/src/vendor/bootstrap-vue/src/components/tooltip/tooltip.spec.js +0 -1240
- package/src/vendor/bootstrap-vue/src/components/transition/package.json +0 -5
- package/src/vendor/bootstrap-vue/src/components/transporter/package.json +0 -5
- package/src/vendor/bootstrap-vue/src/components/transporter/transporter.spec.js +0 -85
- package/src/vendor/bootstrap-vue/src/directives/modal/modal.spec.js +0 -191
- package/src/vendor/bootstrap-vue/src/directives/tooltip/README.md +0 -521
- package/src/vendor/bootstrap-vue/src/directives/tooltip/package.json +0 -131
- package/src/vendor/bootstrap-vue/src/directives/tooltip/tooltip.spec.js +0 -190
- package/src/vendor/bootstrap-vue/src/directives/visible/README.md +0 -244
- package/src/vendor/bootstrap-vue/src/directives/visible/package.json +0 -24
- package/src/vendor/bootstrap-vue/src/mixins/attrs.spec.js +0 -194
- package/src/vendor/bootstrap-vue/src/mixins/click-out.spec.js +0 -52
- package/src/vendor/bootstrap-vue/src/mixins/focus-in.spec.js +0 -53
- package/src/vendor/bootstrap-vue/src/mixins/listen-on-document.spec.js +0 -117
- package/src/vendor/bootstrap-vue/src/mixins/listen-on-root.spec.js +0 -77
- package/src/vendor/bootstrap-vue/src/mixins/listen-on-window.spec.js +0 -115
- package/src/vendor/bootstrap-vue/src/mixins/listeners.spec.js +0 -245
- package/src/vendor/bootstrap-vue/src/utils/bv-event.class.spec.js +0 -66
- package/src/vendor/bootstrap-vue/src/utils/clone-deep.spec.js +0 -70
- package/src/vendor/bootstrap-vue/src/utils/config.spec.js +0 -169
- package/src/vendor/bootstrap-vue/src/utils/css-escape.spec.js +0 -82
- package/src/vendor/bootstrap-vue/src/utils/dom.spec.js +0 -291
- package/src/vendor/bootstrap-vue/src/utils/events.spec.js +0 -41
- package/src/vendor/bootstrap-vue/src/utils/get.spec.js +0 -109
- package/src/vendor/bootstrap-vue/src/utils/inspect.spec.js +0 -251
- package/src/vendor/bootstrap-vue/src/utils/loose-equal.spec.js +0 -203
- package/src/vendor/bootstrap-vue/src/utils/normalize-slot.spec.js +0 -63
- package/src/vendor/bootstrap-vue/src/utils/number.spec.js +0 -72
- package/src/vendor/bootstrap-vue/src/utils/object.spec.js +0 -61
- package/src/vendor/bootstrap-vue/src/utils/props.spec.js +0 -112
- package/src/vendor/bootstrap-vue/src/utils/router.spec.js +0 -248
- package/src/vendor/bootstrap-vue/src/utils/string.spec.js +0 -65
- package/src/vendor/bootstrap-vue/src/utils/stringify-object-values.spec.js +0 -47
- package/src/vendor/bootstrap-vue/src/utils/warn.spec.js +0 -54
|
@@ -1,922 +0,0 @@
|
|
|
1
|
-
import { mount } from '@vue/test-utils'
|
|
2
|
-
import { waitNT, waitRAF } from '../../../tests/utils'
|
|
3
|
-
import { BFormCheckbox } from './form-checkbox'
|
|
4
|
-
|
|
5
|
-
describe('form-checkbox', () => {
|
|
6
|
-
// --- Custom checkbox structure, class and attributes tests ---
|
|
7
|
-
|
|
8
|
-
it('default has structure <div><input><label></label></div>', async () => {
|
|
9
|
-
const wrapper = mount(BFormCheckbox, {
|
|
10
|
-
propsData: {
|
|
11
|
-
checked: '',
|
|
12
|
-
value: 'a'
|
|
13
|
-
},
|
|
14
|
-
slots: {
|
|
15
|
-
default: 'foobar'
|
|
16
|
-
}
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
expect(wrapper).toBeDefined()
|
|
20
|
-
expect(wrapper.element.tagName).toBe('DIV')
|
|
21
|
-
|
|
22
|
-
const $children = wrapper.element.children
|
|
23
|
-
expect($children.length).toEqual(2)
|
|
24
|
-
expect($children[0].tagName).toEqual('INPUT')
|
|
25
|
-
expect($children[1].tagName).toEqual('LABEL')
|
|
26
|
-
|
|
27
|
-
wrapper.destroy()
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
it('default has wrapper class custom-control and custom-checkbox', async () => {
|
|
31
|
-
const wrapper = mount(BFormCheckbox, {
|
|
32
|
-
propsData: {
|
|
33
|
-
checked: '',
|
|
34
|
-
value: 'a'
|
|
35
|
-
},
|
|
36
|
-
slots: {
|
|
37
|
-
default: 'foobar'
|
|
38
|
-
}
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
expect(wrapper.classes().length).toEqual(2)
|
|
42
|
-
expect(wrapper.classes()).toContain('custom-control')
|
|
43
|
-
expect(wrapper.classes()).toContain('custom-checkbox')
|
|
44
|
-
|
|
45
|
-
wrapper.destroy()
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
it('default has input type checkbox', async () => {
|
|
49
|
-
const wrapper = mount(BFormCheckbox, {
|
|
50
|
-
propsData: {
|
|
51
|
-
checked: '',
|
|
52
|
-
value: 'a'
|
|
53
|
-
},
|
|
54
|
-
slots: {
|
|
55
|
-
default: 'foobar'
|
|
56
|
-
}
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
const $input = wrapper.find('input')
|
|
60
|
-
expect($input.attributes('type')).toBeDefined()
|
|
61
|
-
expect($input.attributes('type')).toEqual('checkbox')
|
|
62
|
-
|
|
63
|
-
wrapper.destroy()
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
it('default does not have aria-label attribute on input', async () => {
|
|
67
|
-
const wrapper = mount(BFormCheckbox, {
|
|
68
|
-
propsData: {
|
|
69
|
-
checked: false
|
|
70
|
-
},
|
|
71
|
-
slots: {
|
|
72
|
-
default: 'foobar'
|
|
73
|
-
}
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
expect(wrapper.find('input').attributes('aria-label')).toBeUndefined()
|
|
77
|
-
|
|
78
|
-
wrapper.destroy()
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
it('has aria-label attribute on input when aria-label provided', async () => {
|
|
82
|
-
const wrapper = mount(BFormCheckbox, {
|
|
83
|
-
propsData: {
|
|
84
|
-
checked: false,
|
|
85
|
-
ariaLabel: 'bar'
|
|
86
|
-
},
|
|
87
|
-
slots: {
|
|
88
|
-
default: 'foo'
|
|
89
|
-
}
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
expect(wrapper.find('input').attributes('aria-label')).toBe('bar')
|
|
93
|
-
|
|
94
|
-
wrapper.destroy()
|
|
95
|
-
})
|
|
96
|
-
|
|
97
|
-
it('default has input class custom-control-input', async () => {
|
|
98
|
-
const wrapper = mount(BFormCheckbox, {
|
|
99
|
-
propsData: {
|
|
100
|
-
checked: false
|
|
101
|
-
},
|
|
102
|
-
slots: {
|
|
103
|
-
default: 'foobar'
|
|
104
|
-
}
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
const $input = wrapper.find('input')
|
|
108
|
-
expect($input.classes().length).toEqual(1)
|
|
109
|
-
expect($input.classes()).toContain('custom-control-input')
|
|
110
|
-
expect($input.classes()).not.toContain('position-static')
|
|
111
|
-
|
|
112
|
-
wrapper.destroy()
|
|
113
|
-
})
|
|
114
|
-
|
|
115
|
-
it('default has label class custom-control-label', async () => {
|
|
116
|
-
const wrapper = mount(BFormCheckbox, {
|
|
117
|
-
propsData: {
|
|
118
|
-
checked: false
|
|
119
|
-
},
|
|
120
|
-
slots: {
|
|
121
|
-
default: 'foobar'
|
|
122
|
-
}
|
|
123
|
-
})
|
|
124
|
-
|
|
125
|
-
const $label = wrapper.find('label')
|
|
126
|
-
expect($label.classes().length).toEqual(1)
|
|
127
|
-
expect($label.classes()).toContain('custom-control-label')
|
|
128
|
-
|
|
129
|
-
wrapper.destroy()
|
|
130
|
-
})
|
|
131
|
-
|
|
132
|
-
it('has default slot content in label', async () => {
|
|
133
|
-
const wrapper = mount(BFormCheckbox, {
|
|
134
|
-
propsData: {
|
|
135
|
-
checked: false
|
|
136
|
-
},
|
|
137
|
-
slots: {
|
|
138
|
-
default: 'foobar'
|
|
139
|
-
}
|
|
140
|
-
})
|
|
141
|
-
|
|
142
|
-
const $label = wrapper.find('label')
|
|
143
|
-
expect($label.text()).toEqual('foobar')
|
|
144
|
-
|
|
145
|
-
wrapper.destroy()
|
|
146
|
-
})
|
|
147
|
-
|
|
148
|
-
it('default has no disabled attribute on input', async () => {
|
|
149
|
-
const wrapper = mount(BFormCheckbox, {
|
|
150
|
-
propsData: {
|
|
151
|
-
checked: false
|
|
152
|
-
},
|
|
153
|
-
slots: {
|
|
154
|
-
default: 'foobar'
|
|
155
|
-
}
|
|
156
|
-
})
|
|
157
|
-
|
|
158
|
-
const $input = wrapper.find('input')
|
|
159
|
-
expect($input.attributes('disabled')).toBeUndefined()
|
|
160
|
-
|
|
161
|
-
wrapper.destroy()
|
|
162
|
-
})
|
|
163
|
-
|
|
164
|
-
it('has disabled attribute on input when prop disabled set', async () => {
|
|
165
|
-
const wrapper = mount(BFormCheckbox, {
|
|
166
|
-
propsData: {
|
|
167
|
-
checked: false,
|
|
168
|
-
disabled: true
|
|
169
|
-
},
|
|
170
|
-
slots: {
|
|
171
|
-
default: 'foobar'
|
|
172
|
-
}
|
|
173
|
-
})
|
|
174
|
-
|
|
175
|
-
const $input = wrapper.find('input')
|
|
176
|
-
expect($input.attributes('disabled')).toBeDefined()
|
|
177
|
-
|
|
178
|
-
wrapper.destroy()
|
|
179
|
-
})
|
|
180
|
-
|
|
181
|
-
it('default has no required attribute on input', async () => {
|
|
182
|
-
const wrapper = mount(BFormCheckbox, {
|
|
183
|
-
propsData: {
|
|
184
|
-
checked: false
|
|
185
|
-
},
|
|
186
|
-
slots: {
|
|
187
|
-
default: 'foobar'
|
|
188
|
-
}
|
|
189
|
-
})
|
|
190
|
-
|
|
191
|
-
const $input = wrapper.find('input')
|
|
192
|
-
expect($input.attributes('required')).toBeUndefined()
|
|
193
|
-
|
|
194
|
-
wrapper.destroy()
|
|
195
|
-
})
|
|
196
|
-
|
|
197
|
-
it('does not have required attribute on input when prop required set and name prop not provided', async () => {
|
|
198
|
-
const wrapper = mount(BFormCheckbox, {
|
|
199
|
-
propsData: {
|
|
200
|
-
checked: false,
|
|
201
|
-
required: true
|
|
202
|
-
},
|
|
203
|
-
slots: {
|
|
204
|
-
default: 'foobar'
|
|
205
|
-
}
|
|
206
|
-
})
|
|
207
|
-
|
|
208
|
-
const $input = wrapper.find('input')
|
|
209
|
-
expect($input.attributes('required')).toBeUndefined()
|
|
210
|
-
|
|
211
|
-
wrapper.destroy()
|
|
212
|
-
})
|
|
213
|
-
|
|
214
|
-
it('has required attribute on input when prop required and name set', async () => {
|
|
215
|
-
const wrapper = mount(BFormCheckbox, {
|
|
216
|
-
propsData: {
|
|
217
|
-
checked: false,
|
|
218
|
-
name: 'test',
|
|
219
|
-
required: true
|
|
220
|
-
},
|
|
221
|
-
slots: {
|
|
222
|
-
default: 'foobar'
|
|
223
|
-
}
|
|
224
|
-
})
|
|
225
|
-
|
|
226
|
-
const $input = wrapper.find('input')
|
|
227
|
-
expect($input.attributes('required')).toBeDefined()
|
|
228
|
-
|
|
229
|
-
wrapper.destroy()
|
|
230
|
-
})
|
|
231
|
-
|
|
232
|
-
it('default has no name attribute on input', async () => {
|
|
233
|
-
const wrapper = mount(BFormCheckbox, {
|
|
234
|
-
propsData: {
|
|
235
|
-
checked: false
|
|
236
|
-
},
|
|
237
|
-
slots: {
|
|
238
|
-
default: 'foobar'
|
|
239
|
-
}
|
|
240
|
-
})
|
|
241
|
-
|
|
242
|
-
const $input = wrapper.find('input')
|
|
243
|
-
expect($input.attributes('name')).toBeUndefined()
|
|
244
|
-
|
|
245
|
-
wrapper.destroy()
|
|
246
|
-
})
|
|
247
|
-
|
|
248
|
-
it('has name attribute on input when name prop set', async () => {
|
|
249
|
-
const wrapper = mount(BFormCheckbox, {
|
|
250
|
-
propsData: {
|
|
251
|
-
checked: false,
|
|
252
|
-
name: 'test'
|
|
253
|
-
},
|
|
254
|
-
slots: {
|
|
255
|
-
default: 'foobar'
|
|
256
|
-
}
|
|
257
|
-
})
|
|
258
|
-
|
|
259
|
-
const $input = wrapper.find('input')
|
|
260
|
-
expect($input.attributes('name')).toBeDefined()
|
|
261
|
-
expect($input.attributes('name')).toEqual('test')
|
|
262
|
-
|
|
263
|
-
wrapper.destroy()
|
|
264
|
-
})
|
|
265
|
-
|
|
266
|
-
it('default has no form attribute on input', async () => {
|
|
267
|
-
const wrapper = mount(BFormCheckbox, {
|
|
268
|
-
propsData: {
|
|
269
|
-
checked: false
|
|
270
|
-
},
|
|
271
|
-
slots: {
|
|
272
|
-
default: 'foobar'
|
|
273
|
-
}
|
|
274
|
-
})
|
|
275
|
-
|
|
276
|
-
const $input = wrapper.find('input')
|
|
277
|
-
expect($input.attributes('form')).toBeUndefined()
|
|
278
|
-
|
|
279
|
-
wrapper.destroy()
|
|
280
|
-
})
|
|
281
|
-
|
|
282
|
-
it('has form attribute on input when form prop set', async () => {
|
|
283
|
-
const wrapper = mount(BFormCheckbox, {
|
|
284
|
-
propsData: {
|
|
285
|
-
checked: false,
|
|
286
|
-
form: 'test'
|
|
287
|
-
},
|
|
288
|
-
slots: {
|
|
289
|
-
default: 'foobar'
|
|
290
|
-
}
|
|
291
|
-
})
|
|
292
|
-
|
|
293
|
-
const $input = wrapper.find('input')
|
|
294
|
-
expect($input.attributes('form')).toBeDefined()
|
|
295
|
-
expect($input.attributes('form')).toEqual('test')
|
|
296
|
-
|
|
297
|
-
wrapper.destroy()
|
|
298
|
-
})
|
|
299
|
-
|
|
300
|
-
it('has custom attributes transferred to input element', async () => {
|
|
301
|
-
const wrapper = mount(BFormCheckbox, {
|
|
302
|
-
propsData: {
|
|
303
|
-
id: 'foo',
|
|
304
|
-
foo: 'bar'
|
|
305
|
-
}
|
|
306
|
-
})
|
|
307
|
-
|
|
308
|
-
const $input = wrapper.find('input')
|
|
309
|
-
expect($input.attributes('foo')).toBeDefined()
|
|
310
|
-
expect($input.attributes('foo')).toEqual('bar')
|
|
311
|
-
|
|
312
|
-
wrapper.destroy()
|
|
313
|
-
})
|
|
314
|
-
|
|
315
|
-
it('default has class custom-control-inline when prop inline=true', async () => {
|
|
316
|
-
const wrapper = mount(BFormCheckbox, {
|
|
317
|
-
propsData: {
|
|
318
|
-
checked: false,
|
|
319
|
-
inline: true
|
|
320
|
-
},
|
|
321
|
-
slots: {
|
|
322
|
-
default: 'foobar'
|
|
323
|
-
}
|
|
324
|
-
})
|
|
325
|
-
|
|
326
|
-
expect(wrapper.classes().length).toEqual(3)
|
|
327
|
-
expect(wrapper.classes()).toContain('custom-checkbox')
|
|
328
|
-
expect(wrapper.classes()).toContain('custom-control')
|
|
329
|
-
expect(wrapper.classes()).toContain('custom-control-inline')
|
|
330
|
-
|
|
331
|
-
wrapper.destroy()
|
|
332
|
-
})
|
|
333
|
-
|
|
334
|
-
it('default has no input validation classes by default', async () => {
|
|
335
|
-
const wrapper = mount(BFormCheckbox, {
|
|
336
|
-
propsData: {
|
|
337
|
-
checked: false
|
|
338
|
-
},
|
|
339
|
-
slots: {
|
|
340
|
-
default: 'foobar'
|
|
341
|
-
}
|
|
342
|
-
})
|
|
343
|
-
|
|
344
|
-
const $input = wrapper.find('input')
|
|
345
|
-
expect($input).toBeDefined()
|
|
346
|
-
expect($input.classes()).not.toContain('is-invalid')
|
|
347
|
-
expect($input.classes()).not.toContain('is-valid')
|
|
348
|
-
|
|
349
|
-
wrapper.destroy()
|
|
350
|
-
})
|
|
351
|
-
|
|
352
|
-
it('default has no input validation classes when state=null', async () => {
|
|
353
|
-
const wrapper = mount(BFormCheckbox, {
|
|
354
|
-
propsData: {
|
|
355
|
-
state: null,
|
|
356
|
-
checked: false
|
|
357
|
-
},
|
|
358
|
-
slots: {
|
|
359
|
-
default: 'foobar'
|
|
360
|
-
}
|
|
361
|
-
})
|
|
362
|
-
|
|
363
|
-
const $input = wrapper.find('input')
|
|
364
|
-
expect($input).toBeDefined()
|
|
365
|
-
expect($input.classes()).not.toContain('is-invalid')
|
|
366
|
-
expect($input.classes()).not.toContain('is-valid')
|
|
367
|
-
|
|
368
|
-
wrapper.destroy()
|
|
369
|
-
})
|
|
370
|
-
|
|
371
|
-
it('default has input validation class is-valid when state=true', async () => {
|
|
372
|
-
const wrapper = mount(BFormCheckbox, {
|
|
373
|
-
propsData: {
|
|
374
|
-
state: true,
|
|
375
|
-
checked: false
|
|
376
|
-
},
|
|
377
|
-
slots: {
|
|
378
|
-
default: 'foobar'
|
|
379
|
-
}
|
|
380
|
-
})
|
|
381
|
-
|
|
382
|
-
const $input = wrapper.find('input')
|
|
383
|
-
expect($input).toBeDefined()
|
|
384
|
-
expect($input.classes()).not.toContain('is-invalid')
|
|
385
|
-
expect($input.classes()).toContain('is-valid')
|
|
386
|
-
|
|
387
|
-
wrapper.destroy()
|
|
388
|
-
})
|
|
389
|
-
|
|
390
|
-
it('default has input validation class is-invalid when state=false', async () => {
|
|
391
|
-
const wrapper = mount(BFormCheckbox, {
|
|
392
|
-
propsData: {
|
|
393
|
-
state: false,
|
|
394
|
-
checked: false
|
|
395
|
-
},
|
|
396
|
-
slots: {
|
|
397
|
-
default: 'foobar'
|
|
398
|
-
}
|
|
399
|
-
})
|
|
400
|
-
|
|
401
|
-
const $input = wrapper.find('input')
|
|
402
|
-
expect($input).toBeDefined()
|
|
403
|
-
expect($input.classes()).toContain('is-invalid')
|
|
404
|
-
expect($input.classes()).not.toContain('is-valid')
|
|
405
|
-
|
|
406
|
-
wrapper.destroy()
|
|
407
|
-
})
|
|
408
|
-
|
|
409
|
-
// --- Switch styling - stand alone ---
|
|
410
|
-
|
|
411
|
-
it('switch has structure <div><input><label></label></div>', async () => {
|
|
412
|
-
const wrapper = mount(BFormCheckbox, {
|
|
413
|
-
propsData: {
|
|
414
|
-
switch: true,
|
|
415
|
-
checked: '',
|
|
416
|
-
value: 'a'
|
|
417
|
-
},
|
|
418
|
-
slots: {
|
|
419
|
-
default: 'foobar'
|
|
420
|
-
}
|
|
421
|
-
})
|
|
422
|
-
|
|
423
|
-
expect(wrapper).toBeDefined()
|
|
424
|
-
expect(wrapper.element.tagName).toBe('DIV')
|
|
425
|
-
|
|
426
|
-
const $children = wrapper.element.children
|
|
427
|
-
expect($children.length).toEqual(2)
|
|
428
|
-
expect($children[0].tagName).toEqual('INPUT')
|
|
429
|
-
expect($children[1].tagName).toEqual('LABEL')
|
|
430
|
-
|
|
431
|
-
wrapper.destroy()
|
|
432
|
-
})
|
|
433
|
-
|
|
434
|
-
it('switch has wrapper classes custom-control and custom-switch', async () => {
|
|
435
|
-
const wrapper = mount(BFormCheckbox, {
|
|
436
|
-
propsData: {
|
|
437
|
-
switch: true,
|
|
438
|
-
checked: '',
|
|
439
|
-
value: 'a'
|
|
440
|
-
},
|
|
441
|
-
slots: {
|
|
442
|
-
default: 'foobar'
|
|
443
|
-
}
|
|
444
|
-
})
|
|
445
|
-
|
|
446
|
-
expect(wrapper.classes().length).toEqual(2)
|
|
447
|
-
expect(wrapper.classes()).toContain('custom-control')
|
|
448
|
-
expect(wrapper.classes()).toContain('custom-switch')
|
|
449
|
-
|
|
450
|
-
wrapper.destroy()
|
|
451
|
-
})
|
|
452
|
-
|
|
453
|
-
it('switch has input type checkbox', async () => {
|
|
454
|
-
const wrapper = mount(BFormCheckbox, {
|
|
455
|
-
propsData: {
|
|
456
|
-
switch: true,
|
|
457
|
-
checked: '',
|
|
458
|
-
value: 'a'
|
|
459
|
-
},
|
|
460
|
-
slots: {
|
|
461
|
-
default: 'foobar'
|
|
462
|
-
}
|
|
463
|
-
})
|
|
464
|
-
|
|
465
|
-
const $input = wrapper.find('input')
|
|
466
|
-
expect($input.attributes('type')).toBeDefined()
|
|
467
|
-
expect($input.attributes('type')).toEqual('checkbox')
|
|
468
|
-
|
|
469
|
-
wrapper.destroy()
|
|
470
|
-
})
|
|
471
|
-
|
|
472
|
-
it('switch has input class custom-control-input', async () => {
|
|
473
|
-
const wrapper = mount(BFormCheckbox, {
|
|
474
|
-
propsData: {
|
|
475
|
-
switch: true,
|
|
476
|
-
checked: false
|
|
477
|
-
},
|
|
478
|
-
slots: {
|
|
479
|
-
default: 'foobar'
|
|
480
|
-
}
|
|
481
|
-
})
|
|
482
|
-
|
|
483
|
-
const $input = wrapper.find('input')
|
|
484
|
-
expect($input.classes().length).toEqual(1)
|
|
485
|
-
expect($input.classes()).toContain('custom-control-input')
|
|
486
|
-
|
|
487
|
-
wrapper.destroy()
|
|
488
|
-
})
|
|
489
|
-
|
|
490
|
-
it('switch has label class custom-control-label', async () => {
|
|
491
|
-
const wrapper = mount(BFormCheckbox, {
|
|
492
|
-
propsData: {
|
|
493
|
-
switch: true,
|
|
494
|
-
checked: false
|
|
495
|
-
},
|
|
496
|
-
slots: {
|
|
497
|
-
default: 'foobar'
|
|
498
|
-
}
|
|
499
|
-
})
|
|
500
|
-
|
|
501
|
-
const $label = wrapper.find('label')
|
|
502
|
-
expect($label.classes().length).toEqual(1)
|
|
503
|
-
expect($label.classes()).toContain('custom-control-label')
|
|
504
|
-
|
|
505
|
-
wrapper.destroy()
|
|
506
|
-
})
|
|
507
|
-
|
|
508
|
-
// --- Indeterminate testing ---
|
|
509
|
-
|
|
510
|
-
it('does not have input indeterminate set by default', async () => {
|
|
511
|
-
const wrapper = mount(BFormCheckbox, {
|
|
512
|
-
propsData: {
|
|
513
|
-
checked: false
|
|
514
|
-
},
|
|
515
|
-
slots: {
|
|
516
|
-
default: 'foobar'
|
|
517
|
-
}
|
|
518
|
-
})
|
|
519
|
-
|
|
520
|
-
const $input = wrapper.find('input')
|
|
521
|
-
expect($input).toBeDefined()
|
|
522
|
-
expect($input.element.indeterminate).toBe(false)
|
|
523
|
-
|
|
524
|
-
wrapper.destroy()
|
|
525
|
-
})
|
|
526
|
-
|
|
527
|
-
it('has input indeterminate set by when indeterminate=true', async () => {
|
|
528
|
-
const wrapper = mount(BFormCheckbox, {
|
|
529
|
-
propsData: {
|
|
530
|
-
checked: false,
|
|
531
|
-
indeterminate: true
|
|
532
|
-
},
|
|
533
|
-
slots: {
|
|
534
|
-
default: 'foobar'
|
|
535
|
-
}
|
|
536
|
-
})
|
|
537
|
-
|
|
538
|
-
const $input = wrapper.find('input')
|
|
539
|
-
expect($input).toBeDefined()
|
|
540
|
-
expect($input.element.indeterminate).toBe(true)
|
|
541
|
-
|
|
542
|
-
wrapper.destroy()
|
|
543
|
-
})
|
|
544
|
-
|
|
545
|
-
it('has input indeterminate set by when indeterminate set to true after mount', async () => {
|
|
546
|
-
const wrapper = mount(BFormCheckbox, {
|
|
547
|
-
propsData: {
|
|
548
|
-
checked: false,
|
|
549
|
-
indeterminate: false
|
|
550
|
-
},
|
|
551
|
-
slots: {
|
|
552
|
-
default: 'foobar'
|
|
553
|
-
}
|
|
554
|
-
})
|
|
555
|
-
|
|
556
|
-
const $input = wrapper.find('input')
|
|
557
|
-
expect($input).toBeDefined()
|
|
558
|
-
expect($input.element.indeterminate).toBe(false)
|
|
559
|
-
|
|
560
|
-
await wrapper.setProps({ indeterminate: true })
|
|
561
|
-
expect($input.element.indeterminate).toBe(true)
|
|
562
|
-
|
|
563
|
-
await wrapper.setProps({ indeterminate: false })
|
|
564
|
-
expect($input.element.indeterminate).toBe(false)
|
|
565
|
-
|
|
566
|
-
wrapper.destroy()
|
|
567
|
-
})
|
|
568
|
-
|
|
569
|
-
// --- Functionality testing ---
|
|
570
|
-
|
|
571
|
-
it('default has internal localChecked=false when prop checked=false', async () => {
|
|
572
|
-
const wrapper = mount(BFormCheckbox, {
|
|
573
|
-
propsData: {
|
|
574
|
-
checked: false
|
|
575
|
-
},
|
|
576
|
-
slots: {
|
|
577
|
-
default: 'foobar'
|
|
578
|
-
}
|
|
579
|
-
})
|
|
580
|
-
|
|
581
|
-
expect(wrapper.vm).toBeDefined()
|
|
582
|
-
expect(wrapper.vm.localChecked).toBeDefined()
|
|
583
|
-
expect(wrapper.vm.localChecked).toEqual(false)
|
|
584
|
-
|
|
585
|
-
wrapper.destroy()
|
|
586
|
-
})
|
|
587
|
-
|
|
588
|
-
it('default has internal localChecked=true when prop checked=true', async () => {
|
|
589
|
-
const wrapper = mount(BFormCheckbox, {
|
|
590
|
-
propsData: {
|
|
591
|
-
checked: true
|
|
592
|
-
},
|
|
593
|
-
slots: {
|
|
594
|
-
default: 'foobar'
|
|
595
|
-
}
|
|
596
|
-
})
|
|
597
|
-
|
|
598
|
-
expect(wrapper.vm).toBeDefined()
|
|
599
|
-
expect(wrapper.vm.localChecked).toBeDefined()
|
|
600
|
-
expect(wrapper.vm.localChecked).toEqual(true)
|
|
601
|
-
|
|
602
|
-
wrapper.destroy()
|
|
603
|
-
})
|
|
604
|
-
|
|
605
|
-
it('default has internal localChecked null', async () => {
|
|
606
|
-
const wrapper = mount(BFormCheckbox, {
|
|
607
|
-
propsData: {
|
|
608
|
-
uncheckedValue: 'foo',
|
|
609
|
-
value: 'bar'
|
|
610
|
-
},
|
|
611
|
-
slots: {
|
|
612
|
-
default: 'foobar'
|
|
613
|
-
}
|
|
614
|
-
})
|
|
615
|
-
|
|
616
|
-
expect(wrapper.vm).toBeDefined()
|
|
617
|
-
expect(wrapper.vm.localChecked).toBeDefined()
|
|
618
|
-
expect(wrapper.vm.localChecked).toBe(null)
|
|
619
|
-
|
|
620
|
-
wrapper.destroy()
|
|
621
|
-
})
|
|
622
|
-
|
|
623
|
-
it('default has internal localChecked set to checked prop', async () => {
|
|
624
|
-
const wrapper = mount(BFormCheckbox, {
|
|
625
|
-
propsData: {
|
|
626
|
-
uncheckedValue: 'foo',
|
|
627
|
-
value: 'bar',
|
|
628
|
-
checked: ''
|
|
629
|
-
},
|
|
630
|
-
slots: {
|
|
631
|
-
default: 'foobar'
|
|
632
|
-
}
|
|
633
|
-
})
|
|
634
|
-
|
|
635
|
-
expect(wrapper.vm).toBeDefined()
|
|
636
|
-
expect(wrapper.vm.localChecked).toBeDefined()
|
|
637
|
-
expect(wrapper.vm.localChecked).toEqual('')
|
|
638
|
-
|
|
639
|
-
wrapper.destroy()
|
|
640
|
-
})
|
|
641
|
-
|
|
642
|
-
it('default has internal localChecked set to value when checked=value', async () => {
|
|
643
|
-
const wrapper = mount(BFormCheckbox, {
|
|
644
|
-
propsData: {
|
|
645
|
-
uncheckedValue: 'foo',
|
|
646
|
-
value: 'bar',
|
|
647
|
-
checked: 'bar'
|
|
648
|
-
},
|
|
649
|
-
slots: {
|
|
650
|
-
default: 'foobar'
|
|
651
|
-
}
|
|
652
|
-
})
|
|
653
|
-
|
|
654
|
-
expect(wrapper.vm).toBeDefined()
|
|
655
|
-
expect(wrapper.vm.localChecked).toBeDefined()
|
|
656
|
-
expect(wrapper.vm.localChecked).toEqual('bar')
|
|
657
|
-
|
|
658
|
-
wrapper.destroy()
|
|
659
|
-
})
|
|
660
|
-
|
|
661
|
-
it('default has internal localChecked set to value when checked changed to value', async () => {
|
|
662
|
-
const wrapper = mount(BFormCheckbox, {
|
|
663
|
-
propsData: {
|
|
664
|
-
uncheckedValue: 'foo',
|
|
665
|
-
value: 'bar'
|
|
666
|
-
},
|
|
667
|
-
slots: {
|
|
668
|
-
default: 'foobar'
|
|
669
|
-
}
|
|
670
|
-
})
|
|
671
|
-
|
|
672
|
-
expect(wrapper.vm).toBeDefined()
|
|
673
|
-
expect(wrapper.vm.localChecked).toBeDefined()
|
|
674
|
-
expect(wrapper.vm.localChecked).toBe(null)
|
|
675
|
-
|
|
676
|
-
await wrapper.setProps({ checked: 'bar' })
|
|
677
|
-
expect(wrapper.vm.localChecked).toEqual('bar')
|
|
678
|
-
expect(wrapper.emitted('input')).toBeDefined()
|
|
679
|
-
|
|
680
|
-
const $last = wrapper.emitted('input').length - 1
|
|
681
|
-
expect(wrapper.emitted('input')[$last]).toBeDefined()
|
|
682
|
-
expect(wrapper.emitted('input')[$last][0]).toEqual('bar')
|
|
683
|
-
|
|
684
|
-
wrapper.destroy()
|
|
685
|
-
})
|
|
686
|
-
|
|
687
|
-
it('emits a change event when clicked', async () => {
|
|
688
|
-
const wrapper = mount(BFormCheckbox, {
|
|
689
|
-
attachTo: document.body,
|
|
690
|
-
propsData: {
|
|
691
|
-
uncheckedValue: 'foo',
|
|
692
|
-
value: 'bar'
|
|
693
|
-
},
|
|
694
|
-
slots: {
|
|
695
|
-
default: 'foobar'
|
|
696
|
-
}
|
|
697
|
-
})
|
|
698
|
-
|
|
699
|
-
expect(wrapper.vm).toBeDefined()
|
|
700
|
-
expect(wrapper.vm.localChecked).toBeDefined()
|
|
701
|
-
expect(wrapper.vm.localChecked).toBe(null)
|
|
702
|
-
expect(wrapper.emitted('change')).toBeUndefined()
|
|
703
|
-
|
|
704
|
-
const $input = wrapper.find('input')
|
|
705
|
-
expect($input).toBeDefined()
|
|
706
|
-
|
|
707
|
-
await $input.trigger('click')
|
|
708
|
-
expect(wrapper.emitted('change')).toBeDefined()
|
|
709
|
-
expect(wrapper.emitted('change').length).toBe(1)
|
|
710
|
-
expect(wrapper.emitted('change')[0][0]).toEqual('bar')
|
|
711
|
-
|
|
712
|
-
await $input.trigger('click')
|
|
713
|
-
expect(wrapper.emitted('change')).toBeDefined()
|
|
714
|
-
expect(wrapper.emitted('change').length).toBe(2)
|
|
715
|
-
expect(wrapper.emitted('change')[1][0]).toEqual('foo')
|
|
716
|
-
|
|
717
|
-
wrapper.destroy()
|
|
718
|
-
})
|
|
719
|
-
|
|
720
|
-
it('works when v-model bound to an array', async () => {
|
|
721
|
-
const wrapper = mount(BFormCheckbox, {
|
|
722
|
-
attachTo: document.body,
|
|
723
|
-
propsData: {
|
|
724
|
-
value: 'bar',
|
|
725
|
-
checked: ['foo']
|
|
726
|
-
},
|
|
727
|
-
slots: {
|
|
728
|
-
default: 'foobar'
|
|
729
|
-
}
|
|
730
|
-
})
|
|
731
|
-
|
|
732
|
-
expect(wrapper.vm).toBeDefined()
|
|
733
|
-
expect(wrapper.vm.localChecked).toBeDefined()
|
|
734
|
-
expect(Array.isArray(wrapper.vm.localChecked)).toBe(true)
|
|
735
|
-
expect(wrapper.vm.localChecked.length).toBe(1)
|
|
736
|
-
expect(wrapper.vm.localChecked[0]).toEqual('foo')
|
|
737
|
-
|
|
738
|
-
const $input = wrapper.find('input')
|
|
739
|
-
expect($input).toBeDefined()
|
|
740
|
-
|
|
741
|
-
await $input.trigger('click')
|
|
742
|
-
expect(Array.isArray(wrapper.vm.localChecked)).toBe(true)
|
|
743
|
-
expect(wrapper.vm.localChecked.length).toBe(2)
|
|
744
|
-
expect(wrapper.vm.localChecked[0]).toEqual('foo')
|
|
745
|
-
expect(wrapper.vm.localChecked[1]).toEqual('bar')
|
|
746
|
-
expect(wrapper.emitted('change')).toBeDefined()
|
|
747
|
-
expect(wrapper.emitted('change').length).toBe(1)
|
|
748
|
-
expect(wrapper.emitted('change')[0][0]).toEqual(['foo', 'bar'])
|
|
749
|
-
|
|
750
|
-
await $input.trigger('click')
|
|
751
|
-
expect(Array.isArray(wrapper.vm.localChecked)).toBe(true)
|
|
752
|
-
expect(wrapper.vm.localChecked.length).toBe(1)
|
|
753
|
-
expect(wrapper.vm.localChecked[0]).toEqual('foo')
|
|
754
|
-
expect(wrapper.emitted('change')).toBeDefined()
|
|
755
|
-
expect(wrapper.emitted('change').length).toBe(2)
|
|
756
|
-
expect(wrapper.emitted('change')[1][0]).toEqual(['foo'])
|
|
757
|
-
|
|
758
|
-
await wrapper.setProps({ checked: [] })
|
|
759
|
-
expect(Array.isArray(wrapper.vm.localChecked)).toBe(true)
|
|
760
|
-
expect(wrapper.vm.localChecked.length).toBe(0)
|
|
761
|
-
expect(wrapper.emitted('change')).toBeDefined()
|
|
762
|
-
expect(wrapper.emitted('change').length).toBe(2)
|
|
763
|
-
|
|
764
|
-
await $input.trigger('click')
|
|
765
|
-
expect(Array.isArray(wrapper.vm.localChecked)).toBe(true)
|
|
766
|
-
expect(wrapper.vm.localChecked.length).toBe(1)
|
|
767
|
-
expect(wrapper.vm.localChecked[0]).toEqual('bar')
|
|
768
|
-
expect(wrapper.emitted('change')).toBeDefined()
|
|
769
|
-
expect(wrapper.emitted('change').length).toBe(3)
|
|
770
|
-
expect(wrapper.emitted('change')[2][0]).toEqual(['bar'])
|
|
771
|
-
|
|
772
|
-
await $input.trigger('click')
|
|
773
|
-
expect(Array.isArray(wrapper.vm.localChecked)).toBe(true)
|
|
774
|
-
expect(wrapper.vm.localChecked.length).toBe(0)
|
|
775
|
-
expect(wrapper.emitted('change')).toBeDefined()
|
|
776
|
-
expect(wrapper.emitted('change').length).toBe(4)
|
|
777
|
-
expect(wrapper.emitted('change')[3][0]).toEqual([])
|
|
778
|
-
|
|
779
|
-
wrapper.destroy()
|
|
780
|
-
})
|
|
781
|
-
|
|
782
|
-
it('works when value is an object', async () => {
|
|
783
|
-
const wrapper = mount(BFormCheckbox, {
|
|
784
|
-
attachTo: document.body,
|
|
785
|
-
propsData: {
|
|
786
|
-
value: { bar: 1, baz: 2 },
|
|
787
|
-
checked: ['foo']
|
|
788
|
-
},
|
|
789
|
-
slots: {
|
|
790
|
-
default: 'foobar'
|
|
791
|
-
}
|
|
792
|
-
})
|
|
793
|
-
|
|
794
|
-
expect(wrapper.vm).toBeDefined()
|
|
795
|
-
expect(wrapper.vm.localChecked).toBeDefined()
|
|
796
|
-
expect(Array.isArray(wrapper.vm.localChecked)).toBe(true)
|
|
797
|
-
expect(wrapper.vm.localChecked.length).toBe(1)
|
|
798
|
-
expect(wrapper.vm.localChecked[0]).toEqual('foo')
|
|
799
|
-
|
|
800
|
-
const $input = wrapper.find('input')
|
|
801
|
-
expect($input).toBeDefined()
|
|
802
|
-
|
|
803
|
-
await $input.trigger('click')
|
|
804
|
-
expect(Array.isArray(wrapper.vm.localChecked)).toBe(true)
|
|
805
|
-
expect(wrapper.vm.localChecked.length).toBe(2)
|
|
806
|
-
expect(wrapper.vm.localChecked[0]).toEqual('foo')
|
|
807
|
-
expect(wrapper.vm.localChecked[1]).toEqual({ bar: 1, baz: 2 })
|
|
808
|
-
|
|
809
|
-
await $input.trigger('click')
|
|
810
|
-
expect(Array.isArray(wrapper.vm.localChecked)).toBe(true)
|
|
811
|
-
expect(wrapper.vm.localChecked.length).toBe(1)
|
|
812
|
-
expect(wrapper.vm.localChecked[0]).toEqual('foo')
|
|
813
|
-
|
|
814
|
-
wrapper.destroy()
|
|
815
|
-
})
|
|
816
|
-
|
|
817
|
-
it('focus() and blur() methods work', async () => {
|
|
818
|
-
const wrapper = mount(BFormCheckbox, {
|
|
819
|
-
attachTo: document.body,
|
|
820
|
-
propsData: {
|
|
821
|
-
checked: false
|
|
822
|
-
},
|
|
823
|
-
slots: {
|
|
824
|
-
default: 'foobar'
|
|
825
|
-
}
|
|
826
|
-
})
|
|
827
|
-
|
|
828
|
-
expect(wrapper.vm).toBeDefined()
|
|
829
|
-
|
|
830
|
-
const $input = wrapper.find('input')
|
|
831
|
-
expect($input).toBeDefined()
|
|
832
|
-
expect(document).toBeDefined()
|
|
833
|
-
|
|
834
|
-
expect(wrapper.vm.focus).toBeDefined()
|
|
835
|
-
expect(typeof wrapper.vm.focus).toBe('function')
|
|
836
|
-
expect(wrapper.vm.blur).toBeDefined()
|
|
837
|
-
expect(typeof wrapper.vm.blur).toBe('function')
|
|
838
|
-
expect($input.element).not.toBe(document.activeElement)
|
|
839
|
-
|
|
840
|
-
wrapper.vm.focus()
|
|
841
|
-
await waitNT(wrapper.vm)
|
|
842
|
-
expect($input.element).toBe(document.activeElement)
|
|
843
|
-
|
|
844
|
-
wrapper.vm.blur()
|
|
845
|
-
await waitNT(wrapper.vm)
|
|
846
|
-
expect($input.element).not.toBe(document.activeElement)
|
|
847
|
-
|
|
848
|
-
wrapper.destroy()
|
|
849
|
-
})
|
|
850
|
-
|
|
851
|
-
// These tests are wrapped in a new describe to limit the scope
|
|
852
|
-
// of the `getBoundingClientRect()` mock
|
|
853
|
-
describe('prop `autofocus`', () => {
|
|
854
|
-
const origGetBCR = Element.prototype.getBoundingClientRect
|
|
855
|
-
|
|
856
|
-
beforeEach(() => {
|
|
857
|
-
// Mock `getBoundingClientRect()` so that the `isVisible(el)` test returns `true`
|
|
858
|
-
// In our test below, all pagination buttons would normally be visible
|
|
859
|
-
Element.prototype.getBoundingClientRect = jest.fn(() => ({
|
|
860
|
-
width: 24,
|
|
861
|
-
height: 24,
|
|
862
|
-
top: 0,
|
|
863
|
-
left: 0,
|
|
864
|
-
bottom: 0,
|
|
865
|
-
right: 0
|
|
866
|
-
}))
|
|
867
|
-
})
|
|
868
|
-
|
|
869
|
-
afterEach(() => {
|
|
870
|
-
// Restore prototype
|
|
871
|
-
Element.prototype.getBoundingClientRect = origGetBCR
|
|
872
|
-
})
|
|
873
|
-
|
|
874
|
-
it('works when true', async () => {
|
|
875
|
-
const wrapper = mount(BFormCheckbox, {
|
|
876
|
-
attachTo: document.body,
|
|
877
|
-
propsData: {
|
|
878
|
-
checked: false,
|
|
879
|
-
autofocus: true
|
|
880
|
-
},
|
|
881
|
-
slots: {
|
|
882
|
-
default: 'foobar'
|
|
883
|
-
}
|
|
884
|
-
})
|
|
885
|
-
|
|
886
|
-
expect(wrapper.vm).toBeDefined()
|
|
887
|
-
await waitNT(wrapper.vm)
|
|
888
|
-
await waitRAF()
|
|
889
|
-
|
|
890
|
-
const $input = wrapper.find('input')
|
|
891
|
-
expect($input.exists()).toBe(true)
|
|
892
|
-
expect(document).toBeDefined()
|
|
893
|
-
expect(document.activeElement).toBe($input.element)
|
|
894
|
-
|
|
895
|
-
wrapper.destroy()
|
|
896
|
-
})
|
|
897
|
-
|
|
898
|
-
it('does not auto focus when false', async () => {
|
|
899
|
-
const wrapper = mount(BFormCheckbox, {
|
|
900
|
-
attachTo: document.body,
|
|
901
|
-
propsData: {
|
|
902
|
-
checked: false,
|
|
903
|
-
autofocus: false
|
|
904
|
-
},
|
|
905
|
-
slots: {
|
|
906
|
-
default: 'foobar'
|
|
907
|
-
}
|
|
908
|
-
})
|
|
909
|
-
|
|
910
|
-
expect(wrapper.vm).toBeDefined()
|
|
911
|
-
await waitNT(wrapper.vm)
|
|
912
|
-
await waitRAF()
|
|
913
|
-
|
|
914
|
-
const $input = wrapper.find('input')
|
|
915
|
-
expect($input.exists()).toBe(true)
|
|
916
|
-
expect(document).toBeDefined()
|
|
917
|
-
expect(document.activeElement).not.toBe($input.element)
|
|
918
|
-
|
|
919
|
-
wrapper.destroy()
|
|
920
|
-
})
|
|
921
|
-
})
|
|
922
|
-
})
|