Slide 28
Slide 28 text
https://github.com/pivotal/jasmine/wiki
Asynchronous specs V
waitsFor(function, optional message, optional timeout)
waitsFor() . Provides a better interface for pausing your spec until some other
work has completed.
Jasmine will wait until the provided function returns true before continuing
with the next block. This may mean waiting an arbitrary period of time, or you
may specify a maxiumum period in milliseconds before timing out.
describe("Calculator", function() {
it("should factor two huge numbers asynchronously", function() { var calc = new Calculator(); var answer = calc.
factor(18973547201226, 28460320801839); waitsFor(function() { return calc.answerHasBeenCalculated();
}, "It took too long to find those factors.", 10000);
runs(function() {
expect(answer).toEqual(9486773600613);
});
});
});