@gitlab/ui 97.3.0 → 98.0.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.
Files changed (53) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/index.js +0 -1
  3. package/dist/vendor/bootstrap-vue/src/components/collapse/collapse.js +3 -36
  4. package/dist/vendor/bootstrap-vue/src/components/tabs/tabs.js +1 -1
  5. package/dist/vendor/bootstrap-vue/src/components/transition/bv-transition.js +12 -2
  6. package/dist/vendor/bootstrap-vue/src/constants/components.js +1 -3
  7. package/dist/vendor/bootstrap-vue/src/constants/env.js +1 -2
  8. package/dist/vendor/bootstrap-vue/src/index.js +0 -2
  9. package/dist/vendor/bootstrap-vue/src/mixins/dropdown.js +12 -39
  10. package/package.json +2 -1
  11. package/src/index.js +0 -1
  12. package/src/scss/bootstrap_vue.scss +0 -1
  13. package/src/scss/components.scss +0 -1
  14. package/src/vendor/bootstrap-vue/package.json +3 -20
  15. package/src/vendor/bootstrap-vue/src/components/collapse/MODIFICATIONS.md +14 -0
  16. package/src/vendor/bootstrap-vue/src/components/collapse/collapse.js +3 -37
  17. package/src/vendor/bootstrap-vue/src/components/collapse/collapse.spec.js +0 -132
  18. package/src/vendor/bootstrap-vue/src/components/collapse/package.json +0 -4
  19. package/src/vendor/bootstrap-vue/src/components/dropdown/README.md +1 -1
  20. package/src/vendor/bootstrap-vue/src/components/form-input/form-input.spec.js +3 -0
  21. package/src/vendor/bootstrap-vue/src/components/index.d.ts +0 -1
  22. package/src/vendor/bootstrap-vue/src/components/index.scss +0 -1
  23. package/src/vendor/bootstrap-vue/src/components/modal/MODIFICATIONS.md +8 -5
  24. package/src/vendor/bootstrap-vue/src/components/nav/package.json +1 -1
  25. package/src/vendor/bootstrap-vue/src/components/popover/popover.spec.js +0 -1
  26. package/src/vendor/bootstrap-vue/src/components/table/table-filtering.spec.js +1 -1
  27. package/src/vendor/bootstrap-vue/src/components/tabs/tabs.js +1 -1
  28. package/src/vendor/bootstrap-vue/src/components/toast/toast.spec.js +6 -18
  29. package/src/vendor/bootstrap-vue/src/components/tooltip/tooltip.spec.js +67 -356
  30. package/src/vendor/bootstrap-vue/src/components/transition/bv-transition.js +15 -2
  31. package/src/vendor/bootstrap-vue/src/constants/components.js +0 -2
  32. package/src/vendor/bootstrap-vue/src/constants/env.js +0 -3
  33. package/src/vendor/bootstrap-vue/src/directives/tooltip/tooltip.spec.js +46 -79
  34. package/src/vendor/bootstrap-vue/src/index.js +0 -4
  35. package/src/vendor/bootstrap-vue/src/mixins/dropdown.js +12 -36
  36. package/src/vendor/bootstrap-vue/src/utils/config.spec.js +20 -2
  37. package/dist/components/base/navbar/navbar.js +0 -48
  38. package/dist/vendor/bootstrap-vue/src/components/navbar/index.js +0 -2
  39. package/dist/vendor/bootstrap-vue/src/components/navbar/navbar-brand.js +0 -40
  40. package/dist/vendor/bootstrap-vue/src/components/navbar/navbar.js +0 -72
  41. package/src/components/base/navbar/navbar.md +0 -4
  42. package/src/components/base/navbar/navbar.scss +0 -0
  43. package/src/components/base/navbar/navbar.vue +0 -17
  44. package/src/vendor/bootstrap-vue/src/components/navbar/README.md +0 -332
  45. package/src/vendor/bootstrap-vue/src/components/navbar/_navbar.scss +0 -1
  46. package/src/vendor/bootstrap-vue/src/components/navbar/index.d.ts +0 -10
  47. package/src/vendor/bootstrap-vue/src/components/navbar/index.js +0 -4
  48. package/src/vendor/bootstrap-vue/src/components/navbar/index.scss +0 -1
  49. package/src/vendor/bootstrap-vue/src/components/navbar/navbar-brand.js +0 -42
  50. package/src/vendor/bootstrap-vue/src/components/navbar/navbar-brand.spec.js +0 -50
  51. package/src/vendor/bootstrap-vue/src/components/navbar/navbar.js +0 -78
  52. package/src/vendor/bootstrap-vue/src/components/navbar/navbar.spec.js +0 -130
  53. package/src/vendor/bootstrap-vue/src/components/navbar/package.json +0 -54
@@ -1,5 +1,5 @@
1
1
  import { createWrapper, mount } from '@vue/test-utils'
2
- import { waitNT, waitRAF } from '../../../tests/utils'
2
+ import { ensureEventEmitted, waitNT, waitRAF } from '../../../tests/utils'
3
3
  import { BTooltip } from './tooltip'
4
4
 
5
5
  const MODAL_CLOSE_EVENT = 'bv::modal::hidden'
@@ -60,11 +60,15 @@ const App = {
60
60
  }
61
61
  }
62
62
 
