aboutsummaryrefslogtreecommitdiff
path: root/js/tests/unit/scrollspy.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/scrollspy.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/scrollspy.spec.js')
-rw-r--r--js/tests/unit/scrollspy.spec.js9
1 files changed, 6 insertions, 3 deletions
diff --git a/js/tests/unit/scrollspy.spec.js b/js/tests/unit/scrollspy.spec.js
index 0d175aafa..917593f39 100644
--- a/js/tests/unit/scrollspy.spec.js
+++ b/js/tests/unit/scrollspy.spec.js
@@ -1,6 +1,5 @@
import ScrollSpy from '../../src/scrollspy'
import Manipulator from '../../src/dom/manipulator'
-import EventHandler from '../../src/dom/event-handler'
/** Test helpers */
import { getFixture, clearFixture, createEvent, jQueryMock } from '../helpers/fixture'
@@ -560,14 +559,18 @@ describe('ScrollSpy', () => {
describe('dispose', () => {
it('should dispose a scrollspy', () => {
- spyOn(EventHandler, 'off')
fixtureEl.innerHTML = '<div style="display: none;"></div>'
const divEl = fixtureEl.querySelector('div')
+ spyOn(divEl, 'addEventListener').and.callThrough()
+ spyOn(divEl, 'removeEventListener').and.callThrough()
+
const scrollSpy = new ScrollSpy(divEl)
+ expect(divEl.addEventListener).toHaveBeenCalledWith('scroll', jasmine.any(Function), jasmine.any(Boolean))
scrollSpy.dispose()
- expect(EventHandler.off).toHaveBeenCalledWith(divEl, '.bs.scrollspy')
+
+ expect(divEl.removeEventListener).toHaveBeenCalledWith('scroll', jasmine.any(Function), jasmine.any(Boolean))
})
})