Skip to content

Instantly share code, notes, and snippets.

@andreabalducci
Created August 6, 2012 13:49
Show Gist options
  • Save andreabalducci/3274571 to your computer and use it in GitHub Desktop.
Save andreabalducci/3274571 to your computer and use it in GitHub Desktop.
expectAsync extension for jasmine
var CALL_TIMEOUT = 4000;
function expectAsync(promise, expectations) {
var completed = false;
runs(function () {
promise.call().always(function () {
completed = true;
})
});
waitsFor(function () {
return completed;
}, CALL_TIMEOUT);
runs(function () {
expectations.call();
});
}
@andreabalducci
Copy link
Author

it("server connection should be invalid", function () {
    expectAsync(function () {
        return client.discover();
    }, function () {
        expect(client.hasValidSession()).toBeFalsy();
    });
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment