aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick H. Lauke <[email protected]>2019-07-14 10:24:27 +0100
committerXhmikosR <[email protected]>2019-07-14 12:24:27 +0300
commitcc49977038aa886ffa6c5905e2dba4c8cc3a6fd0 (patch)
tree93f5e8f0ba2427fc850e5b287e24e3ce8f6b6714
parentcef69b9a658d35cb1b5887f8f063c8f23b860e07 (diff)
downloadbootstrap-cc49977038aa886ffa6c5905e2dba4c8cc3a6fd0.tar.xz
bootstrap-cc49977038aa886ffa6c5905e2dba4c8cc3a6fd0.zip
Fix dropdown unit test (#29037)
swap jQuery's `trigger(...)` with the more verbose native `dispatchEvent(...)`, as the former may not always behave/bubble correctly (observed while trying to write unit tests for keyboard handling of ARIA tab navigation), which may lead to this test passing even though it fails in real usage.
-rw-r--r--js/tests/unit/dropdown.js7
1 files changed, 4 insertions, 3 deletions
diff --git a/js/tests/unit/dropdown.js b/js/tests/unit/dropdown.js
index 04b506ff9..f4327959b 100644
--- a/js/tests/unit/dropdown.js
+++ b/js/tests/unit/dropdown.js
@@ -88,10 +88,11 @@ $(function () {
$(dropdownHTML).appendTo('#qunit-fixture')
var $dropdown = $('#qunit-fixture').find('[data-toggle="dropdown"]').bootstrapDropdown()
var $button = $('button[data-toggle="dropdown"]')
+ $button[0].focus()
// Key escape
- $button.trigger('focus').trigger($.Event('keydown', {
- which: 27
- }))
+ var keydown = new Event('keydown')
+ keydown.which = 27
+ $button[0].dispatchEvent(keydown)
assert.ok(!$dropdown.parent('.dropdown').hasClass('show'), 'dropdown menu is not shown after escape pressed')
done()
})