]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Add test for modal-content
authorGeoSot <geo.sotis@gmail.com>
Fri, 8 Oct 2021 00:23:23 +0000 (03:23 +0300)
committerXhmikosR <xhmikosr@gmail.com>
Thu, 25 Nov 2021 17:23:49 +0000 (19:23 +0200)
js/tests/unit/modal.spec.js

index 6e7b8fc88ffb1fb92466ab8b0f75a3bc3c68f7b2..613b0a0a13a6633d652ac6d4662528f163a9887a 100644 (file)
@@ -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>'