Skip to content

Commit

Permalink
Add test for sortable
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Tsai committed Apr 15, 2016
1 parent 088cfab commit 7f58070
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions conf/karma.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module.exports = function(config) {
// list of files / patterns to load in the browser
files: [
'test/lib/jquery-1.11.3.min.js',
'test/lib/jquery-ui.min.js',
'src/jquery.tree-multiselect.js',
'test/helper.js',
'test/integration/*.js',
Expand Down
15 changes: 15 additions & 0 deletions test/integration/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,21 @@ QUnit.test("onChange callback is called with correct args when item is removed",
item.find("input[type=checkbox]").click();
});

QUnit.test("sortable actually sorts the options", function(assert) {
$("select").append("<option value='one' data-section='test' selected='selected'>One</option>");
$("select").append("<option value='two' data-section='test' selected='selected'>Two</option>");
$("select").treeMultiselect({ sortable: true });

assert.deepEqual($("select").val(), ['one', 'two']);

var $one = $("div.selected div.item[data-value='one']");
var $two = $("div.selected div.item[data-value='two']");
$one.insertAfter($two);
$("div.selected").sortable('option', 'update')();

assert.deepEqual($("select").val(), ['two', 'one']);
});

QUnit.test("select all button is created and it works", function(assert) {
$("select").append("<option value='one' data-section='test'>One</option>");
$("select").append("<option value='two' data-section='test'>Two</option>");
Expand Down
7 changes: 7 additions & 0 deletions test/lib/jquery-ui.min.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion test/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<meta charset="UTF-8">

<script src="./lib/jquery-1.11.3.min.js"></script>
<script src="./lib/jquery-ui.min.js"></script>
<script src="../src/jquery.tree-multiselect.js"></script>

<style>
Expand All @@ -27,7 +28,7 @@
</select>

<script type="text/javascript">
$("#test-select").treeMultiselect({ enableSelectAll: true });
$("#test-select").treeMultiselect({ enableSelectAll: true, sortable: true });
</script>
</body>
</html>

0 comments on commit 7f58070

Please sign in to comment.