Skip to content

Instantly share code, notes, and snippets.

@nstadigs
Last active August 29, 2015 13:57
Show Gist options
  • Save nstadigs/9830406 to your computer and use it in GitHub Desktop.
Save nstadigs/9830406 to your computer and use it in GitHub Desktop.
async.it('waits to request to finish', function (done) {
doRequest().then(function (data) {
expect(data).toEqual('hello world');
done();
})
});
var async = (function () {
function createAsyncVersion (fn) {
return function () {
var args = Array.prototype.slice.call(arguments),
testFunc = args.pop(),
isDone;
function declareDone () {
isDone = true;
}
args.push(function () {
waitsFor(function () {
return isDone;
});
return testFunc(declareDone);
});
return fn.apply(this, args);
};
}
return {
beforeEach: createAsyncVersion(beforeEach),
afterEach: createAsyncVersion(afterEach),
it: createAsyncVersion(it)
};
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment