Skip to content

Commit

Permalink
v0.16.0, fix mustBeError test helper for nodeJS v10 assert changes
Browse files Browse the repository at this point in the history
  • Loading branch information
localnerve committed Jun 7, 2019
1 parent 6ecc72d commit a584cfe
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions test/helpers/result.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,23 @@
*/
var assert = require("assert");

function mustBeError(err) {
/**
* NodeJS v8 ifError throws if value is truthy
* NodeJS v10 ifError throws if value is NOT undefined or null.
* So to cover both, added falsy check.
*
* @param {*} err
*/
function notFalsy (err) {
return !!err;
}

function mustBeError (err) {
assert.throws(
function() {
assert.ifError(err);
function () {
notFalsy(err) && assert.ifError(err);
},
function(err) {
function (err) {
return !!err;
}
);
Expand Down

0 comments on commit a584cfe

Please sign in to comment.