diff options
author | Rohit Sharma <rohit2sharma95@gmail.com> | 2021-01-13 22:59:47 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-13 22:59:47 +0300 |
commit | e34481b6eb5c7b9db35911f428cb96af6947741e (patch) | |
tree | e3675a4b136a1202e3211e4f04e47991e4af58a2 /js/tests/unit/modal.spec.js | |
parent | d21fb9b6276cf023f99286c2e39498990ff69895 (diff) |
Fix toggling modal when clicking on `data-bs-toggle="modal"` (#32691)
Co-authored-by: XhmikosR <xhmikosr@gmail.com>
Diffstat (limited to 'js/tests/unit/modal.spec.js')
-rw-r--r-- | js/tests/unit/modal.spec.js | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/js/tests/unit/modal.spec.js b/js/tests/unit/modal.spec.js index f645e9892b..a867bec9b6 100644 --- a/js/tests/unit/modal.spec.js +++ b/js/tests/unit/modal.spec.js @@ -870,7 +870,7 @@ describe('Modal', () => { }) describe('data-api', () => { - it('should open modal', done => { + it('should toggle modal', done => { fixtureEl.innerHTML = [ '<button type="button" data-bs-toggle="modal" data-bs-target="#exampleModal"></button>', '<div id="exampleModal" class="modal"><div class="modal-dialog"></div></div>' @@ -885,6 +885,15 @@ describe('Modal', () => { expect(modalEl.getAttribute('aria-hidden')).toEqual(null) expect(modalEl.style.display).toEqual('block') expect(document.querySelector('.modal-backdrop')).toBeDefined() + setTimeout(() => trigger.click(), 10) + }) + + modalEl.addEventListener('hidden.bs.modal', () => { + expect(modalEl.getAttribute('aria-modal')).toEqual(null) + expect(modalEl.getAttribute('role')).toEqual(null) + expect(modalEl.getAttribute('aria-hidden')).toEqual('true') + expect(modalEl.style.display).toEqual('none') + expect(document.querySelector('.modal-backdrop')).toEqual(null) done() }) |