From: Kevin Kirsche Date: Tue, 24 Feb 2015 19:55:08 +0000 (-0500) Subject: Add unit test of aria-expanded to dropdown suite X-Git-Tag: v3.3.4~87^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=696fc2e53c0664ef04123167c1dcb1d22ae24d18;p=thirdparty%2Fbootstrap.git Add unit test of aria-expanded to dropdown suite Redo of #15876 --- diff --git a/js/tests/unit/dropdown.js b/js/tests/unit/dropdown.js index 346f29fde9..051ca4be93 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 = '' + 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 = '' + 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 = '