diff options
| author | XhmikosR <[email protected]> | 2021-09-09 15:01:58 +0300 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-09-09 15:01:58 +0300 |
| commit | e961454738f4033eb2be68bde4b257ea9e0a7765 (patch) | |
| tree | 507ca252e706a9c692b133b6e18fb8504c488837 /js/tests/unit | |
| parent | 86d5d5ea79e8eaa15a28b9da92bbee53036640f6 (diff) | |
| parent | 1df098361cac04217d6a464c80e890c4335ecb5c (diff) | |
| download | bootstrap-main-xmr-docs-render-heading.tar.xz bootstrap-main-xmr-docs-render-heading.zip | |
Merge branch 'main' into main-xmr-docs-render-headingmain-xmr-docs-render-heading
Diffstat (limited to 'js/tests/unit')
| -rw-r--r-- | js/tests/unit/.eslintrc.json | 5 | ||||
| -rw-r--r-- | js/tests/unit/collapse.spec.js | 50 | ||||
| -rw-r--r-- | js/tests/unit/jquery.spec.js | 2 | ||||
| -rw-r--r-- | js/tests/unit/util/focustrap.spec.js | 2 |
4 files changed, 58 insertions, 1 deletions
diff --git a/js/tests/unit/.eslintrc.json b/js/tests/unit/.eslintrc.json index adde3105d..6362a1acf 100644 --- a/js/tests/unit/.eslintrc.json +++ b/js/tests/unit/.eslintrc.json @@ -4,5 +4,10 @@ ], "env": { "jasmine": true + }, + "rules": { + "unicorn/consistent-function-scoping": "off", + "unicorn/no-useless-undefined": "off", + "unicorn/prefer-add-event-listener": "off" } } diff --git a/js/tests/unit/collapse.spec.js b/js/tests/unit/collapse.spec.js index 6220623fc..ece88eff5 100644 --- a/js/tests/unit/collapse.spec.js +++ b/js/tests/unit/collapse.spec.js @@ -267,6 +267,56 @@ describe('Collapse', () => { collapse.show() }) + it('should not change tab tabpanels descendants on accordion', done => { + fixtureEl.innerHTML = [ + '<div class="accordion" id="accordionExample">', + ' <div class="accordion-item">', + ' <h2 class="accordion-header" id="headingOne">', + ' <button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">', + ' Accordion Item #1', + ' </button>', + ' </h2>', + ' <div id="collapseOne" class="accordion-collapse collapse show" aria-labelledby="headingOne" data-bs-parent="#accordionExample">', + ' <div class="accordion-body">', + ' <nav>', + ' <div class="nav nav-tabs" id="nav-tab" role="tablist">', + ' <button class="nav-link active" id="nav-home-tab" data-bs-toggle="tab" data-bs-target="#nav-home" type="button" role="tab" aria-controls="nav-home" aria-selected="true">Home</button>', + ' <button class="nav-link" id="nav-profile-tab" data-bs-toggle="tab" data-bs-target="#nav-profile" type="button" role="tab" aria-controls="nav-profile" aria-selected="false">Profile</button>', + ' </div>', + ' </nav>', + ' <div class="tab-content" id="nav-tabContent">', + ' <div class="tab-pane fade show active" id="nav-home" role="tabpanel" aria-labelledby="nav-home-tab">Home</div>', + ' <div class="tab-pane fade" id="nav-profile" role="tabpanel" aria-labelledby="nav-profile-tab">Profile</div>', + ' </div>', + ' </div>', + ' </div>', + ' </div>', + ' </div>' + ].join('') + + // const btn = fixtureEl.querySelector('[data-bs-target="#collapseOne"]') + const el = fixtureEl.querySelector('#collapseOne') + const activeTabPane = fixtureEl.querySelector('#nav-home') + const collapse = new Collapse(el) + let times = 1 + + el.addEventListener('hidden.bs.collapse', () => { + setTimeout(() => collapse.show(), 10) + }) + + el.addEventListener('shown.bs.collapse', () => { + expect(activeTabPane.classList.contains('show')).toEqual(true) + times++ + if (times === 2) { + done() + } + + collapse.hide() + }) + + collapse.show() + }) + it('should not fire shown when show is prevented', done => { fixtureEl.innerHTML = '<div class="collapse"></div>' diff --git a/js/tests/unit/jquery.spec.js b/js/tests/unit/jquery.spec.js index 289612df5..7513341a4 100644 --- a/js/tests/unit/jquery.spec.js +++ b/js/tests/unit/jquery.spec.js @@ -5,6 +5,7 @@ import Carousel from '../../src/carousel' import Collapse from '../../src/collapse' import Dropdown from '../../src/dropdown' import Modal from '../../src/modal' +import Offcanvas from '../../src/offcanvas' import Popover from '../../src/popover' import ScrollSpy from '../../src/scrollspy' import Tab from '../../src/tab' @@ -32,6 +33,7 @@ describe('jQuery', () => { expect(Collapse.jQueryInterface).toEqual(jQuery.fn.collapse) expect(Dropdown.jQueryInterface).toEqual(jQuery.fn.dropdown) expect(Modal.jQueryInterface).toEqual(jQuery.fn.modal) + expect(Offcanvas.jQueryInterface).toEqual(jQuery.fn.offcanvas) expect(Popover.jQueryInterface).toEqual(jQuery.fn.popover) expect(ScrollSpy.jQueryInterface).toEqual(jQuery.fn.scrollspy) expect(Tab.jQueryInterface).toEqual(jQuery.fn.tab) diff --git a/js/tests/unit/util/focustrap.spec.js b/js/tests/unit/util/focustrap.spec.js index 2457239c4..99bc95fca 100644 --- a/js/tests/unit/util/focustrap.spec.js +++ b/js/tests/unit/util/focustrap.spec.js @@ -74,7 +74,7 @@ describe('FocusTrap', () => { document.dispatchEvent(focusInEvent) }) - it('should wrap focus around foward on tab', done => { + it('should wrap focus around forward on tab', done => { fixtureEl.innerHTML = [ '<a href="#" id="outside">outside</a>', '<div id="focustrap" tabindex="-1">', |
