Skip to content

Commit

Permalink
Some minor changes and test additions
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Tsai committed Aug 23, 2015
1 parent 283cfce commit 6bf64f8
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 9 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
## jQuery Tree Multiselect
[![Build Status](https://travis-ci.org/patosai/tree-multiselect.js.svg?branch=master)](https://travis-ci.org/patosai/tree-multiselect.js)
## jQuery Tree Multiselect [![Build Status](https://travis-ci.org/patosai/tree-multiselect.js.svg?branch=master)](https://travis-ci.org/patosai/tree-multiselect.js)

**This plugin allows you to replace a `select` element with a sweet treeview element.**

Expand Down
2 changes: 1 addition & 1 deletion jquery.tree-multiselect.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions jquery.tree-multiselect.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jquery.tree-multiselect.js",
"version": "1.12.2",
"version": "1.12.3",
"description": "jQuery multiple select with nested options",
"main": "jquery.tree-multiselect.min.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/jquery.tree-multiselect.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* jQuery Tree Multiselect
* v1.12.2
* v1.12.3
*
* (c) Patrick Tsai
* MIT Licensed
Expand Down
4 changes: 2 additions & 2 deletions src/jquery.tree-multiselect.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* jQuery Tree Multiselect
* v1.12.2
* v1.12.3
*
* (c) Patrick Tsai
* MIT Licensed
Expand Down Expand Up @@ -383,7 +383,7 @@
$(this).attr('data-index', undefined);
var sectionName = $.map($(this).parentsUntil(selectionContainer, "div.section").get().reverse(), function(parentSection) {
return textOf($(parentSection).find("> div.title"));
}).join("/");
}).join(options.sectionDelimiter);
selections.push({ text: text, value: value, index: index, sectionName: sectionName });
});
selections.sort(function(a, b) {
Expand Down
38 changes: 38 additions & 0 deletions test/integration/adding-removing.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
QUnit.module("Adding and Removing", {
beforeEach: function(assert) {
var select = document.createElement("select");
select.setAttribute("multiple", "multiple");
$("div#qunit-fixture").append(select);
assert.equal($("select").length, 1);
}
});

QUnit.test("can add an item", function(assert) {
$("select").append("<option value='one' data-section='section'>One</option>");
$("select").treeMultiselect();

assert.equal($("div.selections div.item").length, 1, "there should be one item for selection");
assert.equal($("div.selected div.item").length, 0, "no items should be selected");

$("div.selections div.item > input[type=checkbox]").prop('checked', true).trigger('change');

assert.equal($("div.selections div.item > input[type=checkbox]:checked").length, 1, "the one item should be checked");
var selectedItem = $("div.selected div.item");
assert.equal($("div.selected div.item").length, 1, "there should be one item in the selected div");

assert.equal(textOf(selectedItem), 'One', "selected item text should be 'one'");
assert.equal(textOf(selectedItem.find("> span.selectedSectionName")), 'section', "selected item section label should be 'section'");
});

QUnit.test("can remove an item", function(assert) {
$("select").append("<option value='one' data-section='section' selected='selected'>One</option>");
$("select").treeMultiselect();

var selectedItem = $("div.selected div.item");
assert.equal(selectedItem.length, 1, "there should be one selected item");

var removeSpan = selectedItem.find("> span.remove-selected");
removeSpan.trigger('click');

assert.equal($("div.selected div.item").length, 0, "there should now be no selected items");
});
1 change: 1 addition & 0 deletions test/runner.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<script src="./qunit-1.18.0.js"></script>
<script src="./helper.js"></script>

<script src="./integration/adding-removing.js"></script>
<script src="./integration/options.js"></script>
<script src="./integration/section-creation.js"></script>
<script src="./integration/title-autochecking.js"></script>
Expand Down

0 comments on commit 6bf64f8

Please sign in to comment.