summaryrefslogtreecommitdiffstats
path: root/js/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-07-24 09:22:06 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-07-24 09:22:19 +0000
commit6c0806874f6757db30937bf5620ef41819c1538d (patch)
tree40874ca50d55d0ef5a942d26e5a37cf1516c378a /js/tests
parentReleasing debian version 5.3.1+dfsg-1. (diff)
downloadbootstrap-html-6c0806874f6757db30937bf5620ef41819c1538d.tar.xz
bootstrap-html-6c0806874f6757db30937bf5620ef41819c1538d.zip
Merging upstream version 5.3.3+dfsg.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/tests')
-rw-r--r--js/tests/unit/carousel.spec.js4
-rw-r--r--js/tests/unit/dom/selector-engine.spec.js24
-rw-r--r--js/tests/unit/dropdown.spec.js4
-rw-r--r--js/tests/unit/modal.spec.js33
-rw-r--r--js/tests/unit/offcanvas.spec.js4
-rw-r--r--js/tests/unit/scrollspy.spec.js4
-rw-r--r--js/tests/unit/tab.spec.js4
-rw-r--r--js/tests/unit/toast.spec.js4
-rw-r--r--js/tests/unit/tooltip.spec.js4
-rw-r--r--js/tests/visual/modal.html34
10 files changed, 96 insertions, 23 deletions
diff --git a/js/tests/unit/carousel.spec.js b/js/tests/unit/carousel.spec.js
index c468b5c..2960eb5 100644
--- a/js/tests/unit/carousel.spec.js
+++ b/js/tests/unit/carousel.spec.js
@@ -2,7 +2,9 @@ import Carousel from '../../src/carousel.js'
import EventHandler from '../../src/dom/event-handler.js'
import { isRTL, noop } from '../../src/util/index.js'
import Swipe from '../../src/util/swipe.js'
-import { clearFixture, createEvent, getFixture, jQueryMock } from '../helpers/fixture.js'
+import {
+ clearFixture, createEvent, getFixture, jQueryMock
+} from '../helpers/fixture.js'
describe('Carousel', () => {
const { Simulator, PointerEvent } = window
diff --git a/js/tests/unit/dom/selector-engine.spec.js b/js/tests/unit/dom/selector-engine.spec.js
index 8dd7b1f..95d9bf8 100644
--- a/js/tests/unit/dom/selector-engine.spec.js
+++ b/js/tests/unit/dom/selector-engine.spec.js
@@ -359,6 +359,30 @@ describe('SelectorEngine', () => {
expect(SelectorEngine.getMultipleElementsFromSelector(testEl)).toEqual(Array.from(fixtureEl.querySelectorAll('.target')))
})
+ it('should get elements if several ids are given', () => {
+ fixtureEl.innerHTML = [
+ '<div id="test" data-bs-target="#target1,#target2"></div>',
+ '<div class="target" id="target1"></div>',
+ '<div class="target" id="target2"></div>'
+ ].join('')
+
+ const testEl = fixtureEl.querySelector('#test')
+
+ expect(SelectorEngine.getMultipleElementsFromSelector(testEl)).toEqual(Array.from(fixtureEl.querySelectorAll('.target')))
+ })
+
+ it('should get elements if several ids with special chars are given', () => {
+ fixtureEl.innerHTML = [
+ '<div id="test" data-bs-target="#j_id11:exampleModal,#j_id22:exampleModal"></div>',
+ '<div class="target" id="j_id11:exampleModal"></div>',
+ '<div class="target" id="j_id22:exampleModal"></div>'
+ ].join('')
+
+ const testEl = fixtureEl.querySelector('#test')
+
+ expect(SelectorEngine.getMultipleElementsFromSelector(testEl)).toEqual(Array.from(fixtureEl.querySelectorAll('.target')))
+ })
+
it('should get elements in array, from href if no data-bs-target set', () => {
fixtureEl.innerHTML = [
'<a id="test" href=".target"></a>',
diff --git a/js/tests/unit/dropdown.spec.js b/js/tests/unit/dropdown.spec.js
index 8447be6..1560055 100644
--- a/js/tests/unit/dropdown.spec.js
+++ b/js/tests/unit/dropdown.spec.js
@@ -1,7 +1,9 @@
import EventHandler from '../../src/dom/event-handler.js'
import Dropdown from '../../src/dropdown.js'
import { noop } from '../../src/util/index.js'
-import { clearFixture, createEvent, getFixture, jQueryMock } from '../helpers/fixture.js'
+import {
+ clearFixture, createEvent, getFixture, jQueryMock
+} from '../helpers/fixture.js'
describe('Dropdown', () => {
let fixtureEl
diff --git a/js/tests/unit/modal.spec.js b/js/tests/unit/modal.spec.js
index 6434d8b..2aa0b76 100644
--- a/js/tests/unit/modal.spec.js
+++ b/js/tests/unit/modal.spec.js
@@ -1,7 +1,9 @@
import EventHandler from '../../src/dom/event-handler.js'
import Modal from '../../src/modal.js'
import ScrollBarHelper from '../../src/util/scrollbar.js'
-import { clearBodyAndDocument, clearFixture, createEvent, getFixture, jQueryMock } from '../helpers/fixture.js'
+import {
+ clearBodyAndDocument, clearFixture, createEvent, getFixture, jQueryMock
+} from '../helpers/fixture.js'
describe('Modal', () => {
let fixtureEl
@@ -989,6 +991,35 @@ describe('Modal', () => {
trigger.click()
})
})
+
+ it('should open modal, having special characters in its id', () => {
+ return new Promise(resolve => {
+ fixtureEl.innerHTML = [
+ '<button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#j_id22:exampleModal">',
+ ' Launch demo modal',
+ '</button>',
+ '<div class="modal fade" id="j_id22:exampleModal" aria-labelledby="exampleModalLabel" aria-hidden="true">',
+ ' <div class="modal-dialog">',
+ ' <div class="modal-content">',
+ ' <div class="modal-body">',
+ ' <p>modal body</p>',
+ ' </div>',
+ ' </div>',
+ ' </div>',
+ '</div>'
+ ].join('')
+
+ const modalEl = fixtureEl.querySelector('.modal')
+ const trigger = fixtureEl.querySelector('[data-bs-toggle="modal"]')
+
+ modalEl.addEventListener('shown.bs.modal', () => {
+ resolve()
+ })
+
+ trigger.click()
+ })
+ })
+
it('should not prevent default when a click occurred on data-bs-dismiss="modal" where tagName is DIFFERENT than <a> or <area>', () => {
return new Promise(resolve => {
fixtureEl.innerHTML = [
diff --git a/js/tests/unit/offcanvas.spec.js b/js/tests/unit/offcanvas.spec.js
index 03e7d9e..3b6c98c 100644
--- a/js/tests/unit/offcanvas.spec.js
+++ b/js/tests/unit/offcanvas.spec.js
@@ -2,7 +2,9 @@ import EventHandler from '../../src/dom/event-handler.js'
import Offcanvas from '../../src/offcanvas.js'
import { isVisible } from '../../src/util/index.js'
import ScrollBarHelper from '../../src/util/scrollbar.js'
-import { clearBodyAndDocument, clearFixture, createEvent, getFixture, jQueryMock } from '../helpers/fixture.js'
+import {
+ clearBodyAndDocument, clearFixture, createEvent, getFixture, jQueryMock
+} from '../helpers/fixture.js'
describe('Offcanvas', () => {
let fixtureEl
diff --git a/js/tests/unit/scrollspy.spec.js b/js/tests/unit/scrollspy.spec.js
index ecbd952..fc44471 100644
--- a/js/tests/unit/scrollspy.spec.js
+++ b/js/tests/unit/scrollspy.spec.js
@@ -1,6 +1,8 @@
import EventHandler from '../../src/dom/event-handler.js'
import ScrollSpy from '../../src/scrollspy.js'
-import { clearFixture, createEvent, getFixture, jQueryMock } from '../helpers/fixture.js'
+import {
+ clearFixture, createEvent, getFixture, jQueryMock
+} from '../helpers/fixture.js'
describe('ScrollSpy', () => {
let fixtureEl
diff --git a/js/tests/unit/tab.spec.js b/js/tests/unit/tab.spec.js
index 007addd..4fcf8ee 100644
--- a/js/tests/unit/tab.spec.js
+++ b/js/tests/unit/tab.spec.js
@@ -1,5 +1,7 @@
import Tab from '../../src/tab.js'
-import { clearFixture, createEvent, getFixture, jQueryMock } from '../helpers/fixture.js'
+import {
+ clearFixture, createEvent, getFixture, jQueryMock
+} from '../helpers/fixture.js'
describe('Tab', () => {
let fixtureEl
diff --git a/js/tests/unit/toast.spec.js b/js/tests/unit/toast.spec.js
index cfc56c7..200fe3e 100644
--- a/js/tests/unit/toast.spec.js
+++ b/js/tests/unit/toast.spec.js
@@ -1,5 +1,7 @@
import Toast from '../../src/toast.js'
-import { clearFixture, createEvent, getFixture, jQueryMock } from '../helpers/fixture.js'
+import {
+ clearFixture, createEvent, getFixture, jQueryMock
+} from '../helpers/fixture.js'
describe('Toast', () => {
let fixtureEl
diff --git a/js/tests/unit/tooltip.spec.js b/js/tests/unit/tooltip.spec.js
index 080432e..ceb8de4 100644
--- a/js/tests/unit/tooltip.spec.js
+++ b/js/tests/unit/tooltip.spec.js
@@ -1,7 +1,9 @@
import EventHandler from '../../src/dom/event-handler.js'
import Tooltip from '../../src/tooltip.js'
import { noop } from '../../src/util/index.js'
-import { clearFixture, createEvent, getFixture, jQueryMock } from '../helpers/fixture.js'
+import {
+ clearFixture, createEvent, getFixture, jQueryMock
+} from '../helpers/fixture.js'
describe('Tooltip', () => {
let fixtureEl
diff --git a/js/tests/visual/modal.html b/js/tests/visual/modal.html
index 09d4233..efb5127 100644
--- a/js/tests/visual/modal.html
+++ b/js/tests/visual/modal.html
@@ -13,21 +13,25 @@
</style>
</head>
<body>
- <nav class="navbar navbar-full navbar-dark bg-dark">
- <button class="navbar-toggler hidden-lg-up" type="button" data-bs-toggle="collapse" data-bs-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation"></button>
- <div class="collapse navbar-expand-md" id="navbarResponsive">
- <a class="navbar-brand" href="#">This shouldn't jump!</a>
- <ul class="navbar-nav">
- <li class="nav-item">
- <a class="nav-link active" href="#" aria-current="page">Home</a>
- </li>
- <li class="nav-item">
- <a class="nav-link" href="#">Link</a>
- </li>
- <li class="nav-item">
- <a class="nav-link" href="#">Link</a>
- </li>
- </ul>
+ <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
+ <div class="container-fluid">
+ <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
+ <span class="navbar-toggler-icon"></span>
+ </button>
+ <div class="collapse navbar-collapse" id="navbarResponsive">
+ <a class="navbar-brand" href="#">This shouldn't jump!</a>
+ <ul class="navbar-nav">
+ <li class="nav-item">
+ <a class="nav-link active" href="#" aria-current="page">Home</a>
+ </li>
+ <li class="nav-item">
+ <a class="nav-link" href="#">Link</a>
+ </li>
+ <li class="nav-item">
+ <a class="nav-link" href="#">Link</a>
+ </li>
+ </ul>
+ </div>
</div>
</nav>