chai
chai copied to clipboard
assert.doesNotDecreaseBy not work as expected
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);
}
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.