aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorKevin Kirsche <[email protected]>2015-02-24 14:55:08 -0500
committerChris Rebert <[email protected]>2015-02-24 14:09:08 -0800
commit696fc2e53c0664ef04123167c1dcb1d22ae24d18 (patch)
tree77d81a429c91461c3563910d45e42a8584da82f2 /js
parentecd469ec16225ca6de90992ceeb1c700db54df8a (diff)
downloadbootstrap-696fc2e53c0664ef04123167c1dcb1d22ae24d18.tar.xz
bootstrap-696fc2e53c0664ef04123167c1dcb1d22ae24d18.zip
Add unit test of aria-expanded to dropdown suite
Redo of #15876
Diffstat (limited to 'js')
-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">'