summaryrefslogtreecommitdiffstats
path: root/js/tests/unit/scrollspy.spec.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-06-24 12:44:36 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-06-24 12:44:36 +0000
commitc1d5a801b4bc66e3866f815be00e11d1b20d3539 (patch)
tree394cfedf644640ac80b78aaddaff93ceb8eefa5e /js/tests/unit/scrollspy.spec.js
parentAdding upstream version 5.2.3+dfsg. (diff)
downloadbootstrap-html-c1d5a801b4bc66e3866f815be00e11d1b20d3539.tar.xz
bootstrap-html-c1d5a801b4bc66e3866f815be00e11d1b20d3539.zip
Adding upstream version 5.3.0+dfsg.upstream/5.3.0+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/tests/unit/scrollspy.spec.js')
-rw-r--r--js/tests/unit/scrollspy.spec.js42
1 files changed, 37 insertions, 5 deletions
diff --git a/js/tests/unit/scrollspy.spec.js b/js/tests/unit/scrollspy.spec.js
index c7951e6..ecbd952 100644
--- a/js/tests/unit/scrollspy.spec.js
+++ b/js/tests/unit/scrollspy.spec.js
@@ -1,8 +1,6 @@
-import ScrollSpy from '../../src/scrollspy'
-
-/** Test helpers */
-import { clearFixture, createEvent, getFixture, jQueryMock } from '../helpers/fixture'
-import EventHandler from '../../src/dom/event-handler'
+import EventHandler from '../../src/dom/event-handler.js'
+import ScrollSpy from '../../src/scrollspy.js'
+import { clearFixture, createEvent, getFixture, jQueryMock } from '../helpers/fixture.js'
describe('ScrollSpy', () => {
let fixtureEl
@@ -942,5 +940,39 @@ describe('ScrollSpy', () => {
}, 100)
link.click()
})
+
+ it('should smoothscroll to observable with anchor link that contains a french word as id', done => {
+ fixtureEl.innerHTML = [
+ '<nav id="navBar" class="navbar">',
+ ' <ul class="nav">',
+ ' <li class="nav-item"><a id="li-jsm-1" class="nav-link" href="#présentation">div 1</a></li>',
+ ' </ul>',
+ '</nav>',
+ '<div class="content" data-bs-target="#navBar" style="overflow-y: auto">',
+ ' <div id="présentation">div 1</div>',
+ '</div>'
+ ].join('')
+
+ const div = fixtureEl.querySelector('.content')
+ const link = fixtureEl.querySelector('[href="#présentation"]')
+ const observable = fixtureEl.querySelector('#présentation')
+ const clickSpy = getElementScrollSpy(div)
+ // eslint-disable-next-line no-new
+ new ScrollSpy(div, {
+ offset: 1,
+ smoothScroll: true
+ })
+
+ setTimeout(() => {
+ if (div.scrollTo) {
+ expect(clickSpy).toHaveBeenCalledWith({ top: observable.offsetTop - div.offsetTop, behavior: 'smooth' })
+ } else {
+ expect(clickSpy).toHaveBeenCalledWith(observable.offsetTop - div.offsetTop)
+ }
+
+ done()
+ }, 100)
+ link.click()
+ })
})
})