Skip to content

Instantly share code, notes, and snippets.

@juliocesar
Forked from suranyami/fails.coffee
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juliocesar/9965427 to your computer and use it in GitHub Desktop.
Save juliocesar/9965427 to your computer and use it in GitHub Desktop.
describe "Asynchronous specs", ->
funcRunInBackground = ->
value = 1
wrapFuncRunInBackground = (done) ->
# setup for simmulating the async operation, a function run in the background
setTimeout ->
funcRunInBackground()
done()
, 3000
value = 0
beforeEach (done) ->
wrapFuncRunInBackground done
console.log "wrap function returns immediately but value = 1 is set 3 seconds later. value is still " + value
it "should support async execution of test preparation", ->
expect(value).toBeGreaterThan 0
describe("Asynchronous specs", function() {
var value = 0;
function funcRunInBackground() {
value = 1;
};
function wrapFuncRunInBackground(done) {
// setup for simmulating the async operation, a function run in the background
setTimeout(function() {
funcRunInBackground();
done();
}, 3000);
}
beforeEach(function(done) {
wrapFuncRunInBackground(done);
console.log("wrap function returns immediately but value = 1 is set 3 seconds later. value is still " + value);
});
it("should support async execution of test preparation", function() {
expect(value).toBeGreaterThan(0);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment