Skip to content

Commit

Permalink
Merge pull request #56 from tristen/v2.1.0
Browse files Browse the repository at this point in the history
Add tests + version bump
  • Loading branch information
tristen committed Jan 10, 2015
2 parents 9b5637b + 2b4feb2 commit 027636c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tablesort",
"description": "A sorting component for HTML tables",
"version": "2.0.1",
"version": "2.1.0",
"author": "tristen <@fallsemo>",
"ender": "./ender.js",
"main": "./src/tablesort.js",
Expand Down
6 changes: 3 additions & 3 deletions tablesort.min.js

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

22 changes: 21 additions & 1 deletion test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<th>Birthday</th>
<th>Grocery item</th>
<th>Price</th>
<th>Version</th>
</tr>
</thead>
<tbody>
Expand All @@ -23,20 +24,23 @@
<td>12-2-70</td>
<td>Radishes</td>
<td>$0.63</td>
<td>31.0.1650.57</td>
</tr>
<tr>
<td>2</td>
<td>Ernie</td>
<td>10/11/69</td>
<td>Fish</td>
<td>$12.09</td>
<td>11.0.1</td>
</tr>
<tr>
<td>3</td>
<td>Bert</td>
<td>10/11/1969</td>
<td>Broccoli</td>
<td>$0.79</td>
<td>18.0.1284.49</td>
</tr>
</tbody>
</table>
Expand All @@ -52,7 +56,9 @@

tape('Sorting with no options', function(t) {
t.plan(3);
var el = table.querySelector('th')

// Number column
var el = table.querySelector('th:nth-child(1)');
var event = document.createEvent('HTMLEvents');
event.initEvent('click', true, false);
el.dispatchEvent(event);
Expand All @@ -63,6 +69,20 @@
t.equal(parseInt(c.textContent, 10), count--, 'Values sorted');
});
});

tape('Sorting dot separated numbers', function(t) {
t.plan(3);

var el = table.querySelector('th:nth-child(6)');
var event = document.createEvent('HTMLEvents');
event.initEvent('click', true, false);
el.dispatchEvent(event);

// Test the version column has sorted
t.equal(table.rows[1].cells[5].innerHTML, '11.0.1');
t.equal(table.rows[2].cells[5].innerHTML, '18.0.1284.49');
t.equal(table.rows[3].cells[5].innerHTML, '31.0.1650.57');
});
</script>
</body>
</html>

0 comments on commit 027636c

Please sign in to comment.