0
0
mirror of https://github.com/twbs/bootstrap.git synced 2024-12-01 13:24:25 +01:00

Close #21249 : Add a Unit test for #21227

This commit is contained in:
Johann-S 2016-12-29 10:40:32 +01:00 committed by Mark Otto
parent de1eaef35b
commit 95ce03f000
2 changed files with 62 additions and 0 deletions

View File

@ -332,4 +332,36 @@ $(function () {
done()
}
})
QUnit.test('should hide popovers when their containing modal is closed', function (assert) {
assert.expect(1)
var done = assert.async()
var templateHTML = '<div id="modal-test" class="modal">' +
'<div class="modal-dialog" role="document">' +
'<div class="modal-content">' +
'<div class="modal-body">' +
'<button id="popover-test" type="button" class="btn btn-secondary" data-toggle="popover" data-placement="top" data-content="Popover">' +
'Popover on top' +
'</button>' +
'</div>' +
'</div>' +
'</div>' +
'</div>'
$(templateHTML).appendTo('#qunit-fixture')
$('#popover-test')
.on('shown.bs.popover', function () {
$('#modal-test').modal('hide')
})
.on('hide.bs.popover', function () {
assert.ok(true, 'popover hide')
done()
})
$('#modal-test')
.on('shown.bs.modal', function () {
$('#popover-test').bootstrapPopover('show')
})
.modal('show')
})
})

View File

@ -839,4 +839,34 @@ $(function () {
assert.ok(showingTooltip(), 'tooltip is faded in again')
})
QUnit.test('should hide tooltip when their containing modal is closed', function (assert) {
assert.expect(1)
var done = assert.async()
var templateHTML = '<div id="modal-test" class="modal">' +
'<div class="modal-dialog" role="document">' +
'<div class="modal-content">' +
'<div class="modal-body">' +
'<a id="tooltipTest" href="#" data-toggle="tooltip" title="Some tooltip text!">Tooltip</a>' +
'</div>' +
'</div>' +
'</div>' +
'</div>'
$(templateHTML).appendTo('#qunit-fixture')
$('#tooltipTest')
.bootstrapTooltip({ trigger: 'manuel' })
.on('shown.bs.tooltip', function () {
$('#modal-test').modal('hide')
})
.on('hide.bs.tooltip', function () {
assert.ok(true, 'tooltip hide')
done()
})
$('#modal-test')
.on('shown.bs.modal', function () {
$('#tooltipTest').bootstrapTooltip('show')
})
.modal('show')
})
})