Last active
August 29, 2015 13:57
-
-
Save nstadigs/9830406 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
async.it('waits to request to finish', function (done) { | |
doRequest().then(function (data) { | |
expect(data).toEqual('hello world'); | |
done(); | |
}) | |
}); |
This file contains hidden or 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
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