Skip to content

Commit

Permalink
Merge pull request #556 from unexpectedjs/feature/simplifyToBeRejecte…
Browse files Browse the repository at this point in the history
…dWith

Simplify the "to be rejected with" and "to call the callback with error" assertions
  • Loading branch information
papandreou authored Jan 3, 2019
2 parents b699ac7 + d900648 commit b8ae69a
Showing 1 changed file with 2 additions and 21 deletions.
23 changes: 2 additions & 21 deletions lib/assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const arrayChanges = require('array-changes');
const arrayChangesAsync = require('array-changes-async');
const throwIfNonUnexpectedError = require('./throwIfNonUnexpectedError');
const objectIs = utils.objectIs;
const isRegExp = utils.isRegExp;
const extend = utils.extend;

module.exports = expect => {
Expand Down Expand Up @@ -2265,17 +2264,7 @@ module.exports = expect => {
expect.errorMode = 'nested';
return expect(subject, 'to be rejected').tap(err =>
expect.withError(
() => {
if (
err &&
err._isUnexpected &&
(typeof value === 'string' || isRegExp(value))
) {
return expect(err, 'to have message', value);
} else {
return expect(err, 'to [exhaustively] satisfy', value);
}
},
() => expect(err, 'to [exhaustively] satisfy', value),
e => {
e.originalError = err;
throw e;
Expand Down Expand Up @@ -2525,15 +2514,7 @@ module.exports = expect => {
(expect, subject, value) =>
expect(subject, 'to call the callback with error').tap(err => {
expect.errorMode = 'nested';
if (
err &&
err._isUnexpected &&
(typeof value === 'string' || isRegExp(value))
) {
return expect(err, 'to have message', value);
} else {
return expect(err, 'to satisfy', value);
}
expect(err, 'to satisfy', value);
})
);
};

0 comments on commit b8ae69a

Please sign in to comment.