Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorDavid Bailey <techdavid@users.noreply.github.com>2017-08-29 14:01:41 +0300
committerDavid Bailey <techdavid@users.noreply.github.com>2017-08-29 14:01:41 +0300
commit2622a015f2d38673e3af92a3031ae8b2f2a9ce0f (patch)
treee7054f65a27fe4242e670713aac151cd09b0649c /js
parent3f2a8db4711e420b48b7a5b4c36f158a1b9eabab (diff)
Fix unit tests in PhantomJS
Use a virtual scrollbar as this is simpler than having a real one (overflow: scroll doesn't seem to work in Phantom), and disable it for the new test. One test has also been altered to prevent erroneous fails when other inline styles are added to the body (e.g. overflow).
Diffstat (limited to 'js')
-rw-r--r--js/tests/unit/modal.js13
1 files changed, 10 insertions, 3 deletions
diff --git a/js/tests/unit/modal.js b/js/tests/unit/modal.js
index 3611dfdf11..735dc4f0c8 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
@@ -397,14 +399,19 @@ $(function () {
var $body = $(document.body)
var originalPadding = $body.css('padding-right')
- $('#qunit-container').hide()
+ // 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')
- $('#qunit-container').show()
+ // restore scrollbars
+ $body.css('overflow', 'auto')
+ $('html').css('padding-right', '16px')
done()
})
.bootstrapModal('show')
@@ -544,7 +551,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()
})