Commit 03e9818a authored by David Stutz's avatar David Stutz

Updated tests.

parent 85db8aef
...@@ -67,9 +67,9 @@ ...@@ -67,9 +67,9 @@
<th>Test deselect</th> <th>Test deselect</th>
<td> <td>
<select id="test-deselect-select" multiple="multiple"> <select id="test-deselect-select" multiple="multiple">
<option value="1">1</option> <option value="1" selected="selected">1</option>
<option value="2">2</option> <option value="2" selected="selected">2</option>
<option value="3">3</option> <option value="3" selected="selected">3</option>
<option value="4">4</option> <option value="4">4</option>
<option value="5">5</option> <option value="5">5</option>
</select> </select>
...@@ -81,10 +81,6 @@ ...@@ -81,10 +81,6 @@
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {
// Some simple useful functions for testing.
function checkCheckbox(ul, value) {
return $('checkbox[value="1"]', element).is(':checked');
}
// Test build of multiselect. // Test build of multiselect.
var build = function() { var build = function() {
...@@ -145,6 +141,7 @@ ...@@ -145,6 +141,7 @@
$('#test-build-selected-tr td').last().html(buildSelected); $('#test-build-selected-tr td').last().html(buildSelected);
} }
// Test select.
var select = function() { var select = function() {
$('#test-deselect-select').multiselect(); $('#test-deselect-select').multiselect();
...@@ -171,10 +168,6 @@ ...@@ -171,10 +168,6 @@
return 'Wrong option selected.'; return 'Wrong option selected.';
} }
if (!checkCheckbox($('#test-select-select ul.multiselect-container'), 1)) {
return 'Corresponding checkbox not checked.';
}
$('#test-select-select').multiselect('select', [2, 3]); $('#test-select-select').multiselect('select', [2, 3]);
if ($('#test-select-select option:selected').length != 3) { if ($('#test-select-select option:selected').length != 3) {
...@@ -185,12 +178,19 @@ ...@@ -185,12 +178,19 @@
return 'Just selected two additional options - list items not set active.'; return 'Just selected two additional options - list items not set active.';
} }
if ($('#test-select-select option:selected')[1].val() != 2 || $('test-select-select option:selected')[2].val() != 3) { var second = $('#test-select-select option:selected').get(1),
return 'Wrong options selected.'; third = $('#test-select-select option:selected').get(2);
if (second == undefined || second.length == 0) {
return 'Could not get second option.';
}
if (third == undefined || third.length == 0) {
return 'Could not get third option.';
} }
if (!checkCheckbox($('#test-select-select ul.multiselect-container'), 2) || !checkCheckbox($('#test-select-select ul.multiselect-container'), 3)) { if ($(second).val() != 2 || $(third).val() != 3) {
return 'Corresponding checkboxes not checked.'; return 'Wrong options selected.';
} }
}(); }();
...@@ -199,15 +199,16 @@ ...@@ -199,15 +199,16 @@
$('#test-select-tr td').last().html(select); $('#test-select-tr td').last().html(select);
} }
// Test deselect.
var deselect = function() { var deselect = function() {
$('#test-deselect-select').multiselect(); $('#test-deselect-select').multiselect();
// Check for no selected options and no active li's. // Check for no selected options and no active li's.
if ($('test-deselect-select option:selected').length != 3) { if ($('#test-deselect-select option:selected').length != 3) {
return 'There should be 3 options selected.'; return 'There should be 3 options selected.';
} }
if ($('#test-deselect-tr ul.multiselect-container li.active').length != 0) { if ($('#test-deselect-tr ul.multiselect-container li.active').length != 3) {
return 'There should be 3 list items set to active.'; return 'There should be 3 list items set to active.';
} }
...@@ -217,31 +218,23 @@ ...@@ -217,31 +218,23 @@
return 'Just deselected an option - option not marked deselected.'; return 'Just deselected an option - option not marked deselected.';
} }
if ($('#test-deselect-tr ul.multiselect-container li.active').length != 1) { if ($('#test-deselect-tr ul.multiselect-container li.active').length != 2) {
return 'Just deselected an option - list item not set inactive.'; return 'Just deselected an option - list item not set inactive.';
} }
if ($('#test-deselect-select option:selected').first().val() != 1) { if ($('#test-deselect-select option:selected').first().val() != 2) {
return 'Wrong option deselected.'; return 'Wrong option deselected.';
} }
if (checkCheckbox($('#test-deselect-select ul.multiselect-container'), 1)) {
return 'Corresponding checkbox not unchecked.';
}
$('#test-deselect-select').multiselect('deselect', [2, 3]); $('#test-deselect-select').multiselect('deselect', [2, 3]);
if ($('#test-deselect-select option:selected').length != 3) { if ($('#test-deselect-select option:selected').length > 0) {
return 'Just deselected two additional options - options not marked deselected.'; return 'Just deselected two additional options - options not marked deselected.';
} }
if ($('#test-deselect-tr ul.multiselect-container li.active').length != 3) { if ($('#test-deselect-tr ul.multiselect-container li.active').length > 0) {
return 'Just deselected two additional options - list items not set unactive.'; return 'Just deselected two additional options - list items not set unactive.';
} }
if (checkCheckbox($('#test-deselect-select ul.multiselect-container'), 2) || checkCheckbox($('#test-deselect-select ul.multiselect-container'), 3)) {
return 'Corresponding checkboxes not checked.';
}
}(); }();
if (deselect) { if (deselect) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment