Skip to content

Commit

Permalink
Added an extra test to cover this edge case
Browse files Browse the repository at this point in the history
  • Loading branch information
KittyGiraudel committed Apr 15, 2016
1 parent 6ff876c commit 2f4b78f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions tests/index.html
Expand Up @@ -83,6 +83,11 @@
<button data-a11y-toggle="t13" type="button"><span>Toggle</span></button>
<div id="t13">Target</div>
</div>

<div class="test test-14">
<span data-a11y-toggle="t14" role="button" tabindex="0">Toggle</span>
<div id="t14">Target</div>
</div>
</div>

<script src="../a11y-toggle.js"></script>
Expand Down
12 changes: 11 additions & 1 deletion tests/index.js
@@ -1,5 +1,6 @@
/* globals describe, it, expect */

describe('Initial setup', function () {
var toggle, target;
var actual, expected;

it('should add `id` attribute to toggle if not set', function () {
Expand Down Expand Up @@ -103,4 +104,13 @@ describe('Click events', function () {
expected = 'true';
expect(actual).to.be.equal(expected);
});

it('should work correctly with accessible non-<button> toggle', function () {
var toggle = document.querySelector('[data-a11y-toggle="t14"]');
toggle.click();

actual = toggle.getAttribute('aria-expanded');
expected = 'true';
expect(actual).to.be.equal(expected);
});
});

0 comments on commit 2f4b78f

Please sign in to comment.