Created
June 2, 2014 11:21
-
-
Save DioNNiS/539bc071ca5093bf4a30 to your computer and use it in GitHub Desktop.
qUnit: multiple async tests in one test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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