Skip to content

Commit

Permalink
Close #21249 : Add a Unit test for #21227
Browse files Browse the repository at this point in the history
  • Loading branch information
Johann-S authored and mdo committed Dec 29, 2016
1 parent de1eaef commit 95ce03f
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
32 changes: 32 additions & 0 deletions js/tests/unit/popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
})
})
30 changes: 30 additions & 0 deletions js/tests/unit/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
})
})

0 comments on commit 95ce03f

Please sign in to comment.