From 15d63ef31538bcd52b177a83d2416b1d1e181964 Mon Sep 17 00:00:00 2001 From: Kevin Schaaf Date: Fri, 7 Aug 2015 16:56:57 -0700 Subject: [PATCH] Add tests for isSelected. --- test/unit/array-selector.html | 36 +++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/test/unit/array-selector.html b/test/unit/array-selector.html index 31ee18f2d3..9b20250f00 100644 --- a/test/unit/array-selector.html +++ b/test/unit/array-selector.html @@ -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() {