aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohann-S <[email protected]>2015-09-09 09:26:14 +0200
committerJohann-S <[email protected]>2015-09-10 08:19:59 +0200
commit8ece899ba84aa0061576da0c5f894821724a151f (patch)
tree4f7c21bc142928544752f44b8094ffec088c97d4
parent64301a1e4c503d30591f1c17d90bb22eb93713b6 (diff)
downloadbootstrap-8ece899ba84aa0061576da0c5f894821724a151f.tar.xz
bootstrap-8ece899ba84aa0061576da0c5f894821724a151f.zip
Add tests about padding restoration
-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 6da09e3c6..d5b83a1da 100644
--- a/js/tests/unit/modal.js
+++ b/js/tests/unit/modal.js
@@ -334,6 +334,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()