Skip to content

Instantly share code, notes, and snippets.

Created October 3, 2012 04:32
Show Gist options
  • Save anonymous/3825008 to your computer and use it in GitHub Desktop.
Save anonymous/3825008 to your computer and use it in GitHub Desktop.
Jasmine.Async example
var Calculator = function(displayElement) {
this.$el = $(displayElement);
};
Calculator.prototype.hideResult = function(cb) {
this.$el.fadeOut(1000, cb);
};
describe("Calculator", function() {
var calc, el;
var async = new AsyncSpec(this);
beforeEach(function() {
el = $("<div>some content</div>");
$("#container").append(el);
calc = new Calculator(el);
});
afterEach(function() {
el.remove();
});
async.it("should make the result invisible", function(done) {
var callback = function() {
expect(el.css("display")).toBe("none");
done();
};
calc.hideResult(callback);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment