public
Last active

  • Download Gist
1.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
describe("an async spec", function(){
 
beforeEach(function(){
var done = false;
 
function doStuff(){
// simulate async stuff and wait 10ms
setTimeout(function(){
done = true;
}, 10);
}
 
runs(doStuff);
 
waitsFor(function(){
return done;
});
});
 
it("did stuff", function(){
expect(done).toBe(true);
});
 
});
2.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
describe("an async spec", function(){
 
var foo = false,
async = new AsyncSpec(this);
 
async.beforeEach(function(done){
 
// simulate async stuff and wait 10ms
setTimeout(function(){
foo = true;
done();
}, 10);
 
});
 
it("did stuff", function(){
expect(foo).toBe(true);
});
 
});

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.