diff options
| author | Johann-S <[email protected]> | 2019-08-25 18:12:02 +0200 |
|---|---|---|
| committer | XhmikosR <[email protected]> | 2019-08-27 16:32:25 +0300 |
| commit | ef1c7aadbc61c69e03ecc7c6e13bdccd1901cbd4 (patch) | |
| tree | aa936dcac6452b6e63259a58a01604da0e9ca05d /js/tests | |
| parent | dd181e91bd174776cf81a8747d39d1d2f89c339e (diff) | |
| download | bootstrap-ef1c7aadbc61c69e03ecc7c6e13bdccd1901cbd4.tar.xz bootstrap-ef1c7aadbc61c69e03ecc7c6e13bdccd1901cbd4.zip | |
Backport #29298
dropdown show method should do the same as toggle
Diffstat (limited to 'js/tests')
| -rw-r--r-- | js/tests/unit/dropdown.js | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/js/tests/unit/dropdown.js b/js/tests/unit/dropdown.js index 07702e2f6..bfe5aebf5 100644 --- a/js/tests/unit/dropdown.js +++ b/js/tests/unit/dropdown.js @@ -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) + }) }) |
