Skip to content

Commit

Permalink
test(async): add async test
Browse files Browse the repository at this point in the history
  • Loading branch information
azu committed Mar 22, 2014
1 parent e8bc367 commit 9cb8d63
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion tests/power-doctest.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,16 @@ describe("power-doctest", function () {
});
});
describe("#runDocTest", function () {
context("when success test", function () {
context("when no assert code", function () {
it("should pass assert count = 0", function () {
var code = "var a = 1;";
return docPower.runDocTestAsPromise(code).then(function (result) {
var assertCount = 0;
assert.equal(result, assertCount);
});
});
});
context("when sync code", function () {
it("should pass assert count", function () {
var code = "var a = 1;\n" +
"a; // => 1";
Expand All @@ -142,6 +151,18 @@ describe("power-doctest", function () {
});
});
});
context("when async code", function () {
it("should pass assert count", function () {
var code = "setTimeout(function(){" +
"var a = 1;\n" +
"a; // => 1\n" +
"},1);";
return docPower.runDocTestAsPromise(code).then(function (result) {
var assertCount = 1;
assert.equal(result, assertCount);
});
});
});
context("when fail test", function () {
function assertDocTestError(error) {
assert.equal(error.name, "AssertionError");
Expand Down

0 comments on commit 9cb8d63

Please sign in to comment.