aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorMark Otto <[email protected]>2016-10-28 13:46:14 -0700
committerGitHub <[email protected]>2016-10-28 13:46:14 -0700
commitc01fa6b369dc751192ae0dfa5ba5beb2ea048e89 (patch)
tree770937bda5eb13a0085c8fb10a669d9366f9d104 /js
parentcecf0db2ce5e4687579d9510dca6cc205ef43d7b (diff)
parent8ece899ba84aa0061576da0c5f894821724a151f (diff)
downloadbootstrap-c01fa6b369dc751192ae0dfa5ba5beb2ea048e89.tar.xz
bootstrap-c01fa6b369dc751192ae0dfa5ba5beb2ea048e89.zip
Merge pull request #17536 from Johann-S/testPadding
[Fix #17400] Add tests about padding restoration
Diffstat (limited to 'js')
-rw-r--r--js/tests/unit/modal.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/js/tests/unit/modal.js b/js/tests/unit/modal.js
index 28c1e0ec7..f5157d454 100644
--- a/js/tests/unit/modal.js
+++ b/js/tests/unit/modal.js
@@ -363,6 +363,44 @@ $(function () {
.bootstrapModal('show')
})
+ QUnit.test('should have a paddingRight when the modal is taller than the viewport', function (assert) {
+ assert.expect(2)
+ var done = assert.async()
+ $('<div class="navbar-fixed-top navbar-fixed-bottom is-fixed">@Johann-S</div>').appendTo('#qunit-fixture')
+ $('.navbar-fixed-top, .navbar-fixed-bottom, .is-fixed').css('padding-right', '10px')
+
+ $('<div id="modal-test"/>')
+ .on('shown.bs.modal', function () {
+ var paddingRight = parseInt($(document.body).css('padding-right'), 10)
+ assert.strictEqual(isNaN(paddingRight), false)
+ assert.strictEqual(paddingRight !== 0, true)
+ $(document.body).css('padding-right', ''); // Because test case "should ignore other inline styles when trying to restore body padding after closing" fail if not
+ done()
+ })
+ .bootstrapModal('show')
+ })
+
+ QUnit.test('should remove padding-right on modal after closing', function (assert) {
+ assert.expect(3)
+ var done = assert.async()
+ $('<div class="navbar-fixed-top navbar-fixed-bottom is-fixed">@Johann-S</div>').appendTo('#qunit-fixture')
+ $('.navbar-fixed-top, .navbar-fixed-bottom, .is-fixed').css('padding-right', '10px')
+
+ $('<div id="modal-test"/>')
+ .on('shown.bs.modal', function () {
+ var paddingRight = parseInt($(document.body).css('padding-right'), 10)
+ assert.strictEqual(isNaN(paddingRight), false)
+ assert.strictEqual(paddingRight !== 0, true)
+ $(this).bootstrapModal('hide')
+ })
+ .on('hidden.bs.modal', function () {
+ var paddingRight = parseInt($(document.body).css('padding-right'), 10)
+ assert.strictEqual(paddingRight, 0)
+ done()
+ })
+ .bootstrapModal('show')
+ })
+
QUnit.test('should ignore other inline styles when trying to restore body padding after closing', function (assert) {
assert.expect(2)
var done = assert.async()