Skip to content

Commit

Permalink
Add unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Miksovsky committed Aug 25, 2016
1 parent 2348d84 commit 9b3ea9c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
5 changes: 3 additions & 2 deletions iron-menu-behavior.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@
* other items.
*
* Reset the aria-selected attribute based on the current selection state.
* As _applySelection notes, we need to set aria-selected to false to items,
* even in their initial state, not just when they become deselected.
* As _applySelection notes, we need to set aria-selected to false for
* unselected items, even in their initial state, not just when they become
* deselected.
*/
_resetItemAttributes: function() {
var selectedItem = this.multi ? (this.selectedItems && this.selectedItems[0]) : this.selectedItem;
Expand Down
23 changes: 23 additions & 0 deletions test/iron-menu-behavior.html
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,29 @@
done();
});
});

test('aria-selected attribute for items defaults to false', function() {
var menu = fixture('basic');
var selectedValues = menu.items.map(function(item) {
return item.getAttribute('aria-selected');
});
assert.deepEqual(selectedValues, ['false', 'false', 'false']);
});

test('aria-selected attribute reflects item selection state', function() {
var menu = fixture('basic');
var item0 = menu.items[0];
var item1 = menu.items[1];
assert.equal(item0.getAttribute('aria-selected'), 'false');
assert.equal(item1.getAttribute('aria-selected'), 'false');
menu.selected = 0;
assert.equal(item0.getAttribute('aria-selected'), 'true');
assert.equal(item1.getAttribute('aria-selected'), 'false');
menu.selected = 1;
assert.equal(item0.getAttribute('aria-selected'), 'false');
assert.equal(item1.getAttribute('aria-selected'), 'true');
});

});
</script>
</body>
Expand Down

0 comments on commit 9b3ea9c

Please sign in to comment.