Skip to content

Commit

Permalink
Add a notMessage option
Browse files Browse the repository at this point in the history
The problem with issue #47 is that chai-as-promised somtimes treats the final string parameter as a custom error message. We want to test that it does not do this anymore so we check to make sure that such string is not used as a custom error message.
  • Loading branch information
lddubeau authored and domenic committed Sep 27, 2016
1 parent 40fe94e commit 52beb1f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/support/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ global.shouldPass = function (promiseProducer) {
global.shouldFail = function (options) {
var promiseProducer = options.op;
var desiredMessageSubstring = options.message;
var nonDesiredMessageSubstring = options.notMessage;

it("should return a promise rejected with an assertion error", function (done) {
promiseProducer().then(function () {
Expand All @@ -39,6 +40,11 @@ global.shouldFail = function (options) {
throw new Error("Expected promise to be rejected with an AssertionError containing \"" +
desiredMessageSubstring + "\" but it was rejected with " + reason);
}

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

});
Expand Down

0 comments on commit 52beb1f

Please sign in to comment.