aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Rebert <[email protected]>2015-02-24 14:09:54 -0800
committerChris Rebert <[email protected]>2015-02-24 14:11:03 -0800
commit2a6207c0c9888fb5d7961bf766bfd4e28a61ed19 (patch)
tree8e16e3e1fd68e131072703fb4faa89a872ef2f4b
parent19fc014397b843cb9e47ca4fb7cc42cc0f4a87d2 (diff)
parent696fc2e53c0664ef04123167c1dcb1d22ae24d18 (diff)
downloadbootstrap-2a6207c0c9888fb5d7961bf766bfd4e28a61ed19.tar.xz
bootstrap-2a6207c0c9888fb5d7961bf766bfd4e28a61ed19.zip
Merge pull request #15904 from kkirsche/patch-8
Closes #15904
-rw-r--r--js/tests/unit/dropdown.js47
1 files changed, 47 insertions, 0 deletions
diff --git a/js/tests/unit/dropdown.js b/js/tests/unit/dropdown.js
index 346f29fde..051ca4be9 100644
--- a/js/tests/unit/dropdown.js
+++ b/js/tests/unit/dropdown.js
@@ -46,6 +46,53 @@ $(function () {
assert.ok(!$dropdown.parent('.dropdown').hasClass('open'), '"open" class added on click')
})
+ QUnit.test('should set aria-expanded="true" on target when dropdown menu is shown', function (assert) {
+ var dropdownHTML = '<ul class="tabs">'
+ + '<li class="dropdown">'
+ + '<a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false">Dropdown</a>'
+ + '<ul class="dropdown-menu">'
+ + '<li><a href="#">Secondary link</a></li>'
+ + '<li><a href="#">Something else here</a></li>'
+ + '<li class="divider"/>'
+ + '<li><a href="#">Another link</a></li>'
+ + '</ul>'
+ + '</li>'
+ + '</ul>'
+ var $dropdown = $(dropdownHTML).find('[data-toggle="dropdown"]').bootstrapDropdown().click()
+
+ assert.strictEqual($dropdown.attr('aria-expanded'), 'true', 'aria-expanded is set to string "true" on click')
+ })
+
+ QUnit.test('should set aria-expanded="false" on target when dropdown menu is hidden', function (assert) {
+ var dropdownHTML = '<ul class="tabs">'
+ + '<li class="dropdown">'
+ + '<a href="#" class="dropdown-toggle" aria-expanded="false" data-toggle="dropdown">Dropdown</a>'
+ + '<ul class="dropdown-menu">'
+ + '<li><a href="#">Secondary link</a></li>'
+ + '<li><a href="#">Something else here</a></li>'
+ + '<li class="divider"/>'
+ + '<li><a href="#">Another link</a></li>'
+ + '</ul>'
+ + '</li>'
+ + '</ul>'
+ var $dropdown = $(dropdownHTML)
+ .appendTo('#qunit-fixture')
+ .find('[data-toggle="dropdown"]')
+ .bootstrapDropdown()
+
+ var done = assert.async()
+
+ $dropdown
+ .parent('.dropdown')
+ .on('hidden.bs.dropdown', function () {
+ assert.strictEqual($dropdown.attr('aria-expanded'), 'false', 'aria-expanded is set to string "false" on hide')
+ done()
+ })
+
+ $dropdown.click()
+ $(document.body).click()
+ })
+
QUnit.test('should not open dropdown if target is disabled via class', function (assert) {
var dropdownHTML = '<ul class="tabs">'
+ '<li class="dropdown">'