Skip to content

Commit

Permalink
Restructure to avoid so much nesting
Browse files Browse the repository at this point in the history
  • Loading branch information
lddubeau authored and domenic committed Sep 27, 2016
1 parent 62e137f commit 40fe94e
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions test/support/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,18 @@ global.shouldFail = function (options) {

it("should return a promise rejected with an assertion error", function (done) {
promiseProducer().then(function () {
done(new Error("Expected promise to be rejected with an assertion error, but it was fulfilled"));
throw new Error("Expected promise to be rejected with an assertion error, but it was fulfilled");
}, function (reason) {
if (Object(reason) !== reason || reason.constructor.name !== "AssertionError") {
done(new Error("Expected promise to be rejected with an AssertionError but it was rejected with " +
reason));
} else {
if (desiredMessageSubstring && reason.message.indexOf(desiredMessageSubstring) === -1) {
done(new Error("Expected promise to be rejected with an AssertionError containing \"" +
desiredMessageSubstring + "\" but it was rejected with " + reason));
} else {
done();
}
throw new Error("Expected promise to be rejected with an AssertionError but it was rejected with " +
reason);
}
});

if (desiredMessageSubstring && reason.message.indexOf(desiredMessageSubstring) === -1) {
throw new Error("Expected promise to be rejected with an AssertionError containing \"" +
desiredMessageSubstring + "\" but it was rejected with " + reason);
}
}).then(done, done);

});
};

0 comments on commit 40fe94e

Please sign in to comment.