diff options
| author | Patrick H. Lauke <[email protected]> | 2014-10-17 15:17:57 +0100 |
|---|---|---|
| committer | Heinrich Fenkart <[email protected]> | 2014-10-22 21:02:19 +0200 |
| commit | e1d40f7633886298a9fb417ed4f118844ed83a0d (patch) | |
| tree | 7068561317d1d213ddfe43660ed8fd3982193bcd /js/tests/unit/button.js | |
| parent | 60bb69acd512d3d54fc388823f9946cd0d350f6f (diff) | |
| download | bootstrap-e1d40f7633886298a9fb417ed4f118844ed83a0d.tar.xz bootstrap-e1d40f7633886298a9fb417ed4f118844ed83a0d.zip | |
Add `aria-pressed` to single toggle buttons
also includes tiny fix/clarification to two existing unit tests for the
.active class, adding data-toggle=“button” explicitly to the tested
buttons
Closes #14819.
Diffstat (limited to 'js/tests/unit/button.js')
| -rw-r--r-- | js/tests/unit/button.js | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/js/tests/unit/button.js b/js/tests/unit/button.js index bd431d546..73747cdd4 100644 --- a/js/tests/unit/button.js +++ b/js/tests/unit/button.js @@ -85,7 +85,7 @@ $(function () { }) test('should toggle active', function () { - var $btn = $('<button class="btn">mdo</button>') + var $btn = $('<button class="btn" data-toggle="button">mdo</button>') ok(!$btn.hasClass('active'), 'btn does not have active class') $btn.bootstrapButton('toggle') ok($btn.hasClass('active'), 'btn has class active') @@ -102,6 +102,24 @@ $(function () { ok($btn.hasClass('active'), 'btn has class active') }) + test('should toggle aria-pressed', function () { + var $btn = $('<button class="btn" data-toggle="button" aria-pressed="false">redux</button>') + equal($btn.attr('aria-pressed'), 'false', 'btn aria-pressed state is false') + $btn.bootstrapButton('toggle') + equal($btn.attr('aria-pressed'), 'true', 'btn aria-pressed state is true') + }) + + test('should toggle aria-pressed when btn children are clicked', function () { + var $btn = $('<button class="btn" data-toggle="button" aria-pressed="false">redux</button>') + var $inner = $('<i/>') + $btn + .append($inner) + .appendTo('#qunit-fixture') + equal($btn.attr('aria-pressed'), 'false', 'btn aria-pressed state is false') + $inner.click() + equal($btn.attr('aria-pressed'), 'true', 'btn aria-pressed state is true') + }) + test('should toggle active when btn children are clicked within btn-group', function () { var $btngroup = $('<div class="btn-group" data-toggle="buttons"/>') var $btn = $('<button class="btn">fat</button>') |
