diff options
author | Joakim Riedel <joakim.riedel@gmail.com> | 2020-09-21 14:41:40 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-21 14:41:40 +0300 |
commit | b0a0c56788919ae760533ef3623d7ff66fdbaf63 (patch) | |
tree | 6f5d97383ecb395d4ab7b6151d89d02bf91c66ce /js/tests | |
parent | ab0aec397eacd28dd229f5cb67b687762cf0c531 (diff) |
ensure `hidePrevented.bs.modal` can be prevented (#31696)
Diffstat (limited to 'js/tests')
-rw-r--r-- | js/tests/unit/modal.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/js/tests/unit/modal.js b/js/tests/unit/modal.js index c4e5a30565..60c3cba9dd 100644 --- a/js/tests/unit/modal.js +++ b/js/tests/unit/modal.js @@ -976,4 +976,43 @@ $(function () { backdrop: 'static' }) }) + + QUnit.test('should get modal-static class when clicking outside of modal-content if backdrop = static', function (assert) { + assert.expect(1) + var done = assert.async() + var $modal = $('<div class="modal" data-backdrop="static"><div class="modal-dialog" style="transition-duration: 20ms;"/></div>').appendTo('#qunit-fixture') + + $modal.on('shown.bs.modal', function () { + $modal.trigger('click') + setTimeout(function () { + assert.ok($modal.hasClass('modal-static'), 'has modal-static class') + done() + }, 0) + }) + .bootstrapModal({ + backdrop: 'static' + }) + }) + + QUnit.test('should not get modal-static class when clicking outside of modal-content if backdrop = static and event is prevented', function (assert) { + assert.expect(2) + var done = assert.async() + var $modal = $('<div class="modal" data-backdrop="static"><div class="modal-dialog" style="transition-duration: 20ms;"/></div>').appendTo('#qunit-fixture') + + $modal.on('hidePrevented.bs.modal', function (e) { + assert.ok(true, 'should trigger hidePrevented event') + e.preventDefault() + }) + + $modal.on('shown.bs.modal', function () { + $modal.trigger('click') + setTimeout(function () { + assert.notOk($modal.hasClass('modal-static'), 'should not have modal-static class') + done() + }, 0) + }) + .bootstrapModal({ + backdrop: 'static' + }) + }) }) |