aboutsummaryrefslogtreecommitdiff
path: root/js/tests
diff options
context:
space:
mode:
authorXhmikosR <[email protected]>2018-12-05 11:38:55 +0200
committerGitHub <[email protected]>2018-12-05 11:38:55 +0200
commite184c11618ef040864c2fb1b38f81d8df595aacf (patch)
tree3611313862675db6dab106f0b2eea00c7f916dc4 /js/tests
parent3007d4b4353fd0b8f3f65d660e19168e8400ee20 (diff)
parent1a171b80ab1b46f59cfd727a7e5f8a10fc43b189 (diff)
downloadbootstrap-e184c11618ef040864c2fb1b38f81d8df595aacf.tar.xz
bootstrap-e184c11618ef040864c2fb1b38f81d8df595aacf.zip
Merge branch 'v4-dev' into stretched-link
Diffstat (limited to 'js/tests')
-rw-r--r--js/tests/unit/modal.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/js/tests/unit/modal.js b/js/tests/unit/modal.js
index 1156ce0c7..8e67d83a0 100644
--- a/js/tests/unit/modal.js
+++ b/js/tests/unit/modal.js
@@ -735,4 +735,45 @@ $(function () {
done()
}).bootstrapModal('show')
})
+
+ QUnit.test('should enforce focus', function (assert) {
+ assert.expect(4)
+ var done = assert.async()
+
+ var $modal = $([
+ '<div id="modal-test" data-show="false">',
+ ' <div class="modal-dialog">',
+ ' <div class="modal-content">',
+ ' <div class="modal-body" />',
+ ' </div>',
+ ' </div>',
+ '</div>'
+ ].join(''))
+ .bootstrapModal()
+ .appendTo('#qunit-fixture')
+
+ var modal = $modal.data('bs.modal')
+ var spy = sinon.spy(modal, '_enforceFocus')
+ var spyDocOff = sinon.spy($(document), 'off')
+ var spyDocOn = sinon.spy($(document), 'on')
+
+ $modal.one('shown.bs.modal', function () {
+ assert.ok(spy.called, '_enforceFocus called')
+ assert.ok(spyDocOff.withArgs('focusin.bs.modal'))
+ assert.ok(spyDocOn.withArgs('focusin.bs.modal'))
+
+ var spyFocus = sinon.spy(modal._element, 'focus')
+ var event = $.Event('focusin', {
+ target: $('#qunit-fixture')[0]
+ })
+
+ $(document).one('focusin', function () {
+ assert.ok(spyFocus.called)
+ done()
+ })
+
+ $(document).trigger(event)
+ })
+ .bootstrapModal('show')
+ })
})