Created
December 16, 2011 16:23
-
-
Save cjohansen/1486702 to your computer and use it in GitHub Desktop.
Asynchronous Buster.JS tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Oops: Defaut test runner timeout is 250ms | |
buster.testCase("Async stuff", { | |
"does things asynchonously": function (done) { | |
setTimeout(function () { | |
assert(true); | |
done(); | |
}, 100); | |
}, | |
"does things asynchonously with promises": function () { | |
var deferred = when.defer(); | |
setTimeout(function () { | |
assert(true); | |
deferred.resolver.resolve(); | |
}, 100); | |
return deferred.promise; | |
} | |
}); | |
// Specs | |
buster.spec.expose(); // Make functions global | |
describe("Async stuff", { | |
it("does things asynchonously", function (done) { | |
setTimeout(function () { | |
assert(true); | |
done(); | |
}, 100); | |
}); | |
it("does things asynchonously with promises", function () { | |
var deferred = when.defer(); | |
setTimeout(function () { | |
assert(true); | |
deferred.resolver.resolve(); | |
}, 100); | |
return deferred.promise; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
omfg, just spent way too long trying to get squireJs working with buster...after seeing this, however, it finally made sense. Thanks!