Created
November 15, 2013 13:35
-
-
Save asciidisco/7484405 to your computer and use it in GitHub Desktop.
dalek_waitFor.js
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
// you app code | |
window.qa = {}; | |
$.get('foobar.php', function (data) { | |
// this line could be removed during the build | |
window.qa.requestFooBar = true; | |
}); | |
// in your dalek test | |
'waitFor ajax': function (test) { | |
test.waitFor(function () { | |
return !!window.qa.requestFooBar; | |
}, 10000) | |
// do something after the request finished | |
.done(); | |
} | |
// or if you like promises | |
var window.request = $.get('foobar.php', function () {}); | |
// in your dalek test | |
'waitFor ajax (with promises)': function (test) { | |
test.waitFor(function () { | |
var isDone = false; | |
window.request.done(function () { isDone = true; }); | |
return isDone; | |
}, 10000) | |
// do something after the request finished | |
.done(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment