Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorPatrick H. Lauke <redux@splintered.co.uk>2019-06-25 14:57:41 +0300
committerXhmikosR <xhmikosr@gmail.com>2019-06-25 14:57:41 +0300
commitf2c63ac7299d7e101227da18de4d4a337882035b (patch)
treef4c250c56b3084d9091014b32442c7d245e84fcc /js
parentad62301a5beb3cc4917f57a9b0ac4624995b502b (diff)
Port new unit test for dropdown from v4 (#28913)
Add unit test from #28912 to v5
Diffstat (limited to 'js')
-rw-r--r--js/tests/unit/dropdown.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/js/tests/unit/dropdown.js b/js/tests/unit/dropdown.js
index ab0fdbd444..04b506ff93 100644
--- a/js/tests/unit/dropdown.js
+++ b/js/tests/unit/dropdown.js
@@ -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()