aboutsummaryrefslogtreecommitdiff
path: root/js/tests/unit/tooltip.spec.js
diff options
context:
space:
mode:
authorKyle Tsang <[email protected]>2021-02-11 21:51:34 -0800
committerGitHub <[email protected]>2021-02-12 07:51:34 +0200
commit02dbd87ffa94ff0d2f5bbc43a13f13033ce01f0b (patch)
treedf0accc46fae8eff5c0f7874c7a2773ac9ec58c4 /js/tests/unit/tooltip.spec.js
parent0a9d392975d7f77d8a0e10270da7e07aac013614 (diff)
downloadbootstrap-02dbd87ffa94ff0d2f5bbc43a13f13033ce01f0b.tar.xz
bootstrap-02dbd87ffa94ff0d2f5bbc43a13f13033ce01f0b.zip
Fix event handler removal in dropdown/carousel dispose (#33000)
* Fix event handler removal in carousel dispose * Fix event handler removal in dropdown dispose * Test event handlers in scrollspy dispose * Test event handlers in toast dispose * Test event handlers in tooltip dispose Co-authored-by: XhmikosR <[email protected]> Co-authored-by: Rohit Sharma <[email protected]>
Diffstat (limited to 'js/tests/unit/tooltip.spec.js')
-rw-r--r--js/tests/unit/tooltip.spec.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/js/tests/unit/tooltip.spec.js b/js/tests/unit/tooltip.spec.js
index e1d037154..84f5abcda 100644
--- a/js/tests/unit/tooltip.spec.js
+++ b/js/tests/unit/tooltip.spec.js
@@ -327,13 +327,26 @@ describe('Tooltip', () => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
const tooltipEl = fixtureEl.querySelector('a')
+ const addEventSpy = spyOn(tooltipEl, 'addEventListener').and.callThrough()
+ const removeEventSpy = spyOn(tooltipEl, 'removeEventListener').and.callThrough()
+
const tooltip = new Tooltip(tooltipEl)
expect(Tooltip.getInstance(tooltipEl)).toEqual(tooltip)
+ const expectedArgs = [
+ ['mouseover', jasmine.any(Function), jasmine.any(Boolean)],
+ ['mouseout', jasmine.any(Function), jasmine.any(Boolean)],
+ ['focusin', jasmine.any(Function), jasmine.any(Boolean)],
+ ['focusout', jasmine.any(Function), jasmine.any(Boolean)]
+ ]
+
+ expect(addEventSpy.calls.allArgs()).toEqual(expectedArgs)
+
tooltip.dispose()
expect(Tooltip.getInstance(tooltipEl)).toEqual(null)
+ expect(removeEventSpy.calls.allArgs()).toEqual(expectedArgs)
})
it('should destroy a tooltip after it is shown and hidden', done => {