1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-09-29 06:49:06 +02:00
dropdown show method should do the same as toggle
This commit is contained in:
Johann-S
2019-08-25 18:12:02 +02:00
committed by XhmikosR
parent dd181e91bd
commit ef1c7aadbc
3 changed files with 51 additions and 27 deletions

View File

@@ -1272,7 +1272,7 @@ $(function () {
})
QUnit.test('should show dropdown', function (assert) {
assert.expect(2)
assert.expect(3)
var dropdownHTML =
'<div class="dropdown">' +
@@ -1293,6 +1293,7 @@ $(function () {
$dropdown
.parent('.dropdown')
.on('show.bs.dropdown', function () {
assert.ok(dropdown._popper === null)
assert.ok(true, 'show was fired')
})
.on('shown.bs.dropdown', function () {
@@ -1550,4 +1551,38 @@ $(function () {
dropdown1.toggle()
})
QUnit.test('should hide a dropdown and destroy popper', function (assert) {
assert.expect(1)
var done = assert.async()
var fixtureHtml = [
'<div class="dropdown">',
' <button href="#" class="btn dropdown-toggle" data-toggle="dropdown">Dropdown</button>',
' <div class="dropdown-menu">',
' <a class="dropdown-item" href="#">Secondary link</a>',
' </div>',
'</div>'
].join('')
$(fixtureHtml).appendTo('#qunit-fixture')
var $dropdownEl = $('.dropdown')
var dropdown = $('[data-toggle="dropdown"]')
.bootstrapDropdown()
.data('bs.dropdown')
var spyPopper
$dropdownEl.one('shown.bs.dropdown', function () {
spyPopper = sinon.spy(dropdown._popper, 'destroy')
dropdown.hide()
})
$dropdownEl.one('hidden.bs.dropdown', function () {
assert.ok(spyPopper.called)
done()
})
dropdown.show(true)
})
})