Skip to content

Instantly share code, notes, and snippets.

@xrd
Created November 10, 2008 21:11
Show Gist options
  • Save xrd/23629 to your computer and use it in GitHub Desktop.
Save xrd/23629 to your computer and use it in GitHub Desktop.
describe("tablesort", function() {
var table = "<table class='tablesorter' id='sorted'><thead><th>Foo</th><th>Blah</th></thead><tbody>" +
"<tr><td>3</td><td>2</td></tr>" +
"<tr><td>100</td><td>5</td></tr>" +
"<tr><td>1</td><td>5</td></tr>" +
"</tbody></table>";
it( "creates a tablesorter and sorts properly", function() {
$("#harness").html(table);
$('#sorted').tablesorter();
// Should have the order we put it in.
expect($('#sorted td:first').html()).to(equal,"3");
$('#sorted th:first').click();
$('#sorted th:first').click();
// do this kind of thing to "wait" for the value
// And, the expect loses context so errors get stuck into the console.log, not where we want
// them to. But, if your tests pass, all is well. :)
function callLater(yourdaddy) {
var me = yourdaddy;
return function() {
me.expect($('#sorted td:first').html()).to(equal,'100');
}
}
var funcRef = callLater(self);
setTimeout( funcRef, 1000 );
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment