MCPcopy
hub / github.com/louischatriot/nedb / assertChanges

Function assertChanges

browser-version/test/chai.js:2393–2407  ·  view source on GitHub ↗

* ### .change(function) * * Asserts that a function changes an object property * * var obj = { val: 10 }; * var fn = function() { obj.val += 3 }; * var noChangeFn = function() { return 'foo' + 'bar'; } * expect(fn).to.change(obj, 'val'); * expect(noChangFn

(object, prop, msg)

Source from the content-addressed store, hash-verified

2391 */
2392
2393 function assertChanges (object, prop, msg) {
2394 if (msg) flag(this, 'message', msg);
2395 var fn = flag(this, 'object');
2396 new Assertion(object, msg).to.have.property(prop);
2397 new Assertion(fn).is.a('function');
2398
2399 var initial = object[prop];
2400 fn();
2401
2402 this.assert(
2403 initial !== object[prop]
2404 , 'expected .' + prop + ' to change'
2405 , 'expected .' + prop + ' to not change'
2406 );
2407 }
2408
2409 Assertion.addChainableMethod('change', assertChanges);
2410 Assertion.addChainableMethod('changes', assertChanges);

Callers

nothing calls this directly

Calls 1

fnFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…