@gitlab/ui 111.6.0 → 111.7.0
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/CHANGELOG.md +7 -0
- package/dist/components/charts/chart/chart.js +29 -23
- package/dist/utils/charts/config.js +1 -4
- package/dist/vendor/bootstrap-vue/src/constants/components.js +1 -7
- package/package.json +1 -1
- package/src/components/charts/chart/chart.vue +17 -20
- package/src/utils/charts/config.js +0 -3
- package/src/vendor/bootstrap-vue/src/constants/components.js +0 -6
- package/dist/vendor/bootstrap-vue/src/components/form-input/form-input.js +0 -157
- package/dist/vendor/bootstrap-vue/src/components/form-input/index.js +0 -1
- package/dist/vendor/bootstrap-vue/src/components/input-group/index.js +0 -5
- package/dist/vendor/bootstrap-vue/src/components/input-group/input-group-addon.js +0 -44
- package/dist/vendor/bootstrap-vue/src/components/input-group/input-group-append.js +0 -34
- package/dist/vendor/bootstrap-vue/src/components/input-group/input-group-prepend.js +0 -34
- package/dist/vendor/bootstrap-vue/src/components/input-group/input-group-text.js +0 -31
- package/dist/vendor/bootstrap-vue/src/components/input-group/input-group.js +0 -75
- package/src/vendor/bootstrap-vue/src/components/form-input/README.md +0 -612
- package/src/vendor/bootstrap-vue/src/components/form-input/form-input.js +0 -168
- package/src/vendor/bootstrap-vue/src/components/form-input/form-input.spec.js +0 -989
- package/src/vendor/bootstrap-vue/src/components/form-input/index.js +0 -3
- package/src/vendor/bootstrap-vue/src/components/form-input/package.json +0 -135
- package/src/vendor/bootstrap-vue/src/components/input-group/README.md +0 -329
- package/src/vendor/bootstrap-vue/src/components/input-group/index.js +0 -7
- package/src/vendor/bootstrap-vue/src/components/input-group/input-group-addon.js +0 -43
- package/src/vendor/bootstrap-vue/src/components/input-group/input-group-append.js +0 -31
- package/src/vendor/bootstrap-vue/src/components/input-group/input-group-append.spec.js +0 -84
- package/src/vendor/bootstrap-vue/src/components/input-group/input-group-prepend.js +0 -31
- package/src/vendor/bootstrap-vue/src/components/input-group/input-group-prepend.spec.js +0 -84
- package/src/vendor/bootstrap-vue/src/components/input-group/input-group-text.js +0 -31
- package/src/vendor/bootstrap-vue/src/components/input-group/input-group-text.spec.js +0 -45
- package/src/vendor/bootstrap-vue/src/components/input-group/input-group.js +0 -73
- package/src/vendor/bootstrap-vue/src/components/input-group/input-group.spec.js +0 -153
- package/src/vendor/bootstrap-vue/src/components/input-group/package.json +0 -109
|
@@ -1,989 +0,0 @@
|
|
|
1
|
-
import Vue from 'vue'
|
|
2
|
-
import { mount } from '@vue/test-utils'
|
|
3
|
-
import { waitNT, waitRAF } from '../../../tests/utils'
|
|
4
|
-
import { BFormInput } from './form-input'
|
|
5
|
-
|
|
6
|
-
describe('form-input', () => {
|
|
7
|
-
it('has class form-control', async () => {
|
|
8
|
-
const wrapper = mount(BFormInput)
|
|
9
|
-
|
|
10
|
-
const $input = wrapper.find('input')
|
|
11
|
-
expect($input.classes()).toContain('form-control')
|
|
12
|
-
|
|
13
|
-
wrapper.destroy()
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
it('has class form-control-lg when size=lg and plane=false', async () => {
|
|
17
|
-
const wrapper = mount(BFormInput, {
|
|
18
|
-
propsData: {
|
|
19
|
-
size: 'lg'
|
|
20
|
-
}
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
const $input = wrapper.find('input')
|
|
24
|
-
expect($input.classes()).toContain('form-control-lg')
|
|
25
|
-
|
|
26
|
-
wrapper.destroy()
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
it('has class form-control-sm when size=lg and plain=false', async () => {
|
|
30
|
-
const wrapper = mount(BFormInput, {
|
|
31
|
-
propsData: {
|
|
32
|
-
size: 'sm'
|
|
33
|
-
}
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
const $input = wrapper.find('input')
|
|
37
|
-
expect($input.classes()).toContain('form-control-sm')
|
|
38
|
-
|
|
39
|
-
wrapper.destroy()
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
it('does not have class form-control-plaintext when plaintext not set', async () => {
|
|
43
|
-
const wrapper = mount(BFormInput)
|
|
44
|
-
|
|
45
|
-
const $input = wrapper.find('input')
|
|
46
|
-
expect($input.classes()).not.toContain('form-control-plaintext')
|
|
47
|
-
expect($input.attributes('readonly')).toBeUndefined()
|
|
48
|
-
|
|
49
|
-
wrapper.destroy()
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
it('has class form-control-plaintext when plaintext=true', async () => {
|
|
53
|
-
const wrapper = mount(BFormInput, {
|
|
54
|
-
propsData: {
|
|
55
|
-
plaintext: true
|
|
56
|
-
}
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
const $input = wrapper.find('input')
|
|
60
|
-
expect($input.classes()).toContain('form-control-plaintext')
|
|
61
|
-
|
|
62
|
-
wrapper.destroy()
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
it('has attribute read-only when plaintext=true', async () => {
|
|
66
|
-
const wrapper = mount(BFormInput, {
|
|
67
|
-
propsData: {
|
|
68
|
-
plaintext: true
|
|
69
|
-
}
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
const $input = wrapper.find('input')
|
|
73
|
-
expect($input.classes()).toContain('form-control-plaintext')
|
|
74
|
-
expect($input.attributes('readonly')).toBeDefined()
|
|
75
|
-
|
|
76
|
-
wrapper.destroy()
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
it('has class custom-range instead of form-control when type=range', async () => {
|
|
80
|
-
const wrapper = mount(BFormInput, {
|
|
81
|
-
propsData: {
|
|
82
|
-
type: 'range'
|
|
83
|
-
}
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
const $input = wrapper.find('input')
|
|
87
|
-
expect($input.classes()).toContain('custom-range')
|
|
88
|
-
expect($input.classes()).not.toContain('form-control')
|
|
89
|
-
|
|
90
|
-
wrapper.destroy()
|
|
91
|
-
})
|
|
92
|
-
|
|
93
|
-
it('does not have class form-control-plaintext when type=range and plaintext=true', async () => {
|
|
94
|
-
const wrapper = mount(BFormInput, {
|
|
95
|
-
propsData: {
|
|
96
|
-
type: 'range',
|
|
97
|
-
plaintext: true
|
|
98
|
-
}
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
const $input = wrapper.find('input')
|
|
102
|
-
expect($input.classes()).toContain('custom-range')
|
|
103
|
-
expect($input.classes()).not.toContain('form-control')
|
|
104
|
-
expect($input.classes()).not.toContain('form-control-plaintext')
|
|
105
|
-
|
|
106
|
-
wrapper.destroy()
|
|
107
|
-
})
|
|
108
|
-
|
|
109
|
-
it('does not have class form-control-plaintext when type=color and plaintext=true', async () => {
|
|
110
|
-
const wrapper = mount(BFormInput, {
|
|
111
|
-
propsData: {
|
|
112
|
-
type: 'color',
|
|
113
|
-
plaintext: true
|
|
114
|
-
}
|
|
115
|
-
})
|
|
116
|
-
|
|
117
|
-
const $input = wrapper.find('input')
|
|
118
|
-
expect($input.classes()).not.toContain('custom-range')
|
|
119
|
-
expect($input.classes()).not.toContain('form-control-plaintext')
|
|
120
|
-
expect($input.classes()).toContain('form-control')
|
|
121
|
-
|
|
122
|
-
wrapper.destroy()
|
|
123
|
-
})
|
|
124
|
-
|
|
125
|
-
it('has user supplied id', async () => {
|
|
126
|
-
const wrapper = mount(BFormInput, {
|
|
127
|
-
propsData: {
|
|
128
|
-
id: 'foobar'
|
|
129
|
-
}
|
|
130
|
-
})
|
|
131
|
-
|
|
132
|
-
const $input = wrapper.find('input')
|
|
133
|
-
expect($input.attributes('id')).toBe('foobar')
|
|
134
|
-
|
|
135
|
-
wrapper.destroy()
|
|
136
|
-
})
|
|
137
|
-
|
|
138
|
-
it('has safeId after mount when no id provided', async () => {
|
|
139
|
-
const wrapper = mount(BFormInput, {
|
|
140
|
-
attachTo: document.body
|
|
141
|
-
})
|
|
142
|
-
|
|
143
|
-
// We need to wait a tick for `safeId` to be generated
|
|
144
|
-
await waitNT(wrapper.vm)
|
|
145
|
-
|
|
146
|
-
const $input = wrapper.find('input')
|
|
147
|
-
expect($input.attributes('id')).toBeDefined()
|
|
148
|
-
|
|
149
|
-
wrapper.destroy()
|
|
150
|
-
})
|
|
151
|
-
|
|
152
|
-
it('has form attribute when form prop set', async () => {
|
|
153
|
-
const wrapper = mount(BFormInput, {
|
|
154
|
-
propsData: {
|
|
155
|
-
form: 'foobar'
|
|
156
|
-
}
|
|
157
|
-
})
|
|
158
|
-
|
|
159
|
-
const $input = wrapper.find('input')
|
|
160
|
-
expect($input.attributes('form')).toBe('foobar')
|
|
161
|
-
|
|
162
|
-
wrapper.destroy()
|
|
163
|
-
})
|
|
164
|
-
|
|
165
|
-
it('does not have list attribute when list prop not set', async () => {
|
|
166
|
-
const wrapper = mount(BFormInput)
|
|
167
|
-
|
|
168
|
-
const $input = wrapper.find('input')
|
|
169
|
-
expect($input.attributes('list')).toBeUndefined()
|
|
170
|
-
|
|
171
|
-
wrapper.destroy()
|
|
172
|
-
})
|
|
173
|
-
|
|
174
|
-
it('has list attribute when list prop set', async () => {
|
|
175
|
-
const wrapper = mount(BFormInput, {
|
|
176
|
-
propsData: {
|
|
177
|
-
list: 'foobar'
|
|
178
|
-
}
|
|
179
|
-
})
|
|
180
|
-
|
|
181
|
-
const $input = wrapper.find('input')
|
|
182
|
-
expect($input.attributes('list')).toBe('foobar')
|
|
183
|
-
|
|
184
|
-
wrapper.destroy()
|
|
185
|
-
})
|
|
186
|
-
|
|
187
|
-
it('does not have list attribute when list prop set and type=password', async () => {
|
|
188
|
-
const wrapper = mount(BFormInput, {
|
|
189
|
-
propsData: {
|
|
190
|
-
list: 'foobar',
|
|
191
|
-
type: 'password'
|
|
192
|
-
}
|
|
193
|
-
})
|
|
194
|
-
|
|
195
|
-
const $input = wrapper.find('input')
|
|
196
|
-
expect($input.attributes('list')).toBeUndefined()
|
|
197
|
-
|
|
198
|
-
wrapper.destroy()
|
|
199
|
-
})
|
|
200
|
-
|
|
201
|
-
it('renders text input by default', async () => {
|
|
202
|
-
const wrapper = mount(BFormInput)
|
|
203
|
-
|
|
204
|
-
const $input = wrapper.find('input')
|
|
205
|
-
expect($input.attributes('type')).toBe('text')
|
|
206
|
-
|
|
207
|
-
wrapper.destroy()
|
|
208
|
-
})
|
|
209
|
-
|
|
210
|
-
it('renders number input when type set to number', async () => {
|
|
211
|
-
const wrapper = mount(BFormInput, {
|
|
212
|
-
propsData: {
|
|
213
|
-
type: 'number'
|
|
214
|
-
}
|
|
215
|
-
})
|
|
216
|
-
|
|
217
|
-
const $input = wrapper.find('input')
|
|
218
|
-
expect($input.attributes('type')).toBe('number')
|
|
219
|
-
|
|
220
|
-
wrapper.destroy()
|
|
221
|
-
})
|
|
222
|
-
|
|
223
|
-
it('renders text input when type not supported', async () => {
|
|
224
|
-
const { warnHandler } = Vue.config
|
|
225
|
-
Vue.config.warnHandler = jest.fn()
|
|
226
|
-
|
|
227
|
-
const wrapper = mount(BFormInput, {
|
|
228
|
-
propsData: {
|
|
229
|
-
type: 'foobar'
|
|
230
|
-
}
|
|
231
|
-
})
|
|
232
|
-
|
|
233
|
-
const $input = wrapper.find('input')
|
|
234
|
-
expect($input.attributes('type')).toBe('text')
|
|
235
|
-
|
|
236
|
-
expect(Vue.config.warnHandler).toHaveBeenCalled()
|
|
237
|
-
Vue.config.warnHandler = warnHandler
|
|
238
|
-
|
|
239
|
-
wrapper.destroy()
|
|
240
|
-
})
|
|
241
|
-
|
|
242
|
-
it('does not have is-valid or is-invalid classes when state is default', async () => {
|
|
243
|
-
const wrapper = mount(BFormInput)
|
|
244
|
-
|
|
245
|
-
const $input = wrapper.find('input')
|
|
246
|
-
expect($input.classes()).not.toContain('is-valid')
|
|
247
|
-
expect($input.classes()).not.toContain('is-invalid')
|
|
248
|
-
|
|
249
|
-
wrapper.destroy()
|
|
250
|
-
})
|
|
251
|
-
|
|
252
|
-
it('has class is-valid when state=true', async () => {
|
|
253
|
-
const wrapper = mount(BFormInput, {
|
|
254
|
-
propsData: {
|
|
255
|
-
state: true
|
|
256
|
-
}
|
|
257
|
-
})
|
|
258
|
-
|
|
259
|
-
const $input = wrapper.find('input')
|
|
260
|
-
expect($input.classes()).toContain('is-valid')
|
|
261
|
-
expect($input.classes()).not.toContain('is-invalid')
|
|
262
|
-
|
|
263
|
-
wrapper.destroy()
|
|
264
|
-
})
|
|
265
|
-
|
|
266
|
-
it('has class is-invalid when state=false', async () => {
|
|
267
|
-
const wrapper = mount(BFormInput, {
|
|
268
|
-
propsData: {
|
|
269
|
-
state: false
|
|
270
|
-
}
|
|
271
|
-
})
|
|
272
|
-
|
|
273
|
-
const $input = wrapper.find('input')
|
|
274
|
-
expect($input.classes()).toContain('is-invalid')
|
|
275
|
-
expect($input.classes()).not.toContain('is-valid')
|
|
276
|
-
|
|
277
|
-
wrapper.destroy()
|
|
278
|
-
})
|
|
279
|
-
|
|
280
|
-
it('does not have aria-invalid attribute by default', async () => {
|
|
281
|
-
const wrapper = mount(BFormInput)
|
|
282
|
-
|
|
283
|
-
expect(wrapper.attributes('aria-invalid')).toBeUndefined()
|
|
284
|
-
|
|
285
|
-
wrapper.destroy()
|
|
286
|
-
})
|
|
287
|
-
|
|
288
|
-
it('does not have aria-invalid attribute when state is true', async () => {
|
|
289
|
-
const wrapper = mount(BFormInput, {
|
|
290
|
-
propsData: {
|
|
291
|
-
state: true
|
|
292
|
-
}
|
|
293
|
-
})
|
|
294
|
-
|
|
295
|
-
expect(wrapper.attributes('aria-invalid')).toBeUndefined()
|
|
296
|
-
|
|
297
|
-
wrapper.destroy()
|
|
298
|
-
})
|
|
299
|
-
|
|
300
|
-
it('has aria-invalid attribute when state=false', async () => {
|
|
301
|
-
const wrapper = mount(BFormInput, {
|
|
302
|
-
propsData: {
|
|
303
|
-
state: false
|
|
304
|
-
}
|
|
305
|
-
})
|
|
306
|
-
|
|
307
|
-
const $input = wrapper.find('input')
|
|
308
|
-
expect($input.attributes('aria-invalid')).toBe('true')
|
|
309
|
-
|
|
310
|
-
wrapper.destroy()
|
|
311
|
-
})
|
|
312
|
-
|
|
313
|
-
it('has aria-invalid attribute when aria-invalid="true"', async () => {
|
|
314
|
-
const wrapper = mount(BFormInput, {
|
|
315
|
-
propsData: {
|
|
316
|
-
ariaInvalid: 'true'
|
|
317
|
-
}
|
|
318
|
-
})
|
|
319
|
-
|
|
320
|
-
const $input = wrapper.find('input')
|
|
321
|
-
expect($input.attributes('aria-invalid')).toBe('true')
|
|
322
|
-
|
|
323
|
-
wrapper.destroy()
|
|
324
|
-
})
|
|
325
|
-
|
|
326
|
-
it('has aria-invalid attribute when aria-invalid=true', async () => {
|
|
327
|
-
const wrapper = mount(BFormInput, {
|
|
328
|
-
propsData: {
|
|
329
|
-
ariaInvalid: true
|
|
330
|
-
}
|
|
331
|
-
})
|
|
332
|
-
|
|
333
|
-
const $input = wrapper.find('input')
|
|
334
|
-
expect($input.attributes('aria-invalid')).toBe('true')
|
|
335
|
-
|
|
336
|
-
wrapper.destroy()
|
|
337
|
-
})
|
|
338
|
-
|
|
339
|
-
it('has aria-invalid attribute when aria-invalid="spelling"', async () => {
|
|
340
|
-
const wrapper = mount(BFormInput, {
|
|
341
|
-
propsData: {
|
|
342
|
-
ariaInvalid: 'spelling'
|
|
343
|
-
}
|
|
344
|
-
})
|
|
345
|
-
|
|
346
|
-
const $input = wrapper.find('input')
|
|
347
|
-
expect($input.attributes('aria-invalid')).toBe('spelling')
|
|
348
|
-
|
|
349
|
-
wrapper.destroy()
|
|
350
|
-
})
|
|
351
|
-
|
|
352
|
-
it('is disabled when disabled=true', async () => {
|
|
353
|
-
const wrapper = mount(BFormInput, {
|
|
354
|
-
propsData: {
|
|
355
|
-
disabled: true
|
|
356
|
-
}
|
|
357
|
-
})
|
|
358
|
-
|
|
359
|
-
const $input = wrapper.find('input')
|
|
360
|
-
expect(!!$input.attributes('disabled')).toBe(true)
|
|
361
|
-
expect($input.element.disabled).toBe(true)
|
|
362
|
-
|
|
363
|
-
wrapper.destroy()
|
|
364
|
-
})
|
|
365
|
-
|
|
366
|
-
it('is not disabled when disabled=false', async () => {
|
|
367
|
-
const wrapper = mount(BFormInput, {
|
|
368
|
-
propsData: {
|
|
369
|
-
disabled: false
|
|
370
|
-
}
|
|
371
|
-
})
|
|
372
|
-
|
|
373
|
-
const $input = wrapper.find('input')
|
|
374
|
-
expect(!!$input.attributes('disabled')).toBe(false)
|
|
375
|
-
expect($input.element.disabled).toBe(false)
|
|
376
|
-
|
|
377
|
-
wrapper.destroy()
|
|
378
|
-
})
|
|
379
|
-
|
|
380
|
-
it('emits an input event', async () => {
|
|
381
|
-
const wrapper = mount(BFormInput)
|
|
382
|
-
|
|
383
|
-
const $input = wrapper.find('input')
|
|
384
|
-
$input.element.value = 'test'
|
|
385
|
-
await $input.trigger('input')
|
|
386
|
-
|
|
387
|
-
expect(wrapper.emitted('input')).toBeDefined()
|
|
388
|
-
expect(wrapper.emitted().input[0].length).toEqual(1)
|
|
389
|
-
expect(wrapper.emitted().input[0][0]).toEqual('test')
|
|
390
|
-
|
|
391
|
-
wrapper.destroy()
|
|
392
|
-
})
|
|
393
|
-
|
|
394
|
-
it('emits a native focus event', async () => {
|
|
395
|
-
const spy = jest.fn()
|
|
396
|
-
const wrapper = mount(BFormInput, {
|
|
397
|
-
attachTo: document.body,
|
|
398
|
-
listeners: {
|
|
399
|
-
focus: spy
|
|
400
|
-
}
|
|
401
|
-
})
|
|
402
|
-
|
|
403
|
-
const $input = wrapper.find('input')
|
|
404
|
-
|
|
405
|
-
await $input.trigger('focus')
|
|
406
|
-
expect(wrapper.emitted()).toMatchObject({})
|
|
407
|
-
expect(spy).toHaveBeenCalled()
|
|
408
|
-
|
|
409
|
-
wrapper.destroy()
|
|
410
|
-
})
|
|
411
|
-
|
|
412
|
-
it('emits a blur event with native event as only arg', async () => {
|
|
413
|
-
const wrapper = mount(BFormInput, {
|
|
414
|
-
propsData: {
|
|
415
|
-
value: 'TEST'
|
|
416
|
-
}
|
|
417
|
-
})
|
|
418
|
-
|
|
419
|
-
const $input = wrapper.find('input')
|
|
420
|
-
await $input.trigger('blur')
|
|
421
|
-
|
|
422
|
-
expect(wrapper.emitted('blur')).toBeDefined()
|
|
423
|
-
expect(wrapper.emitted('blur')[0].length).toEqual(1)
|
|
424
|
-
expect(wrapper.emitted('blur')[0][0] instanceof Event).toBe(true)
|
|
425
|
-
expect(wrapper.emitted('blur')[0][0].type).toEqual('blur')
|
|
426
|
-
|
|
427
|
-
wrapper.destroy()
|
|
428
|
-
})
|
|
429
|
-
|
|
430
|
-
it('applies formatter on input when not lazy', async () => {
|
|
431
|
-
const wrapper = mount(BFormInput, {
|
|
432
|
-
propsData: {
|
|
433
|
-
formatter(value) {
|
|
434
|
-
return value.toLowerCase()
|
|
435
|
-
}
|
|
436
|
-
},
|
|
437
|
-
attachTo: document.body
|
|
438
|
-
})
|
|
439
|
-
|
|
440
|
-
const $input = wrapper.find('input')
|
|
441
|
-
$input.element.value = 'TEST'
|
|
442
|
-
await $input.trigger('input')
|
|
443
|
-
|
|
444
|
-
expect(wrapper.emitted('update')).toBeDefined()
|
|
445
|
-
expect(wrapper.emitted('update').length).toEqual(1)
|
|
446
|
-
expect(wrapper.emitted('update')[0][0]).toEqual('test')
|
|
447
|
-
|
|
448
|
-
expect(wrapper.emitted('input')).toBeDefined()
|
|
449
|
-
expect(wrapper.emitted('input').length).toEqual(1)
|
|
450
|
-
expect(wrapper.emitted('input')[0][0]).toEqual('test')
|
|
451
|
-
|
|
452
|
-
wrapper.destroy()
|
|
453
|
-
})
|
|
454
|
-
|
|
455
|
-
it('does not apply formatter on input when lazy', async () => {
|
|
456
|
-
const wrapper = mount(BFormInput, {
|
|
457
|
-
propsData: {
|
|
458
|
-
formatter(value) {
|
|
459
|
-
return value.toLowerCase()
|
|
460
|
-
},
|
|
461
|
-
lazyFormatter: true
|
|
462
|
-
},
|
|
463
|
-
attachTo: document.body
|
|
464
|
-
})
|
|
465
|
-
|
|
466
|
-
const $input = wrapper.findComponent('input')
|
|
467
|
-
$input.element.value = 'TEST'
|
|
468
|
-
await $input.trigger('input')
|
|
469
|
-
|
|
470
|
-
expect(wrapper.emitted('update')).toBeDefined()
|
|
471
|
-
expect(wrapper.emitted('update').length).toEqual(1)
|
|
472
|
-
expect(wrapper.emitted('update')[0][0]).toEqual('TEST')
|
|
473
|
-
expect(wrapper.emitted('input')).toBeDefined()
|
|
474
|
-
expect(wrapper.emitted('input').length).toEqual(1)
|
|
475
|
-
expect(wrapper.emitted('input')[0][0]).toEqual('TEST')
|
|
476
|
-
expect(wrapper.emitted('change')).toBeUndefined()
|
|
477
|
-
expect($input.vm.localValue).toEqual('TEST')
|
|
478
|
-
|
|
479
|
-
wrapper.destroy()
|
|
480
|
-
})
|
|
481
|
-
|
|
482
|
-
it('applies formatter on blur when lazy', async () => {
|
|
483
|
-
const wrapper = mount(BFormInput, {
|
|
484
|
-
propsData: {
|
|
485
|
-
value: '',
|
|
486
|
-
formatter(value) {
|
|
487
|
-
return value.toLowerCase()
|
|
488
|
-
},
|
|
489
|
-
lazyFormatter: true
|
|
490
|
-
},
|
|
491
|
-
attachTo: document.body
|
|
492
|
-
})
|
|
493
|
-
|
|
494
|
-
const $input = wrapper.findComponent('input')
|
|
495
|
-
|
|
496
|
-
// Input event needed to set initial value
|
|
497
|
-
$input.element.value = 'TEST'
|
|
498
|
-
await $input.trigger('input')
|
|
499
|
-
|
|
500
|
-
expect($input.vm.localValue).toEqual('TEST')
|
|
501
|
-
expect(wrapper.emitted('update')).toBeDefined()
|
|
502
|
-
expect(wrapper.emitted('update').length).toEqual(1)
|
|
503
|
-
expect(wrapper.emitted('update')[0][0]).toEqual('TEST')
|
|
504
|
-
|
|
505
|
-
await $input.trigger('blur')
|
|
506
|
-
|
|
507
|
-
expect(wrapper.emitted('update')).toBeDefined()
|
|
508
|
-
expect(wrapper.emitted('update').length).toEqual(2)
|
|
509
|
-
expect(wrapper.emitted('update')[1][0]).toEqual('test')
|
|
510
|
-
expect(wrapper.emitted('input')).toBeDefined()
|
|
511
|
-
expect(wrapper.emitted('change')).toBeUndefined()
|
|
512
|
-
expect(wrapper.emitted('blur')).toBeDefined()
|
|
513
|
-
expect(wrapper.emitted('blur').length).toEqual(1)
|
|
514
|
-
expect($input.vm.localValue).toEqual('test')
|
|
515
|
-
|
|
516
|
-
wrapper.destroy()
|
|
517
|
-
})
|
|
518
|
-
|
|
519
|
-
it('does not apply formatter when value supplied on mount and not lazy', async () => {
|
|
520
|
-
const wrapper = mount(BFormInput, {
|
|
521
|
-
propsData: {
|
|
522
|
-
value: 'TEST',
|
|
523
|
-
formatter(value) {
|
|
524
|
-
return String(value).toLowerCase()
|
|
525
|
-
}
|
|
526
|
-
},
|
|
527
|
-
attachTo: document.body
|
|
528
|
-
})
|
|
529
|
-
|
|
530
|
-
const $input = wrapper.findComponent('input')
|
|
531
|
-
expect($input.vm.localValue).toEqual('TEST')
|
|
532
|
-
expect(wrapper.emitted('update')).toBeUndefined()
|
|
533
|
-
expect(wrapper.emitted('input')).toBeUndefined()
|
|
534
|
-
expect(wrapper.emitted('change')).toBeUndefined()
|
|
535
|
-
expect(wrapper.emitted('blur')).toBeUndefined()
|
|
536
|
-
|
|
537
|
-
wrapper.destroy()
|
|
538
|
-
})
|
|
539
|
-
|
|
540
|
-
it('does not apply formatter when value prop updated and not lazy', async () => {
|
|
541
|
-
const wrapper = mount(BFormInput, {
|
|
542
|
-
propsData: {
|
|
543
|
-
value: '',
|
|
544
|
-
formatter(value) {
|
|
545
|
-
return value.toLowerCase()
|
|
546
|
-
}
|
|
547
|
-
},
|
|
548
|
-
attachTo: document.body
|
|
549
|
-
})
|
|
550
|
-
|
|
551
|
-
const $input = wrapper.find('input')
|
|
552
|
-
await wrapper.setProps({ value: 'TEST' })
|
|
553
|
-
|
|
554
|
-
expect($input.element.value).toEqual('TEST')
|
|
555
|
-
expect(wrapper.emitted('update')).toBeUndefined() // Note emitted as value hasn't changed
|
|
556
|
-
expect(wrapper.emitted('input')).toBeUndefined()
|
|
557
|
-
expect(wrapper.emitted('change')).toBeUndefined()
|
|
558
|
-
expect(wrapper.emitted('blur')).toBeUndefined()
|
|
559
|
-
|
|
560
|
-
wrapper.destroy()
|
|
561
|
-
})
|
|
562
|
-
|
|
563
|
-
it('does not apply formatter when value prop updated and lazy', async () => {
|
|
564
|
-
const wrapper = mount(BFormInput, {
|
|
565
|
-
propsData: {
|
|
566
|
-
value: '',
|
|
567
|
-
formatter(value) {
|
|
568
|
-
return value.toLowerCase()
|
|
569
|
-
},
|
|
570
|
-
lazyFormatter: true
|
|
571
|
-
},
|
|
572
|
-
attachTo: document.body
|
|
573
|
-
})
|
|
574
|
-
|
|
575
|
-
const $input = wrapper.find('input')
|
|
576
|
-
await wrapper.setProps({ value: 'TEST' })
|
|
577
|
-
|
|
578
|
-
expect($input.element.value).toEqual('TEST')
|
|
579
|
-
expect(wrapper.emitted('update')).toBeUndefined() // Not emitted when value doesnt change
|
|
580
|
-
expect(wrapper.emitted('input')).toBeUndefined()
|
|
581
|
-
expect(wrapper.emitted('change')).toBeUndefined()
|
|
582
|
-
expect(wrapper.emitted('blur')).toBeUndefined()
|
|
583
|
-
|
|
584
|
-
wrapper.destroy()
|
|
585
|
-
})
|
|
586
|
-
|
|
587
|
-
it('does not update value when non-lazy formatter returns false', async () => {
|
|
588
|
-
const wrapper = mount(BFormInput, {
|
|
589
|
-
propsData: {
|
|
590
|
-
value: 'abc',
|
|
591
|
-
formatter() {
|
|
592
|
-
return false
|
|
593
|
-
}
|
|
594
|
-
},
|
|
595
|
-
attachTo: document.body
|
|
596
|
-
})
|
|
597
|
-
|
|
598
|
-
const $input = wrapper.find('input')
|
|
599
|
-
expect($input.exists()).toBe(true)
|
|
600
|
-
|
|
601
|
-
await $input.trigger('focus')
|
|
602
|
-
await $input.setValue('TEST')
|
|
603
|
-
|
|
604
|
-
expect(wrapper.emitted('input')).toBeUndefined()
|
|
605
|
-
expect(wrapper.emitted('update')).toBeUndefined()
|
|
606
|
-
// v-model should not change
|
|
607
|
-
expect(wrapper.vm.localValue).toBe('abc')
|
|
608
|
-
// Value in input should remain the same as entered
|
|
609
|
-
expect($input.element.value).toEqual('TEST')
|
|
610
|
-
|
|
611
|
-
wrapper.destroy()
|
|
612
|
-
})
|
|
613
|
-
|
|
614
|
-
it('focused number input with no-wheel set to true works', async () => {
|
|
615
|
-
const spy = jest.fn()
|
|
616
|
-
const wrapper = mount(BFormInput, {
|
|
617
|
-
propsData: {
|
|
618
|
-
noWheel: true,
|
|
619
|
-
type: 'number',
|
|
620
|
-
value: '123'
|
|
621
|
-
},
|
|
622
|
-
listeners: {
|
|
623
|
-
blur: spy
|
|
624
|
-
},
|
|
625
|
-
attachTo: document.body
|
|
626
|
-
})
|
|
627
|
-
|
|
628
|
-
expect(wrapper.element.type).toBe('number')
|
|
629
|
-
expect(wrapper.props().noWheel).toBe(true)
|
|
630
|
-
|
|
631
|
-
wrapper.element.focus()
|
|
632
|
-
await wrapper.trigger('focus')
|
|
633
|
-
await wrapper.trigger('wheel', { deltaY: 33.33, deltaX: 0, deltaZ: 0, deltaMode: 0 })
|
|
634
|
-
|
|
635
|
-
// `:no-wheel="true"` will fire a blur event on the input when wheel fired
|
|
636
|
-
expect(spy).toHaveBeenCalled()
|
|
637
|
-
|
|
638
|
-
wrapper.destroy()
|
|
639
|
-
})
|
|
640
|
-
|
|
641
|
-
it('focused number input with no-wheel set to false works', async () => {
|
|
642
|
-
const spy = jest.fn(() => {})
|
|
643
|
-
const wrapper = mount(BFormInput, {
|
|
644
|
-
propsData: {
|
|
645
|
-
noWheel: false,
|
|
646
|
-
type: 'number',
|
|
647
|
-
value: '123'
|
|
648
|
-
},
|
|
649
|
-
listeners: {
|
|
650
|
-
blur: spy
|
|
651
|
-
},
|
|
652
|
-
attachTo: document.body
|
|
653
|
-
})
|
|
654
|
-
|
|
655
|
-
expect(wrapper.element.type).toBe('number')
|
|
656
|
-
expect(wrapper.props().noWheel).toBe(false)
|
|
657
|
-
expect(document.activeElement).not.toBe(wrapper.element)
|
|
658
|
-
|
|
659
|
-
wrapper.element.focus()
|
|
660
|
-
await wrapper.trigger('focus')
|
|
661
|
-
expect(document.activeElement).toBe(wrapper.element)
|
|
662
|
-
await wrapper.trigger('wheel', { deltaY: 33.33, deltaX: 0, deltaZ: 0, deltaMode: 0 })
|
|
663
|
-
|
|
664
|
-
// `:no-wheel="false"` will not fire a blur event on the input when wheel fired
|
|
665
|
-
expect(spy).not.toHaveBeenCalled()
|
|
666
|
-
|
|
667
|
-
wrapper.destroy()
|
|
668
|
-
})
|
|
669
|
-
|
|
670
|
-
it('changing no-wheel after mount works', async () => {
|
|
671
|
-
const spy = jest.fn(() => {})
|
|
672
|
-
const wrapper = mount(BFormInput, {
|
|
673
|
-
attachTo: document.body,
|
|
674
|
-
propsData: {
|
|
675
|
-
noWheel: false,
|
|
676
|
-
type: 'number',
|
|
677
|
-
value: '123'
|
|
678
|
-
},
|
|
679
|
-
listeners: {
|
|
680
|
-
blur: spy
|
|
681
|
-
}
|
|
682
|
-
})
|
|
683
|
-
|
|
684
|
-
expect(wrapper.element.type).toBe('number')
|
|
685
|
-
expect(wrapper.props().noWheel).toBe(false)
|
|
686
|
-
expect(document.activeElement).not.toBe(wrapper.element)
|
|
687
|
-
|
|
688
|
-
wrapper.element.focus()
|
|
689
|
-
await wrapper.trigger('focus')
|
|
690
|
-
expect(document.activeElement).toBe(wrapper.element)
|
|
691
|
-
await wrapper.trigger('wheel', { deltaY: 33.33, deltaX: 0, deltaZ: 0, deltaMode: 0 })
|
|
692
|
-
|
|
693
|
-
// no-wheel=false will not fire a blur event on the input when wheel fired
|
|
694
|
-
expect(spy).not.toHaveBeenCalled()
|
|
695
|
-
|
|
696
|
-
await wrapper.setProps({ noWheel: true })
|
|
697
|
-
expect(wrapper.props().noWheel).toBe(true)
|
|
698
|
-
|
|
699
|
-
wrapper.element.focus()
|
|
700
|
-
await wrapper.trigger('focus')
|
|
701
|
-
expect(document.activeElement).toBe(wrapper.element)
|
|
702
|
-
|
|
703
|
-
// `no-wheel="true"` will fire a blur event on the input when wheel fired
|
|
704
|
-
wrapper.element.blur()
|
|
705
|
-
await wrapper.trigger('wheel', { deltaY: 33.33, deltaX: 0, deltaZ: 0, deltaMode: 0 })
|
|
706
|
-
expect(document.activeElement).not.toBe(wrapper.element)
|
|
707
|
-
expect(spy).toHaveBeenCalled()
|
|
708
|
-
|
|
709
|
-
wrapper.destroy()
|
|
710
|
-
})
|
|
711
|
-
|
|
712
|
-
it('"number" modifier prop works', async () => {
|
|
713
|
-
const wrapper = mount(BFormInput, {
|
|
714
|
-
propsData: {
|
|
715
|
-
type: 'text',
|
|
716
|
-
number: true
|
|
717
|
-
}
|
|
718
|
-
})
|
|
719
|
-
|
|
720
|
-
const $input = wrapper.find('input')
|
|
721
|
-
$input.element.value = '123.450'
|
|
722
|
-
await $input.trigger('input')
|
|
723
|
-
|
|
724
|
-
expect($input.element.value).toBe('123.450')
|
|
725
|
-
// `v-model` update event (should emit a numerical value)
|
|
726
|
-
expect(wrapper.emitted('update')).toBeDefined()
|
|
727
|
-
expect(wrapper.emitted('update').length).toBe(1)
|
|
728
|
-
expect(wrapper.emitted('update')[0].length).toEqual(1)
|
|
729
|
-
expect(wrapper.emitted('update')[0][0]).toBeCloseTo(123.45)
|
|
730
|
-
// Pre converted value as string (raw input value)
|
|
731
|
-
expect(wrapper.emitted('input')).toBeDefined()
|
|
732
|
-
expect(wrapper.emitted('input').length).toBe(1)
|
|
733
|
-
expect(wrapper.emitted('input')[0].length).toEqual(1)
|
|
734
|
-
expect(wrapper.emitted('input')[0][0]).toEqual('123.450')
|
|
735
|
-
|
|
736
|
-
// Update the input to be different string-wise, but same numerically
|
|
737
|
-
$input.element.value = '123.4500'
|
|
738
|
-
await $input.trigger('input')
|
|
739
|
-
|
|
740
|
-
expect($input.element.value).toBe('123.4500')
|
|
741
|
-
// Should emit a new input event
|
|
742
|
-
expect(wrapper.emitted('input').length).toEqual(2)
|
|
743
|
-
expect(wrapper.emitted('input')[1][0]).toEqual('123.4500')
|
|
744
|
-
// `v-model` value stays the same and update event shouldn't be emitted again
|
|
745
|
-
expect(wrapper.emitted('update').length).toBe(1)
|
|
746
|
-
expect(wrapper.emitted('update')[0][0]).toBeCloseTo(123.45)
|
|
747
|
-
|
|
748
|
-
// Updating the `v-model` to new numeric value
|
|
749
|
-
await wrapper.setProps({ value: 45.6 })
|
|
750
|
-
expect($input.element.value).toBe('45.6')
|
|
751
|
-
|
|
752
|
-
wrapper.destroy()
|
|
753
|
-
})
|
|
754
|
-
|
|
755
|
-
it('"lazy" modifier prop works', async () => {
|
|
756
|
-
const wrapper = mount(BFormInput, {
|
|
757
|
-
propsData: {
|
|
758
|
-
type: 'text',
|
|
759
|
-
lazy: true
|
|
760
|
-
}
|
|
761
|
-
})
|
|
762
|
-
|
|
763
|
-
const $input = wrapper.find('input')
|
|
764
|
-
$input.element.value = 'a'
|
|
765
|
-
await $input.trigger('input')
|
|
766
|
-
expect($input.element.value).toBe('a')
|
|
767
|
-
// `v-model` update event should not have emitted
|
|
768
|
-
expect(wrapper.emitted('update')).toBeUndefined()
|
|
769
|
-
|
|
770
|
-
$input.element.value = 'ab'
|
|
771
|
-
await $input.trigger('input')
|
|
772
|
-
expect($input.element.value).toBe('ab')
|
|
773
|
-
// `v-model` update event should not have emitted
|
|
774
|
-
expect(wrapper.emitted('update')).toBeUndefined()
|
|
775
|
-
|
|
776
|
-
// trigger a change event
|
|
777
|
-
await $input.trigger('change')
|
|
778
|
-
expect($input.element.value).toBe('ab')
|
|
779
|
-
// `v-model` update event should have emitted
|
|
780
|
-
expect(wrapper.emitted('update')).toBeDefined()
|
|
781
|
-
expect(wrapper.emitted('update').length).toEqual(1)
|
|
782
|
-
expect(wrapper.emitted('update')[0][0]).toBe('ab')
|
|
783
|
-
|
|
784
|
-
$input.element.value = 'abc'
|
|
785
|
-
await $input.trigger('input')
|
|
786
|
-
expect($input.element.value).toBe('abc')
|
|
787
|
-
// `v-model` update event should not have emitted new event
|
|
788
|
-
expect(wrapper.emitted('update').length).toEqual(1)
|
|
789
|
-
|
|
790
|
-
$input.element.value = 'abcd'
|
|
791
|
-
await $input.trigger('input')
|
|
792
|
-
expect($input.element.value).toBe('abcd')
|
|
793
|
-
// `v-model` update event should not have emitted new event
|
|
794
|
-
expect(wrapper.emitted('update').length).toEqual(1)
|
|
795
|
-
|
|
796
|
-
// Trigger a blur event
|
|
797
|
-
await $input.trigger('blur')
|
|
798
|
-
expect($input.element.value).toBe('abcd')
|
|
799
|
-
// `v-model` update event should have emitted
|
|
800
|
-
expect(wrapper.emitted('update').length).toEqual(2)
|
|
801
|
-
expect(wrapper.emitted('update')[1][0]).toBe('abcd')
|
|
802
|
-
|
|
803
|
-
wrapper.destroy()
|
|
804
|
-
})
|
|
805
|
-
|
|
806
|
-
it('"debounce" prop works', async () => {
|
|
807
|
-
jest.useFakeTimers()
|
|
808
|
-
const wrapper = mount(BFormInput, {
|
|
809
|
-
propsData: {
|
|
810
|
-
type: 'text',
|
|
811
|
-
value: '',
|
|
812
|
-
debounce: 100
|
|
813
|
-
}
|
|
814
|
-
})
|
|
815
|
-
|
|
816
|
-
const $input = wrapper.find('input')
|
|
817
|
-
$input.element.value = 'a'
|
|
818
|
-
await $input.trigger('input')
|
|
819
|
-
expect($input.element.value).toBe('a')
|
|
820
|
-
// `v-model` update event should not have emitted
|
|
821
|
-
expect(wrapper.emitted('update')).toBeUndefined()
|
|
822
|
-
// `input` event should be emitted
|
|
823
|
-
expect(wrapper.emitted('input')).toBeDefined()
|
|
824
|
-
expect(wrapper.emitted('input').length).toBe(1)
|
|
825
|
-
expect(wrapper.emitted('input')[0][0]).toBe('a')
|
|
826
|
-
|
|
827
|
-
$input.element.value = 'ab'
|
|
828
|
-
await $input.trigger('input')
|
|
829
|
-
expect($input.element.value).toBe('ab')
|
|
830
|
-
// `v-model` update event should not have emitted
|
|
831
|
-
expect(wrapper.emitted('update')).toBeUndefined()
|
|
832
|
-
// `input` event should be emitted
|
|
833
|
-
expect(wrapper.emitted('input').length).toBe(2)
|
|
834
|
-
expect(wrapper.emitted('input')[1][0]).toBe('ab')
|
|
835
|
-
|
|
836
|
-
// Advance timer
|
|
837
|
-
jest.runOnlyPendingTimers()
|
|
838
|
-
// Should update the v-model
|
|
839
|
-
expect($input.element.value).toBe('ab')
|
|
840
|
-
// `v-model` update event should have emitted
|
|
841
|
-
expect(wrapper.emitted('update')).toBeDefined()
|
|
842
|
-
expect(wrapper.emitted('update').length).toBe(1)
|
|
843
|
-
expect(wrapper.emitted('update')[0][0]).toBe('ab')
|
|
844
|
-
// `input` event should not have emitted new event
|
|
845
|
-
expect(wrapper.emitted('input').length).toBe(2)
|
|
846
|
-
|
|
847
|
-
// Update input
|
|
848
|
-
$input.element.value = 'abc'
|
|
849
|
-
await $input.trigger('input')
|
|
850
|
-
expect($input.element.value).toBe('abc')
|
|
851
|
-
// `v-model` update event should not have emitted new event
|
|
852
|
-
expect(wrapper.emitted('update').length).toBe(1)
|
|
853
|
-
// `input` event should be emitted
|
|
854
|
-
expect(wrapper.emitted('input').length).toBe(3)
|
|
855
|
-
expect(wrapper.emitted('input')[2][0]).toBe('abc')
|
|
856
|
-
|
|
857
|
-
// Update input
|
|
858
|
-
$input.element.value = 'abcd'
|
|
859
|
-
await $input.trigger('input')
|
|
860
|
-
expect($input.element.value).toBe('abcd')
|
|
861
|
-
// `v-model` update event should not have emitted new event
|
|
862
|
-
expect(wrapper.emitted('update').length).toEqual(1)
|
|
863
|
-
// `input` event should be emitted
|
|
864
|
-
expect(wrapper.emitted('input').length).toBe(4)
|
|
865
|
-
expect(wrapper.emitted('input')[3][0]).toBe('abcd')
|
|
866
|
-
|
|
867
|
-
// Trigger a `change` event
|
|
868
|
-
await $input.trigger('change')
|
|
869
|
-
expect($input.element.value).toBe('abcd')
|
|
870
|
-
// `v-model` update event should have emitted (change overrides debounce)
|
|
871
|
-
expect(wrapper.emitted('update').length).toEqual(2)
|
|
872
|
-
expect(wrapper.emitted('update')[1][0]).toBe('abcd')
|
|
873
|
-
// `input` event should not have emitted new event
|
|
874
|
-
expect(wrapper.emitted('input').length).toBe(4)
|
|
875
|
-
|
|
876
|
-
$input.element.value = 'abc'
|
|
877
|
-
await $input.trigger('input')
|
|
878
|
-
expect($input.element.value).toBe('abc')
|
|
879
|
-
// `v-model` update event should not have emitted new event
|
|
880
|
-
expect(wrapper.emitted('update').length).toBe(2)
|
|
881
|
-
// `input` event should be emitted
|
|
882
|
-
expect(wrapper.emitted('input').length).toBe(5)
|
|
883
|
-
expect(wrapper.emitted('input')[4][0]).toBe('abc')
|
|
884
|
-
|
|
885
|
-
$input.element.value = 'abcd'
|
|
886
|
-
await $input.trigger('input')
|
|
887
|
-
expect($input.element.value).toBe('abcd')
|
|
888
|
-
// `v-model` update event should not have emitted new event
|
|
889
|
-
expect(wrapper.emitted('update').length).toBe(2)
|
|
890
|
-
// `input` event should be emitted
|
|
891
|
-
expect(wrapper.emitted('input').length).toBe(6)
|
|
892
|
-
expect(wrapper.emitted('input')[5][0]).toBe('abcd')
|
|
893
|
-
|
|
894
|
-
// Advance timer
|
|
895
|
-
jest.runOnlyPendingTimers()
|
|
896
|
-
// Should update the v-model
|
|
897
|
-
expect($input.element.value).toBe('abcd')
|
|
898
|
-
// `v-model` update event should not have emitted new event
|
|
899
|
-
expect(wrapper.emitted('update').length).toBe(2)
|
|
900
|
-
// `input` event should not have emitted new event
|
|
901
|
-
expect(wrapper.emitted('input').length).toBe(6)
|
|
902
|
-
|
|
903
|
-
wrapper.destroy()
|
|
904
|
-
})
|
|
905
|
-
|
|
906
|
-
it('focus() and blur() methods work', async () => {
|
|
907
|
-
const wrapper = mount(BFormInput, {
|
|
908
|
-
attachTo: document.body
|
|
909
|
-
})
|
|
910
|
-
|
|
911
|
-
const $input = wrapper.find('input')
|
|
912
|
-
|
|
913
|
-
expect(typeof wrapper.vm.focus).toBe('function')
|
|
914
|
-
expect(typeof wrapper.vm.blur).toBe('function')
|
|
915
|
-
|
|
916
|
-
expect(document.activeElement).not.toBe($input.element)
|
|
917
|
-
wrapper.vm.focus()
|
|
918
|
-
expect(document.activeElement).toBe($input.element)
|
|
919
|
-
wrapper.vm.blur()
|
|
920
|
-
expect(document.activeElement).not.toBe($input.element)
|
|
921
|
-
|
|
922
|
-
wrapper.destroy()
|
|
923
|
-
})
|
|
924
|
-
|
|
925
|
-
// These tests are wrapped in a new describe to limit the scope of the getBCR Mock
|
|
926
|
-
describe('prop `autofocus`', () => {
|
|
927
|
-
const origGetBCR = Element.prototype.getBoundingClientRect
|
|
928
|
-
|
|
929
|
-
beforeEach(() => {
|
|
930
|
-
// @gitlab-ui: In order to get these tests passing we needed to use real timers
|
|
931
|
-
jest.useRealTimers()
|
|
932
|
-
// Mock `getBoundingClientRect()` so that the `isVisible(el)` test returns `true`
|
|
933
|
-
Element.prototype.getBoundingClientRect = jest.fn(() => ({
|
|
934
|
-
width: 24,
|
|
935
|
-
height: 24,
|
|
936
|
-
top: 0,
|
|
937
|
-
left: 0,
|
|
938
|
-
bottom: 0,
|
|
939
|
-
right: 0
|
|
940
|
-
}))
|
|
941
|
-
})
|
|
942
|
-
|
|
943
|
-
afterEach(() => {
|
|
944
|
-
// Restore prototype
|
|
945
|
-
Element.prototype.getBoundingClientRect = origGetBCR
|
|
946
|
-
jest.useFakeTimers()
|
|
947
|
-
})
|
|
948
|
-
|
|
949
|
-
it('works when true', async () => {
|
|
950
|
-
const wrapper = mount(BFormInput, {
|
|
951
|
-
attachTo: document.body,
|
|
952
|
-
propsData: {
|
|
953
|
-
autofocus: true
|
|
954
|
-
}
|
|
955
|
-
})
|
|
956
|
-
|
|
957
|
-
expect(wrapper.vm).toBeDefined()
|
|
958
|
-
await waitNT(wrapper.vm)
|
|
959
|
-
await waitRAF()
|
|
960
|
-
|
|
961
|
-
const $input = wrapper.find('input')
|
|
962
|
-
expect($input.exists()).toBe(true)
|
|
963
|
-
expect(document).toBeDefined()
|
|
964
|
-
expect(document.activeElement).toBe($input.element)
|
|
965
|
-
|
|
966
|
-
wrapper.destroy()
|
|
967
|
-
})
|
|
968
|
-
|
|
969
|
-
it('does not autofocus when false', async () => {
|
|
970
|
-
const wrapper = mount(BFormInput, {
|
|
971
|
-
attachTo: document.body,
|
|
972
|
-
propsData: {
|
|
973
|
-
autofocus: false
|
|
974
|
-
}
|
|
975
|
-
})
|
|
976
|
-
|
|
977
|
-
expect(wrapper.vm).toBeDefined()
|
|
978
|
-
await waitNT(wrapper.vm)
|
|
979
|
-
await waitRAF()
|
|
980
|
-
|
|
981
|
-
const $input = wrapper.find('input')
|
|
982
|
-
expect($input.exists()).toBe(true)
|
|
983
|
-
expect(document).toBeDefined()
|
|
984
|
-
expect(document.activeElement).not.toBe($input.element)
|
|
985
|
-
|
|
986
|
-
wrapper.destroy()
|
|
987
|
-
})
|
|
988
|
-
})
|
|
989
|
-
})
|