chai icon indicating copy to clipboard operation
chai copied to clipboard

assert.doesNotDecreaseBy not work as expected

Open benben77 opened this issue 5 years ago • 1 comments

I am using [email protected]

According to docs:

var obj = { val: 10 };
var fn = function() { obj.val = 5 };
assert.doesNotDecreaseBy(fn, obj, 'val', 1);

should pass.

But doesNotDecreaseBy pass when the value does not decrease:

assert.doesNotDecreaseBy = function (fn, obj, prop, delta, msg) {
  if (arguments.length === 4 && typeof obj === 'function') {
    var tmpMsg = delta;
    delta = prop;
    msg = tmpMsg;
  } else if (arguments.length === 3) {
    delta = prop;
    prop = null;
  }

  return new Assertion(fn, msg, assert.doesNotDecreaseBy, true)
    .to.not.decrease(obj, prop).by(delta);
}

benben77 avatar Jul 15 '19 06:07 benben77

From what I can see in the code, it doesn't even get to the "by" part, because it already fails on the "does not decrease" part.

rgroothuijsen avatar Apr 16 '20 15:04 rgroothuijsen