Skip to content

Commit

Permalink
Port new unit test for dropdown from v4 (#28913)
Browse files Browse the repository at this point in the history
Add unit test from #28912 to v5
  • Loading branch information
patrickhlauke authored and XhmikosR committed Jun 25, 2019
1 parent ad62301 commit f2c63ac
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions js/tests/unit/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,31 @@ $(function () {
$dropdown.trigger($.Event('click'))
})

QUnit.test('should not open dropdown if escape key was pressed on the toggle', function (assert) {
assert.expect(1)
var done = assert.async()
var dropdownHTML = '<div class="tabs">' +
'<div class="dropdown">' +
'<button disabled href="#" class="btn dropdown-toggle" data-toggle="dropdown">Dropdown</button>' +
'<div class="dropdown-menu">' +
'<a class="dropdown-item" href="#">Secondary link</a>' +
'<a class="dropdown-item" href="#">Something else here</a>' +
'<div class="divider"/>' +
'<a class="dropdown-item" href="#">Another link</a>' +
'</div>' +
'</div>' +
'</div>'
$(dropdownHTML).appendTo('#qunit-fixture')
var $dropdown = $('#qunit-fixture').find('[data-toggle="dropdown"]').bootstrapDropdown()
var $button = $('button[data-toggle="dropdown"]')
// Key escape
$button.trigger('focus').trigger($.Event('keydown', {
which: 27
}))
assert.ok(!$dropdown.parent('.dropdown').hasClass('show'), 'dropdown menu is not shown after escape pressed')
done()
})

QUnit.test('should not add class position-static to dropdown if boundary not set', function (assert) {
assert.expect(1)
var done = assert.async()
Expand Down

0 comments on commit f2c63ac

Please sign in to comment.