diff options
author | GeoSot <geo.sotis@gmail.com> | 2021-10-08 03:23:23 +0300 |
---|---|---|
committer | XhmikosR <xhmikosr@gmail.com> | 2021-11-25 20:23:49 +0300 |
commit | 569bca54d2552b4a1ab39d15f5e4e6108b17d38e (patch) | |
tree | 30168cb14794b66ff88967360599649d675eac58 /js/tests/unit/modal.spec.js | |
parent | 0f9fd75d6c7bfd850f50d6a587c54b8e1227830c (diff) |
Add test for modal-content
Diffstat (limited to 'js/tests/unit/modal.spec.js')
-rw-r--r-- | js/tests/unit/modal.spec.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/js/tests/unit/modal.spec.js b/js/tests/unit/modal.spec.js index 6e7b8fc88f..613b0a0a13 100644 --- a/js/tests/unit/modal.spec.js +++ b/js/tests/unit/modal.spec.js @@ -432,6 +432,38 @@ describe('Modal', () => { modal.show() }) + it('should not close modal when clicking on modal-content', done => { + fixtureEl.innerHTML = [ + '<div class="modal">', + ' <div class="modal-dialog">', + ' <div class="modal-content"></div>', + ' </div>', + '</div>' + ].join('') + + const modalEl = fixtureEl.querySelector('.modal') + const modal = new Modal(modalEl) + + const shownCallback = () => { + setTimeout(() => { + expect(modal._isShown).toEqual(true) + done() + }, 10) + } + + modalEl.addEventListener('shown.bs.modal', () => { + fixtureEl.querySelector('.modal-dialog').click() + fixtureEl.querySelector('.modal-content').click() + shownCallback() + }) + + modalEl.addEventListener('hidden.bs.modal', () => { + throw new Error('Should not hide a modal') + }) + + modal.show() + }) + it('should not close modal when clicking outside of modal-content if backdrop = false', done => { fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div></div>' |