aboutsummaryrefslogtreecommitdiff
path: root/js/tests
diff options
context:
space:
mode:
authorJohann-S <[email protected]>2017-09-03 12:56:04 +0200
committerGitHub <[email protected]>2017-09-03 12:56:04 +0200
commite04e42d08c059732153ff6925fa712464cf12207 (patch)
treea4c5d188bf8416fe7b801fbac79a2ad21af7012e /js/tests
parent45baa15932dd9c546c4618acca0b02d6f661e657 (diff)
parent2e5f1e22860a892f5abdbb65abc14172e0129c1a (diff)
downloadbootstrap-e04e42d08c059732153ff6925fa712464cf12207.tar.xz
bootstrap-e04e42d08c059732153ff6925fa712464cf12207.zip
Merge branch 'v4-dev' into fix-jumping-modal-on-resize
Diffstat (limited to 'js/tests')
-rw-r--r--js/tests/.eslintrc.json1
-rw-r--r--js/tests/unit/modal.js28
2 files changed, 28 insertions, 1 deletions
diff --git a/js/tests/.eslintrc.json b/js/tests/.eslintrc.json
index a05a3a390..b03980144 100644
--- a/js/tests/.eslintrc.json
+++ b/js/tests/.eslintrc.json
@@ -28,6 +28,7 @@
"global-require": "off",
"no-process-env": "off",
"no-process-exit": "off",
+ "no-sync": "off",
// Stylistic Issues
"brace-style": "off",
diff --git a/js/tests/unit/modal.js b/js/tests/unit/modal.js
index d22b818d2..e026cd7f1 100644
--- a/js/tests/unit/modal.js
+++ b/js/tests/unit/modal.js
@@ -21,6 +21,8 @@ $(function () {
document.body.removeChild(scrollDiv)
return scrollbarWidth
}
+ // Simulate scrollbars in PhantomJS
+ $('html').css('padding-right', '16px')
},
beforeEach: function () {
// Run all tests in noConflict mode -- it's the only way to ensure that the plugin works in noConflict mode
@@ -405,6 +407,30 @@ $(function () {
.bootstrapModal('show')
})
+ QUnit.test('should not adjust the inline body padding when it does not overflow', function (assert) {
+ assert.expect(1)
+ var done = assert.async()
+ var $body = $(document.body)
+ var originalPadding = $body.css('padding-right')
+
+ // Hide scrollbars to prevent the body overflowing
+ $body.css('overflow', 'hidden') // real scrollbar (for in-browser testing)
+ $('html').css('padding-right', '0px') // simulated scrollbar (for PhantomJS)
+
+ $('<div id="modal-test"/>')
+ .on('shown.bs.modal', function () {
+ var currentPadding = $body.css('padding-right')
+ assert.strictEqual(currentPadding, originalPadding, 'body padding should not be adjusted')
+ $(this).bootstrapModal('hide')
+
+ // restore scrollbars
+ $body.css('overflow', 'auto')
+ $('html').css('padding-right', '16px')
+ done()
+ })
+ .bootstrapModal('show')
+ })
+
QUnit.test('should adjust the inline padding of fixed elements when opening and restore when closing', function (assert) {
assert.expect(2)
var done = assert.async()
@@ -539,7 +565,7 @@ $(function () {
$('<div id="modal-test"/>')
.on('hidden.bs.modal', function () {
- assert.ok(!$body.attr('style'), 'body does not have inline padding set')
+ assert.strictEqual($body.attr('style').indexOf('padding-right'), -1, 'body does not have inline padding set')
$style.remove()
done()
})