Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix #17400] Add tests about padding restoration #17536

Merged
merged 1 commit into from
Oct 28, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions js/tests/unit/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down