Skip to content

Commit

Permalink
Add tests for isSelected.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpschaaf committed Aug 7, 2015
1 parent d4e7140 commit 15d63ef
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/unit/array-selector.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,46 +38,82 @@
var el = singleConfigured;
// Nothing selected
assert.strictEqual(el.selected, null);
assert.isFalse(el.isSelected(el.items[0]));
assert.isFalse(el.isSelected(el.items[1]));
assert.isFalse(el.isSelected(el.items[2]));
// Select 0
el.select(el.items[0]);
assert.strictEqual(el.selected, el.items[0]);
assert.isTrue(el.isSelected(el.items[0]));
assert.isFalse(el.isSelected(el.items[1]));
assert.isFalse(el.isSelected(el.items[2]));
// Re-select 0
el.select(el.items[0]);
assert.strictEqual(el.selected, el.items[0]);
assert.isTrue(el.isSelected(el.items[0]));
assert.isFalse(el.isSelected(el.items[1]));
assert.isFalse(el.isSelected(el.items[2]));
// Select 2
el.select(el.items[2]);
assert.strictEqual(el.selected, el.items[2]);
assert.isFalse(el.isSelected(el.items[0]));
assert.isFalse(el.isSelected(el.items[1]));
assert.isTrue(el.isSelected(el.items[2]));
// Toggle 2
el.toggle = true;
el.select(el.items[2]);
assert.strictEqual(el.selected, null);
assert.isFalse(el.isSelected(el.items[0]));
assert.isFalse(el.isSelected(el.items[1]));
assert.isFalse(el.isSelected(el.items[2]));
// Toggle 2
el.toggle = true;
el.select(el.items[2]);
assert.strictEqual(el.selected, el.items[2]);
assert.isFalse(el.isSelected(el.items[0]));
assert.isFalse(el.isSelected(el.items[1]));
assert.isTrue(el.isSelected(el.items[2]));
});

test('multiple selection', function() {
var el = multiConfigured;
// Nothing selected
assert.sameMembers(el.selected, []);
assert.isFalse(el.isSelected(el.items[0]));
assert.isFalse(el.isSelected(el.items[1]));
assert.isFalse(el.isSelected(el.items[2]));
// Select 0
el.select(el.items[0]);
assert.sameMembers(el.selected, [el.items[0]]);
assert.isTrue(el.isSelected(el.items[0]));
assert.isFalse(el.isSelected(el.items[1]));
assert.isFalse(el.isSelected(el.items[2]));
// Re-select 0
el.select(el.items[0]);
assert.sameMembers(el.selected, [el.items[0]]);
assert.isTrue(el.isSelected(el.items[0]));
assert.isFalse(el.isSelected(el.items[1]));
assert.isFalse(el.isSelected(el.items[2]));
// Select 2
el.select(el.items[2]);
assert.sameMembers(el.selected, [el.items[0], el.items[2]]);
assert.isTrue(el.isSelected(el.items[0]));
assert.isFalse(el.isSelected(el.items[1]));
assert.isTrue(el.isSelected(el.items[2]));
// Toggle 2
el.toggle = true;
el.select(el.items[2]);
assert.sameMembers(el.selected, [el.items[0]]);
assert.isTrue(el.isSelected(el.items[0]));
assert.isFalse(el.isSelected(el.items[1]));
assert.isFalse(el.isSelected(el.items[2]));
// Toggle 2
el.toggle = true;
el.select(el.items[2]);
assert.sameMembers(el.selected, [el.items[0], el.items[2]]);
assert.isTrue(el.isSelected(el.items[0]));
assert.isFalse(el.isSelected(el.items[1]));
assert.isTrue(el.isSelected(el.items[2]));
});

test('bound defaults', function() {
Expand Down

0 comments on commit 15d63ef

Please sign in to comment.