63
- // Note: `wrapper.destroy()` MUST be called at the end of each test in order for
64
- // the next test to function properly!
63
+ /**
64
+ * @gitlab/ui Note: These specs have been rewritten to be working with jest >= 29
65
+ * Instead of relying on an arcane mix of nextTick and waiting on requestAnimationFrame
66
+ * we are now waiting for certain events to happen
67
+ */
65
68
  describe('b-tooltip', () => {
66
69
  const originalCreateRange = document.createRange
67
70
  const origGetBCR = Element.prototype.getBoundingClientRect
71
+ let wrapper
68
72
 
69
73
  beforeEach(() => {
70
74
  // https://github.com/FezVrasta/popper.js/issues/478#issuecomment-407422016
@@ -91,15 +95,16 @@ describe('b-tooltip', () => {
91
95
  }))
92
96
  })
93
97
 
94
- afterEach(() => {
98
+ afterEach(async () => {
95
99
  // Reset overrides
96
100
  document.createRange = originalCreateRange
97
101
  Element.prototype.getBoundingClientRect = origGetBCR
98
- return waitRAF()
102
+ await waitRAF()
103
+ return wrapper.destroy()
99
104
  })
100
105
 
101
106
  it('has expected default structure', async () => {
102
- const wrapper = mount(App, {
107
+ wrapper = mount(App, {
103
108
  attachTo: document.body,
104
109
  propsData: {
105
110
  triggers: 'click'
@@ -130,13 +135,10 @@ describe('b-tooltip', () => {
130
135
  const $tipHolder = wrapper.findComponent(BTooltip)
131
136
  expect($tipHolder.exists()).toBe(true)
132
137
  expect($tipHolder.element.nodeType).toEqual(Node.COMMENT_NODE)
133
-
134
- wrapper.destroy()
135
138
  })
136
139
 
137
140
  it('initially open has expected structure', async () => {
138
- jest.useFakeTimers()
139
- const wrapper = mount(App, {
141
+ wrapper = mount(App, {
140
142
  attachTo: document.body,
141
143
  propsData: {
142
144
  triggers: 'click',
@@ -149,10 +151,6 @@ describe('b-tooltip', () => {
149
151
 
150
152
  expect(wrapper.vm).toBeDefined()
151
153
  await waitNT(wrapper.vm)
152
- await waitRAF()
153
- await waitNT(wrapper.vm)
154
- await waitRAF()
155
- jest.runOnlyPendingTimers()
156
154
 
157
155
  expect(wrapper.element.tagName).toBe('ARTICLE')
158
156
  expect(wrapper.attributes('id')).toBeDefined()
@@ -185,11 +183,7 @@ describe('b-tooltip', () => {
185
183
 
186
184
  // Hide the tooltip
187
185
  await wrapper.setProps({ show: false })
188
- await waitRAF()
189
- await waitRAF()
190
- jest.runOnlyPendingTimers()
191
- await waitNT(wrapper.vm)
192
- await waitRAF()
186
+ await ensureEventEmitted($tipHolder, 'hidden')
193
187
 
194
188
  expect($button.attributes('aria-describedby')).toBeUndefined()
195
189
 
@@ -199,11 +193,7 @@ describe('b-tooltip', () => {
199
193
 
200
194
  // Show the tooltip
201
195
  await wrapper.setProps({ show: true })
202
- await waitRAF()
203
- await waitRAF()
204
- jest.runOnlyPendingTimers()
205
196
  await waitNT(wrapper.vm)
206
- await waitRAF()
207
197
 
208
198
  expect($button.attributes('aria-describedby')).toBeDefined()
209
199
 
@@ -214,13 +204,10 @@ describe('b-tooltip', () => {
214
204
  expect(tip2.tagName).toEqual('DIV')
215
205
  expect(tip2.classList.contains('tooltip')).toBe(true)
216
206
  expect(tip2.classList.contains('b-tooltip')).toBe(true)
217
-
218
- wrapper.destroy()
219
207
  })
220
208
 
221
209
  it('title prop is reactive', async () => {
222
- jest.useFakeTimers()
223
- const wrapper = mount(App, {
210
+ wrapper = mount(App, {
224
211
  attachTo: document.body,
225
212
  propsData: {
226
213
  triggers: 'click',
@@ -231,14 +218,6 @@ describe('b-tooltip', () => {
231
218
 
232
219
  expect(wrapper.vm).toBeDefined()
233
220
  await waitNT(wrapper.vm)
234
- await waitRAF()
235
- await waitNT(wrapper.vm)
236
- await waitRAF()
237
- await waitNT(wrapper.vm)
238
- await waitRAF()
239
- jest.runOnlyPendingTimers()
240
- await waitNT(wrapper.vm)
241
- await waitRAF()
242
221
 
243
222
  expect(wrapper.element.tagName).toBe('ARTICLE')
244
223
  expect(wrapper.attributes('id')).toBeDefined()
@@ -273,7 +252,7 @@ describe('b-tooltip', () => {
273
252
 
274
253
  // Change the title prop
275
254
  await wrapper.setProps({ title: 'world' })
276
- await waitRAF()
255
+ await waitNT(wrapper.vm)
277
256
  await waitRAF()
278
257
 
279
258
  // Tooltip element should still be in the document
@@ -282,13 +261,10 @@ describe('b-tooltip', () => {
282
261
  expect($tip.classes()).toContain('b-tooltip')
283
262
  // Should contain the new updated content
284
263
  expect($tip.text()).toContain('world')
285
-
286
- wrapper.destroy()
287
264
  })
288
265
 
289
266
  it('providing the trigger element by function works', async () => {
290
- jest.useFakeTimers()
291
- const wrapper = mount(App, {
267
+ wrapper = mount(App, {
292
268
  attachTo: document.body,
293
269
  propsData: {
294
270
  target: () => wrapper.vm.$refs.target,
@@ -303,9 +279,6 @@ describe('b-tooltip', () => {
303
279
  expect(wrapper.vm).toBeDefined()
304
280
  await waitNT(wrapper.vm)
305
281
  await waitRAF()
306
- await waitNT(wrapper.vm)
307
- await waitRAF()
308
- jest.runOnlyPendingTimers()
309
282
 
310
283
  expect(wrapper.element.tagName).toBe('ARTICLE')
311
284
  expect(wrapper.attributes('id')).toBeDefined()
@@ -324,11 +297,7 @@ describe('b-tooltip', () => {
324
297
 
325
298
  // Activate tooltip by trigger
326
299
  await $button.trigger('click')
327
- await waitRAF()
328
- await waitRAF()
329
- jest.runOnlyPendingTimers()
330
- await waitNT(wrapper.vm)
331
- await waitRAF()
300
+ await ensureEventEmitted($tipHolder, 'shown')
332
301
 
333
302
  expect($button.attributes('id')).toBeDefined()
334
303
  expect($button.attributes('id')).toEqual('foo')
@@ -343,13 +312,10 @@ describe('b-tooltip', () => {
343
312
  expect(tip.tagName).toEqual('DIV')
344
313
  expect(tip.classList.contains('tooltip')).toBe(true)
345
314
  expect(tip.classList.contains('b-tooltip')).toBe(true)
346
-
347
- wrapper.destroy()
348
315
  })
349
316
 
350
317
  it('activating trigger element (click) opens tooltip', async () => {
351
- jest.useFakeTimers()
352
- const wrapper = mount(App, {
318
+ wrapper = mount(App, {
353
319
  attachTo: document.body,
354
320
  propsData: {
355
321
  triggers: 'click',
@@ -363,9 +329,6 @@ describe('b-tooltip', () => {
363
329
  expect(wrapper.vm).toBeDefined()
364
330
  await waitNT(wrapper.vm)
365
331
  await waitRAF()
366
- await waitNT(wrapper.vm)
367
- await waitRAF()
368
- jest.runOnlyPendingTimers()
369
332
 
370
333
  expect(wrapper.element.tagName).toBe('ARTICLE')
371
334
  expect(wrapper.attributes('id')).toBeDefined()
@@ -384,11 +347,7 @@ describe('b-tooltip', () => {
384
347
 
385
348
  // Activate tooltip by trigger
386
349
  await $button.trigger('click')
387
- await waitRAF()
388
- await waitRAF()
389
- jest.runOnlyPendingTimers()
390
- await waitNT(wrapper.vm)
391
- await waitRAF()
350
+ await ensureEventEmitted($tipHolder, 'shown')
392
351
 
393
352
  expect($button.attributes('id')).toBeDefined()
394
353
  expect($button.attributes('id')).toEqual('foo')
@@ -403,13 +362,10 @@ describe('b-tooltip', () => {
403
362
  expect(tip.tagName).toEqual('DIV')
404
363
  expect(tip.classList.contains('tooltip')).toBe(true)
405
364
  expect(tip.classList.contains('b-tooltip')).toBe(true)
406
-
407
- wrapper.destroy()
408
365
  })
409
366
 
410
367
  it('activating trigger element (focus) opens tooltip', async () => {
411
- jest.useFakeTimers()
412
- const wrapper = mount(App, {
368
+ wrapper = mount(App, {
413
369
  attachTo: document.body,
414
370
  propsData: {
415
371
  triggers: 'focus',
@@ -424,13 +380,6 @@ describe('b-tooltip', () => {
424
380
  expect(wrapper.vm).toBeDefined()
425
381
  await waitNT(wrapper.vm)
426
382
  await waitRAF()
427
- await waitNT(wrapper.vm)
428
- await waitRAF()
429
- await waitNT(wrapper.vm)
430
- await waitRAF()
431
- jest.runOnlyPendingTimers()
432
- await waitNT(wrapper.vm)
433
- await waitRAF()
434
383
 
435
384
  expect(wrapper.element.tagName).toBe('ARTICLE')
436
385
  expect(wrapper.attributes('id')).toBeDefined()
@@ -449,11 +398,7 @@ describe('b-tooltip', () => {
449
398
 
450
399
  // Activate tooltip by trigger
451
400
  await $button.trigger('focusin')
452
- await waitRAF()
453
- await waitRAF()
454
- jest.runOnlyPendingTimers()
455
- await waitNT(wrapper.vm)
456
- await waitRAF()
401
+ await ensureEventEmitted($tipHolder, 'shown')
457
402
 
458
403
  expect($button.attributes('id')).toBeDefined()
459
404
  expect($button.attributes('id')).toEqual('foo')
@@ -470,24 +415,18 @@ describe('b-tooltip', () => {
470
415
  expect(tip.classList.contains('b-tooltip')).toBe(true)
471
416
 
472
417
  // Deactivate tooltip by trigger
418
+ expect($tipHolder.emitted('hidden')).toBeFalsy()
473
419
  await $button.trigger('focusout', { relatedTarget: document.body })
474
- await waitRAF()
475
- await waitRAF()
476
- jest.runOnlyPendingTimers()
477
- await waitNT(wrapper.vm)
478
- await waitRAF()
420
+ await ensureEventEmitted($tipHolder, 'hidden')
479
421
 
480
422
  // Tooltip element should not be in the document
481
423
  expect($button.attributes('aria-describedby')).toBeUndefined()
482
424
  expect(document.body.contains(tip)).toBe(false)
483
425
  expect(document.getElementById(adb)).toBe(null)
484
-
485
- wrapper.destroy()
486
426
  })
487
427
 
488
428
  it('activating trigger element (hover) opens tooltip', async () => {
489
- jest.useFakeTimers()
490
- const wrapper = mount(App, {
429
+ wrapper = mount(App, {
491
430
  attachTo: document.body,
492
431
  propsData: {
493
432
  triggers: 'hover',
@@ -503,11 +442,6 @@ describe('b-tooltip', () => {
503
442
  expect(wrapper.vm).toBeDefined()
504
443
  await waitNT(wrapper.vm)
505
444
  await waitRAF()
506
- await waitNT(wrapper.vm)
507
- await waitRAF()
508
- jest.runOnlyPendingTimers()
509
- await waitNT(wrapper.vm)
510
- await waitRAF()
511
445
 
512
446
  expect(wrapper.element.tagName).toBe('ARTICLE')
513
447
  expect(wrapper.attributes('id')).toBeDefined()
@@ -526,11 +460,7 @@ describe('b-tooltip', () => {
526
460
 
527
461
  // Activate tooltip by trigger
528
462
  await $button.trigger('mouseenter')
529
- await waitRAF()
530
- await waitRAF()
531
- jest.runOnlyPendingTimers()
532
- await waitNT(wrapper.vm)
533
- await waitRAF()
463
+ await ensureEventEmitted($tipHolder, 'shown')
534
464
 
535
465
  expect($button.attributes('id')).toBeDefined()
536
466
  expect($button.attributes('id')).toEqual('foo')
@@ -548,25 +478,16 @@ describe('b-tooltip', () => {
548
478
 
549
479
  // Deactivate tooltip by trigger
550
480
  await $button.trigger('mouseleave', { relatedTarget: document.body })
551
- await waitRAF()
552
- await waitRAF()
553
- jest.runOnlyPendingTimers()
554
- await waitNT(wrapper.vm)
555
- await waitRAF()
556
- await waitNT(wrapper.vm)
557
- await waitRAF()
481
+ await ensureEventEmitted($tipHolder, 'hidden')
558
482
 
559
483
  // Tooltip element should not be in the document
560
484
  expect($button.attributes('aria-describedby')).toBeUndefined()
561
485
  expect(document.body.contains(tip)).toBe(false)
562
486
  expect(document.getElementById(adb)).toBe(null)
563
-
564
- wrapper.destroy()
565
487
  })
566
488
 
567
489
  it('disabled tooltip does not open on trigger', async () => {
568
- jest.useFakeTimers()
569
- const wrapper = mount(App, {
490
+ wrapper = mount(App, {
570
491
  attachTo: document.body,
571
492
  propsData: {
572
493
  triggers: 'click',
@@ -581,11 +502,6 @@ describe('b-tooltip', () => {
581
502
  expect(wrapper.vm).toBeDefined()
582
503
  await waitNT(wrapper.vm)
583
504
  await waitRAF()
584
- await waitNT(wrapper.vm)
585
- await waitRAF()
586
- jest.runOnlyPendingTimers()
587
- await waitNT(wrapper.vm)
588
- await waitRAF()
589
505
 
590
506
  expect(wrapper.element.tagName).toBe('ARTICLE')
591
507
  expect(wrapper.attributes('id')).toBeDefined()
@@ -601,35 +517,24 @@ describe('b-tooltip', () => {
601
517
  // b-tooltip wrapper
602
518
  const $tipHolder = wrapper.findComponent(BTooltip)
603
519
  expect($tipHolder.exists()).toBe(true)
520
+ expect($tipHolder.emitted('enabled')).toBeUndefined()
604
521
 
605
522
  // Try to activate tooltip by trigger
606
523
  await $button.trigger('click')
607
- await waitRAF()
608
- await waitRAF()
609
- jest.runOnlyPendingTimers()
610
524
  await waitNT(wrapper.vm)
611
525
  await waitRAF()
612
526
 
613
527
  // Tooltip should not have opened
614
528
  expect($button.attributes('aria-describedby')).toBeUndefined()
529
+ expect($tipHolder.emitted('shown')).toBeUndefined()
615
530
 
616
531
  // Now enable the tooltip
617
532
  await wrapper.setProps({ disabled: false })
618
- await waitRAF()
619
- await waitRAF()
620
- jest.runOnlyPendingTimers()
621
- await waitNT(wrapper.vm)
622
- await waitRAF()
533
+ expect($tipHolder.emitted('enabled').length).toBe(1)
623
534
 
624
535
  // Try to activate tooltip by trigger
625
536
  await $button.trigger('click')
626
- await waitRAF()
627
- await waitRAF()
628
- jest.runOnlyPendingTimers()
629
- await waitNT(wrapper.vm)
630
- await waitRAF()
631
- await waitNT(wrapper.vm)
632
- await waitRAF()
537
+ await ensureEventEmitted($tipHolder, 'shown')
633
538
 
634
539
  expect($button.attributes('aria-describedby')).toBeDefined()
635
540
  const adb = $button.attributes('aria-describedby')
@@ -642,33 +547,13 @@ describe('b-tooltip', () => {
642
547
  expect(tip.classList.contains('tooltip')).toBe(true)
643
548
 
644
549
  // Now disable the tooltip
550
+ expect($tipHolder.emitted('disabled').length).toBe(2)
645
551
  await wrapper.setProps({ disabled: true })
646
- await waitRAF()
647
- await waitRAF()
648
- jest.runOnlyPendingTimers()
649
- await waitNT(wrapper.vm)
650
- await waitRAF()
651
- await waitNT(wrapper.vm)
652
- await waitRAF()
653
-
654
- // Try to close tooltip by trigger
655
- await $button.trigger('click')
656
- await waitRAF()
657
- await waitRAF()
658
- jest.runOnlyPendingTimers()
659
- await waitNT(wrapper.vm)
660
- await waitRAF()
661
- await waitNT(wrapper.vm)
662
- await waitRAF()
663
-
664
- // expect($button.attributes('aria-describedby')).toBeUndefined()
665
-
666
- wrapper.destroy()
552
+ expect($tipHolder.emitted('disabled').length).toBe(3)
667
553
  })
668
554
 
669
555
  it('closes/opens on instance events', async () => {
670
- jest.useFakeTimers()
671
- const wrapper = mount(App, {
556
+ wrapper = mount(App, {
672
557
  attachTo: document.body,
673
558
  propsData: {
674
559
  triggers: 'click',
@@ -684,11 +569,6 @@ describe('b-tooltip', () => {
684
569
  expect(wrapper.vm).toBeDefined()
685
570
  await waitNT(wrapper.vm)
686
571
  await waitRAF()
687
- await waitNT(wrapper.vm)
688
- await waitRAF()
689
- jest.runOnlyPendingTimers()
690
- await waitNT(wrapper.vm)
691
- await waitRAF()
692
572
 
693
573
  expect(wrapper.element.tagName).toBe('ARTICLE')
694
574
  expect(wrapper.attributes('id')).toBeDefined()
@@ -711,18 +591,10 @@ describe('b-tooltip', () => {
711
591
  expect(tip.classList.contains('tooltip')).toBe(true)
712
592
  expect(tip.classList.contains('b-tooltip')).toBe(true)
713
593
 
714
- // Hide the tooltip by emitting event on instance
715
- const bTooltip = wrapper.findComponent(BTooltip)
716
- expect(bTooltip.exists()).toBe(true)
717
- bTooltip.vm.$emit('close')
718
- await waitNT(wrapper.vm)
719
- await waitRAF()
720
- await waitNT(wrapper.vm)
721
- await waitRAF()
722
- jest.runOnlyPendingTimers()
723
- await waitNT(wrapper.vm)
724
- await waitRAF()
594
+ expect($tipHolder.emitted('hidden')).toBeFalsy()
595
+ $tipHolder.vm.$emit('close')
725
596
 
597
+ await ensureEventEmitted($tipHolder, 'hidden')
726
598
  expect($button.attributes('aria-describedby')).toBeUndefined()
727
599
 
728
600
  // Tooltip element should not be in the document
@@ -730,26 +602,16 @@ describe('b-tooltip', () => {
730
602
  expect(document.getElementById(adb)).toBe(null)
731
603
 
732
604
  // Show the tooltip by emitting event on instance
733
- bTooltip.vm.$emit('open')
734
-
735
- await waitNT(wrapper.vm)
736
- await waitRAF()
737
- await waitNT(wrapper.vm)
738
- await waitRAF()
739
- jest.runOnlyPendingTimers()
740
- await waitNT(wrapper.vm)
741
- await waitRAF()
605
+ $tipHolder.vm.$emit('open')
606
+ await ensureEventEmitted($tipHolder, 'shown')
742
607
 
743
608
  // Tooltip element should be in the document
744
609
  expect($button.attributes('aria-describedby')).toBeDefined()
745
610
  expect(document.getElementById(adb)).not.toBe(null)
746
-
747
- wrapper.destroy()
748
611
  })
749
612
 
750
613
  it('closes on $root close specific ID event', async () => {
751
- jest.useFakeTimers()
752
- const wrapper = mount(App, {
614
+ wrapper = mount(App, {
753
615
  attachTo: document.body,
754
616
  propsData: {
755
617
  triggers: 'click',
@@ -765,11 +627,6 @@ describe('b-tooltip', () => {
765
627
  expect(wrapper.vm).toBeDefined()
766
628
  await waitNT(wrapper.vm)
767
629
  await waitRAF()
768
- await waitNT(wrapper.vm)
769
- await waitRAF()
770
- jest.runOnlyPendingTimers()
771
- await waitNT(wrapper.vm)
772
- await waitRAF()
773
630
 
774
631
  expect(wrapper.element.tagName).toBe('ARTICLE')
775
632
  expect(wrapper.attributes('id')).toBeDefined()
@@ -802,26 +659,17 @@ describe('b-tooltip', () => {
802
659
 
803
660
  // Hide the tooltip by emitting root event with correct ID (forceHide)
804
661
  wrapper.vm.$root.$emit('bv::hide::tooltip', 'foo')
805
- await waitNT(wrapper.vm)
806
- await waitRAF()
807
- await waitNT(wrapper.vm)
808
- await waitRAF()
809
- jest.runOnlyPendingTimers()
810
- await waitNT(wrapper.vm)
811
- await waitRAF()
662
+ await ensureEventEmitted($tipHolder, 'hidden')
812
663
 
813
664
  expect($button.attributes('aria-describedby')).toBeUndefined()
814
665
 
815
666
  // Tooltip element should not be in the document
816
667
  expect(document.body.contains(tip)).toBe(false)
817
668
  expect(document.getElementById(adb)).toBe(null)
818
-
819
- wrapper.destroy()
820
669
  })
821
670
 
822
671
  it('does not close on $root close specific other ID event', async () => {
823
- jest.useFakeTimers()
824
- const wrapper = mount(App, {
672
+ wrapper = mount(App, {
825
673
  attachTo: document.body,
826
674
  propsData: {
827
675
  triggers: 'click',
@@ -837,11 +685,6 @@ describe('b-tooltip', () => {
837
685
  expect(wrapper.vm).toBeDefined()
838
686
  await waitNT(wrapper.vm)
839
687
  await waitRAF()
840
- await waitNT(wrapper.vm)
841
- await waitRAF()
842
- jest.runOnlyPendingTimers()
843
- await waitNT(wrapper.vm)
844
- await waitRAF()
845
688
 
846
689
  expect(wrapper.element.tagName).toBe('ARTICLE')
847
690
  expect(wrapper.attributes('id')).toBeDefined()
@@ -873,11 +716,11 @@ describe('b-tooltip', () => {
873
716
 
874
717
  // Tooltip should ignore when ID is not its own
875
718
  wrapper.vm.$root.$emit('bv::hide::tooltip', 'wrong-id')
719
+ //TODO: No event in.
876
720
  await waitNT(wrapper.vm)
877
721
  await waitRAF()
878
722
  await waitNT(wrapper.vm)
879
723
  await waitRAF()
880
- jest.runOnlyPendingTimers()
881
724
  await waitNT(wrapper.vm)
882
725
  await waitRAF()
883
726
 
@@ -886,13 +729,10 @@ describe('b-tooltip', () => {
886
729
  // Tooltip element should still be in the document
887
730
  expect(document.body.contains(tip)).toBe(true)
888
731
  expect(document.getElementById(adb)).not.toBe(null)
889
-
890
- wrapper.destroy()
891
732
  })
892
733
 
893
734
  it('closes on $root close all event', async () => {
894
- jest.useFakeTimers()
895
- const wrapper = mount(App, {
735
+ wrapper = mount(App, {
896
736
  attachTo: document.body,
897
737
  propsData: {
898
738
  triggers: 'click',
@@ -908,11 +748,6 @@ describe('b-tooltip', () => {
908
748
  expect(wrapper.vm).toBeDefined()
909
749
  await waitNT(wrapper.vm)
910
750
  await waitRAF()
911
- await waitNT(wrapper.vm)
912
- await waitRAF()
913
- jest.runOnlyPendingTimers()
914
- await waitNT(wrapper.vm)
915
- await waitRAF()
916
751
 
917
752
  expect(wrapper.element.tagName).toBe('ARTICLE')
918
753
  expect(wrapper.attributes('id')).toBeDefined()
@@ -946,26 +781,17 @@ describe('b-tooltip', () => {
946
781
 
947
782
  // Hide the tooltip by emitting root event with no ID (forceHide)
948
783
  wrapper.vm.$root.$emit('bv::hide::tooltip')
949
- await waitNT(wrapper.vm)
950
- await waitRAF()
951
- await waitNT(wrapper.vm)
952
- await waitRAF()
953
- jest.runOnlyPendingTimers()
954
- await waitNT(wrapper.vm)
955
- await waitRAF()
784
+ await ensureEventEmitted($tipHolder, 'hidden')
956
785
 
957
786
  expect($button.attributes('aria-describedby')).toBeUndefined()
958
787
 
959
788
  // Tooltip element should not be in the document
960
789
  expect(document.body.contains(tip)).toBe(false)
961
790
  expect(document.getElementById(adb)).toBe(null)
962
-
963
- wrapper.destroy()
964
791
  })
965
792
 
966
793
  it('does not close on $root modal hidden event by default', async () => {
967
- jest.useFakeTimers()
968
- const wrapper = mount(App, {
794
+ wrapper = mount(App, {
969
795
  attachTo: document.body,
970
796
  propsData: {
971
797
  triggers: 'click',
@@ -981,11 +807,6 @@ describe('b-tooltip', () => {
981
807
  expect(wrapper.vm).toBeDefined()
982
808
  await waitNT(wrapper.vm)
983
809
  await waitRAF()
984
- await waitNT(wrapper.vm)
985
- await waitRAF()
986
- jest.runOnlyPendingTimers()
987
- await waitNT(wrapper.vm)
988
- await waitRAF()
989
810
 
990
811
  expect(wrapper.element.tagName).toBe('ARTICLE')
991
812
  expect(wrapper.attributes('id')).toBeDefined()
@@ -1022,7 +843,6 @@ describe('b-tooltip', () => {
1022
843
  await waitRAF()
1023
844
  await waitNT(wrapper.vm)
1024
845
  await waitRAF()
1025
- jest.runOnlyPendingTimers()
1026
846
  await waitNT(wrapper.vm)
1027
847
  await waitRAF()
1028
848
 
@@ -1031,13 +851,10 @@ describe('b-tooltip', () => {
1031
851
  // Tooltip element should still be in the document
1032
852
  expect(document.body.contains(tip)).toBe(true)
1033
853
  expect(document.getElementById(adb)).not.toBe(null)
1034
-
1035
- wrapper.destroy()
1036
854
  })
1037
855
 
1038
856
  it('closes on $root modal hidden event when inside a modal', async () => {
1039
- jest.useFakeTimers()
1040
- const wrapper = mount(App, {
857
+ wrapper = mount(App, {
1041
858
  attachTo: document.body,
1042
859
  propsData: {
1043
860
  triggers: 'click',
@@ -1054,11 +871,6 @@ describe('b-tooltip', () => {
1054
871
  expect(wrapper.vm).toBeDefined()
1055
872
  await waitNT(wrapper.vm)
1056
873
  await waitRAF()
1057
- await waitNT(wrapper.vm)
1058
- await waitRAF()
1059
- jest.runOnlyPendingTimers()
1060
- await waitNT(wrapper.vm)
1061
- await waitRAF()
1062
874
 
1063
875
  expect(wrapper.element.tagName).toBe('ARTICLE')
1064
876
  expect(wrapper.attributes('id')).toBeDefined()
@@ -1091,27 +903,15 @@ describe('b-tooltip', () => {
1091
903
 
1092
904
  // Tooltip should ignore when ID is not its own
1093
905
  wrapper.vm.$root.$emit(MODAL_CLOSE_EVENT, 'some-modal')
1094
- await waitNT(wrapper.vm)
1095
- await waitRAF()
1096
- await waitNT(wrapper.vm)
1097
- await waitRAF()
1098
- jest.runOnlyPendingTimers()
1099
- await waitNT(wrapper.vm)
1100
- await waitRAF()
906
+ await ensureEventEmitted($tipHolder, 'hidden')
1101
907
 
1102
908
  // Tooltip element should not be in the document
1103
909
  expect(document.body.contains(tip)).toBe(false)
1104
910
  expect(document.getElementById(adb)).toBe(null)
1105
-
1106
- wrapper.destroy()
1107
911
  })
1108
912
 
1109
913
  it('closes when trigger element is no longer visible', async () => {
1110
- jest.useFakeTimers()
1111
- // Prevent warns from appearing in the test logs
1112
- jest.spyOn(console, 'warn').mockImplementation(() => {})
1113
-
1114
- const wrapper = mount(App, {
914
+ wrapper = mount(App, {
1115
915
  attachTo: document.body,
1116
916
  propsData: {
1117
917
  triggers: 'click',
@@ -1126,13 +926,6 @@ describe('b-tooltip', () => {
1126
926
  expect(wrapper.vm).toBeDefined()
1127
927
  await waitNT(wrapper.vm)
1128
928
  await waitRAF()
1129
- await waitNT(wrapper.vm)
1130
- await waitRAF()
1131
- jest.runOnlyPendingTimers()
1132
- await waitNT(wrapper.vm)
1133
- await waitRAF()
1134
- await waitNT(wrapper.vm)
1135
- await waitRAF()
1136
929
 
1137
930
  expect(wrapper.element.tagName).toBe('ARTICLE')
1138
931
  expect(wrapper.attributes('id')).toBeDefined()
@@ -1161,69 +954,29 @@ describe('b-tooltip', () => {
1161
954
 
1162
955
  // Hide the tooltip by removing the trigger button from DOM
1163
956
  $button.element.parentNode.removeChild($button.element)
1164
- await waitNT(wrapper.vm)
1165
- await waitRAF()
1166
- await waitNT(wrapper.vm)
1167
- await waitRAF()
1168
- jest.runOnlyPendingTimers()
1169
- await waitNT(wrapper.vm)
1170
- await waitRAF()
1171
- // The visibility check runs on an interval of 100ms
1172
- jest.runOnlyPendingTimers()
1173
- await waitNT(wrapper.vm)
1174
- await waitRAF()
1175
- jest.runOnlyPendingTimers()
1176
- await waitNT(wrapper.vm)
1177
- await waitRAF()
1178
- jest.runOnlyPendingTimers()
1179
- await waitNT(wrapper.vm)
1180
- await waitRAF()
1181
- await waitNT(wrapper.vm)
1182
- await waitRAF()
957
+ await ensureEventEmitted($tipHolder, 'hidden')
1183
958
 
1184
959
  // Tooltip element should not be in the document
1185
960
  expect(document.body.contains(tip)).toBe(false)
1186
961
  expect(document.getElementById('adb')).toBe(null)
1187
962
 
1188
- // Try and show element via root event (using ID of trigger button)
1189
- // Note that this generates a console warning
1190
- wrapper.vm.$root.$emit('bv::show::tooltip', 'foo')
1191
- await waitNT(wrapper.vm)
1192
- await waitRAF()
1193
- await waitNT(wrapper.vm)
1194
- await waitRAF()
1195
- jest.runOnlyPendingTimers()
1196
- await waitNT(wrapper.vm)
1197
- await waitRAF()
1198
- jest.runOnlyPendingTimers()
1199
- await waitNT(wrapper.vm)
1200
- await waitRAF()
1201
-
1202
- // Tooltip element should not be in the document
1203
- expect(document.getElementById(adb)).toBe(null)
1204
-
1205
963
  // Try and show element via root event (using show all)
1206
964
  wrapper.vm.$root.$emit('bv::show::tooltip')
1207
965
  await waitNT(wrapper.vm)
1208
966
  await waitRAF()
1209
967
  await waitNT(wrapper.vm)
1210
968
  await waitRAF()
1211
- jest.runOnlyPendingTimers()
1212
969
  await waitNT(wrapper.vm)
1213
970
  await waitRAF()
1214
- jest.runOnlyPendingTimers()
1215
971
  await waitNT(wrapper.vm)
1216
972
  await waitRAF()
1217
973
 
1218
974
  // Tooltip element should not be in the document
1219
975
  expect(document.getElementById(adb)).toBe(null)
1220
-
1221
- wrapper.destroy()
1222
976
  })
1223
977
 
1224
978
  it('closes when title is set to empty', async () => {
1225
- jest.useFakeTimers()
1226
- const wrapper = mount(App, {
979
+ wrapper = mount(App, {
1227
980
  attachTo: document.body,
1228
981
  propsData: {
1229
982
  show: true,
@@ -1234,13 +987,6 @@ describe('b-tooltip', () => {
1234
987
  expect(wrapper.vm).toBeDefined()
1235
988
  await waitNT(wrapper.vm)
1236
989
  await waitRAF()
1237
- await waitNT(wrapper.vm)
1238
- await waitRAF()
1239
- await waitNT(wrapper.vm)
1240
- await waitRAF()
1241
- jest.runOnlyPendingTimers()
1242
- await waitNT(wrapper.vm)
1243
- await waitRAF()
1244
990
 
1245
991
  expect(wrapper.element.tagName).toBe('ARTICLE')
1246
992
  expect(wrapper.attributes('id')).toBeDefined()
@@ -1275,19 +1021,15 @@ describe('b-tooltip', () => {
1275
1021
 
1276
1022
  // Change the title prop
1277
1023
  await wrapper.setProps({ title: '' })
1278
- await waitRAF()
1279
- await waitRAF()
1024
+ await ensureEventEmitted($tipHolder, 'hidden')
1280
1025
 
1281
1026
  // Tooltip element should not be in the document
1282
1027
  expect(document.body.contains(tip)).toBe(false)
1283
1028
  expect(document.getElementById('adb')).toBe(null)
1284
-
1285
- wrapper.destroy()
1286
1029
  })
1287
1030
 
1288
1031
  it('applies noninteractive class based on noninteractive prop', async () => {
1289
- jest.useFakeTimers()
1290
- const wrapper = mount(App, {
1032
+ wrapper = mount(App, {
1291
1033
  attachTo: document.body,
1292
1034
  propsData: {
1293
1035
  show: true
@@ -1300,11 +1042,6 @@ describe('b-tooltip', () => {
1300
1042
  expect(wrapper.vm).toBeDefined()
1301
1043
  await waitNT(wrapper.vm)
1302
1044
  await waitRAF()
1303
- await waitNT(wrapper.vm)
1304
- await waitRAF()
1305
- jest.runOnlyPendingTimers()
1306
- await waitNT(wrapper.vm)
1307
- await waitRAF()
1308
1045
 
1309
1046
  expect(wrapper.element.tagName).toBe('ARTICLE')
1310
1047
  expect(wrapper.attributes('id')).toBeDefined()
@@ -1331,17 +1068,14 @@ describe('b-tooltip', () => {
1331
1068
 
1332
1069
  // Enable 'noninteractive'. Should be reactive
1333
1070
  await wrapper.setProps({ noninteractive: true })
1334
- await waitRAF()
1071
+ await waitNT(wrapper.vm)
1335
1072
  expect(tip.classList.contains('tooltip')).toBe(true)
1336
1073
  expect(tip.classList.contains('b-tooltip')).toBe(true)
1337
1074
  expect(tip.classList.contains('noninteractive')).toBe(true)
1338
-
1339
- wrapper.destroy()
1340
1075
  })
1341
1076
 
1342
1077
  it('applies variant class', async () => {
1343
- jest.useFakeTimers()
1344
- const wrapper = mount(App, {
1078
+ wrapper = mount(App, {
1345
1079
  attachTo: document.body,
1346
1080
  propsData: {
1347
1081
  show: true,
@@ -1355,11 +1089,6 @@ describe('b-tooltip', () => {
1355
1089
  expect(wrapper.vm).toBeDefined()
1356
1090
  await waitNT(wrapper.vm)
1357
1091
  await waitRAF()
1358
- await waitNT(wrapper.vm)
1359
- await waitRAF()
1360
- jest.runOnlyPendingTimers()
1361
- await waitNT(wrapper.vm)
1362
- await waitRAF()
1363
1092
 
1364
1093
  expect(wrapper.element.tagName).toBe('ARTICLE')
1365
1094
  expect(wrapper.attributes('id')).toBeDefined()
@@ -1383,17 +1112,15 @@ describe('b-tooltip', () => {
1383
1112
 
1384
1113
  // Change variant type. Should be reactive
1385
1114
  await wrapper.setProps({ variant: 'success' })
1386
- await waitRAF()
1115
+ await waitNT(wrapper.vm)
1116
+
1387
1117
  expect(tip.classList.contains('tooltip')).toBe(true)
1388
1118
  expect(tip.classList.contains('b-tooltip-success')).toBe(true)
1389
1119
  expect(tip.classList.contains('b-tooltip-danger')).toBe(false)
1390
-
1391
- wrapper.destroy()
1392
1120
  })
1393
1121
 
1394
1122
  it('applies custom class', async () => {
1395
- jest.useFakeTimers()
1396
- const wrapper = mount(App, {
1123
+ wrapper = mount(App, {
1397
1124
  attachTo: document.body,
1398
1125
  propsData: {
1399
1126
  show: true,
@@ -1407,11 +1134,6 @@ describe('b-tooltip', () => {
1407
1134
  expect(wrapper.vm).toBeDefined()
1408
1135
  await waitNT(wrapper.vm)
1409
1136
  await waitRAF()
1410
- await waitNT(wrapper.vm)
1411
- await waitRAF()
1412
- jest.runOnlyPendingTimers()
1413
- await waitNT(wrapper.vm)
1414
- await waitRAF()
1415
1137
 
1416
1138
  expect(wrapper.element.tagName).toBe('ARTICLE')
1417
1139
  expect(wrapper.attributes('id')).toBeDefined()
@@ -1438,17 +1160,14 @@ describe('b-tooltip', () => {
1438
1160
 
1439
1161
  // Change custom class. Should be reactive
1440
1162
  await wrapper.setProps({ customClass: 'barbaz-class' })
1441
- await waitRAF()
1163
+ await waitNT(wrapper.vm)
1442
1164
  expect(tip.classList.contains('tooltip')).toBe(true)
1443
1165
  expect(tip.classList.contains('barbaz-class')).toBe(true)
1444
1166
  expect(tip.classList.contains('foobar-class')).toBe(false)
1445
-
1446
- wrapper.destroy()
1447
1167
  })
1448
1168
 
1449
1169
  it('saves title in data attribute on open and adds to back on hide', async () => {
1450
- jest.useFakeTimers()
1451
- const wrapper = mount(App, {
1170
+ wrapper = mount(App, {
1452
1171
  attachTo: document.body,
1453
1172
  propsData: {
1454
1173
  triggers: 'click',
@@ -1463,9 +1182,6 @@ describe('b-tooltip', () => {
1463
1182
  expect(wrapper.vm).toBeDefined()
1464
1183
  await waitNT(wrapper.vm)
1465
1184
  await waitRAF()
1466
- await waitNT(wrapper.vm)
1467
- await waitRAF()
1468
- jest.runOnlyPendingTimers()
1469
1185
 
1470
1186
  expect(wrapper.element.tagName).toBe('ARTICLE')
1471
1187
  expect(wrapper.attributes('id')).toBeDefined()
@@ -1481,8 +1197,14 @@ describe('b-tooltip', () => {
1481
1197
  expect($button.attributes('data-original-title')).toBeUndefined()
1482
1198
  expect($button.attributes('aria-describedby')).toBeUndefined()
1483
1199
 
1200
+ // <b-tooltip> wrapper
1201
+ const $tipHolder = wrapper.findComponent(BTooltip)
1202
+ expect($tipHolder.exists()).toBe(true)
1203
+ expect($tipHolder.element.nodeType).toEqual(Node.COMMENT_NODE)
1204
+
1484
1205
  // Show tooltip
1485
1206
  await wrapper.setProps({ show: true })
1207
+ await ensureEventEmitted($tipHolder, 'shown')
1486
1208
 
1487
1209
  expect($button.attributes('title')).toBeDefined()
1488
1210
  expect($button.attributes('title')).toEqual('')
@@ -1492,11 +1214,6 @@ describe('b-tooltip', () => {
1492
1214
  // ID of the tooltip that will be in the body
1493
1215
  const adb = $button.attributes('aria-describedby')
1494
1216
 
1495
- // <b-tooltip> wrapper
1496
- const $tipHolder = wrapper.findComponent(BTooltip)
1497
- expect($tipHolder.exists()).toBe(true)
1498
- expect($tipHolder.element.nodeType).toEqual(Node.COMMENT_NODE)
1499
-
1500
1217
  // Find the tooltip element in the document
1501
1218
  const tip = document.getElementById(adb)
1502
1219
  expect(tip).not.toBe(null)
@@ -1509,11 +1226,7 @@ describe('b-tooltip', () => {
1509
1226
 
1510
1227
  // Hide the tooltip
1511
1228
  await wrapper.setProps({ show: false })
1512
- await waitRAF()
1513
- await waitRAF()
1514
- jest.runOnlyPendingTimers()
1515
- await waitNT(wrapper.vm)
1516
- await waitRAF()
1229
+ await ensureEventEmitted($tipHolder, 'hidden')
1517
1230
 
1518
1231
  expect($button.attributes('title')).toBeDefined()
1519
1232
  expect($button.attributes('title')).toEqual('bar')
@@ -1523,7 +1236,5 @@ describe('b-tooltip', () => {
1523
1236
  // Tooltip element should not be in the document
1524
1237
  expect(document.body.contains(tip)).toBe(false)
1525
1238
  expect(document.querySelector(adb)).toBe(null)
1526
-
1527
- wrapper.destroy()
1528
1239
  })
1529
1240
  })