Skip to content

Commit 15d63ef

Browse files
committed
Add tests for isSelected.
1 parent d4e7140 commit 15d63ef

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

test/unit/array-selector.html

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,46 +38,82 @@
3838
var el = singleConfigured;
3939
// Nothing selected
4040
assert.strictEqual(el.selected, null);
41+
assert.isFalse(el.isSelected(el.items[0]));
42+
assert.isFalse(el.isSelected(el.items[1]));
43+
assert.isFalse(el.isSelected(el.items[2]));
4144
// Select 0
4245
el.select(el.items[0]);
4346
assert.strictEqual(el.selected, el.items[0]);
47+
assert.isTrue(el.isSelected(el.items[0]));
48+
assert.isFalse(el.isSelected(el.items[1]));
49+
assert.isFalse(el.isSelected(el.items[2]));
4450
// Re-select 0
4551
el.select(el.items[0]);
4652
assert.strictEqual(el.selected, el.items[0]);
53+
assert.isTrue(el.isSelected(el.items[0]));
54+
assert.isFalse(el.isSelected(el.items[1]));
55+
assert.isFalse(el.isSelected(el.items[2]));
4756
// Select 2
4857
el.select(el.items[2]);
4958
assert.strictEqual(el.selected, el.items[2]);
59+
assert.isFalse(el.isSelected(el.items[0]));
60+
assert.isFalse(el.isSelected(el.items[1]));
61+
assert.isTrue(el.isSelected(el.items[2]));
5062
// Toggle 2
5163
el.toggle = true;
5264
el.select(el.items[2]);
5365
assert.strictEqual(el.selected, null);
66+
assert.isFalse(el.isSelected(el.items[0]));
67+
assert.isFalse(el.isSelected(el.items[1]));
68+
assert.isFalse(el.isSelected(el.items[2]));
5469
// Toggle 2
5570
el.toggle = true;
5671
el.select(el.items[2]);
5772
assert.strictEqual(el.selected, el.items[2]);
73+
assert.isFalse(el.isSelected(el.items[0]));
74+
assert.isFalse(el.isSelected(el.items[1]));
75+
assert.isTrue(el.isSelected(el.items[2]));
5876
});
5977

6078
test('multiple selection', function() {
6179
var el = multiConfigured;
6280
// Nothing selected
6381
assert.sameMembers(el.selected, []);
82+
assert.isFalse(el.isSelected(el.items[0]));
83+
assert.isFalse(el.isSelected(el.items[1]));
84+
assert.isFalse(el.isSelected(el.items[2]));
6485
// Select 0
6586
el.select(el.items[0]);
6687
assert.sameMembers(el.selected, [el.items[0]]);
88+
assert.isTrue(el.isSelected(el.items[0]));
89+
assert.isFalse(el.isSelected(el.items[1]));
90+
assert.isFalse(el.isSelected(el.items[2]));
6791
// Re-select 0
6892
el.select(el.items[0]);
6993
assert.sameMembers(el.selected, [el.items[0]]);
94+
assert.isTrue(el.isSelected(el.items[0]));
95+
assert.isFalse(el.isSelected(el.items[1]));
96+
assert.isFalse(el.isSelected(el.items[2]));
7097
// Select 2
7198
el.select(el.items[2]);
7299
assert.sameMembers(el.selected, [el.items[0], el.items[2]]);
100+
assert.isTrue(el.isSelected(el.items[0]));
101+
assert.isFalse(el.isSelected(el.items[1]));
102+
assert.isTrue(el.isSelected(el.items[2]));
73103
// Toggle 2
74104
el.toggle = true;
75105
el.select(el.items[2]);
76106
assert.sameMembers(el.selected, [el.items[0]]);
107+
assert.isTrue(el.isSelected(el.items[0]));
108+
assert.isFalse(el.isSelected(el.items[1]));
109+
assert.isFalse(el.isSelected(el.items[2]));
77110
// Toggle 2
78111
el.toggle = true;
79112
el.select(el.items[2]);
80113
assert.sameMembers(el.selected, [el.items[0], el.items[2]]);
114+
assert.isTrue(el.isSelected(el.items[0]));
115+
assert.isFalse(el.isSelected(el.items[1]));
116+
assert.isTrue(el.isSelected(el.items[2]));
81117
});
82118

83119
test('bound defaults', function() {

0 commit comments

Comments
 (0)