Skip to content

Instantly share code, notes, and snippets.

@DioNNiS
Created June 2, 2014 11:21
Show Gist options
  • Save DioNNiS/539bc071ca5093bf4a30 to your computer and use it in GitHub Desktop.
Save DioNNiS/539bc071ca5093bf4a30 to your computer and use it in GitHub Desktop.
qUnit: multiple async tests in one test
asyncTest( "multiple async setTimeout", function() {
expect( 4 );
// Limit total time to 2 sec.
var counter = 2, timeout = setTimeout(function() {start();}, 2000);
function done() { if(--counter === 0) {start(); clearTimeout(timeout);}}
var url = "http://jsfiddle.net/echo/jsonp/?callback=?";
$.getJSON( url, { a: 1 }, function( data ) {
ok( data, "data is returned from the server" );
equal( data.a, "1", "the value of data.a should be 1" );
done();
});
$.getJSON( url, { b: 2 }, function( data ) {
ok( data, "data is returned from the server" );
equal( data.b, "2", "the value of data.b should be 2" );
done();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment