Skip to content

Commit

Permalink
Improve docs for "increase | decrease"
Browse files Browse the repository at this point in the history
Indicate that 'property' and 'message' are optional.
Indicate that 'increase' and 'decrease' can receive a function which
returns the property to be checked.
  • Loading branch information
vieiralucas committed Sep 12, 2016
1 parent c802d38 commit 5f3c4ae
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions lib/chai/core/assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1959,19 +1959,26 @@ module.exports = function (chai, _) {
Assertion.addChainableMethod('changes', assertChanges);

/**
* ### .increase(function)
* ### .increase(target[, property[, message]])
*
* Asserts that a function increases a numeric object property
*
* var obj = { val: 10 };
* var fn = function() { obj.val = 15 };
* expect(fn).to.increase(obj, 'val');
*
* It can also receive a function which returns the property
*
* var obj = { val: 10 };
* var fn = function() { obj.val = 5 };
* var getVal = function() { return obj.val };
* expect(fn).to.increase(getVal);
*
* @name increase
* @alias increases
* @alias Increase
* @param {String} target
* @param {String} property name
* @param {String|Function} target
* @param {String} property name _optional_
* @param {String} message _optional_
* @namespace BDD
* @api public
Expand Down Expand Up @@ -2016,19 +2023,26 @@ module.exports = function (chai, _) {
Assertion.addChainableMethod('increases', assertIncreases);

/**
* ### .decrease(function)
* ### .decrease(target[, property[, message]])
*
* Asserts that a function decreases a numeric object property
*
* var obj = { val: 10 };
* var fn = function() { obj.val = 5 };
* expect(fn).to.decrease(obj, 'val');
*
* It can also receive a function which returns the property
*
* var obj = { val: 10 };
* var fn = function() { obj.val = 5 };
* var getVal = function() { return obj.val };
* expect(fn).to.decrease(getVal);
*
* @name decrease
* @alias decreases
* @alias Decrease
* @param {String} target
* @param {String} property name
* @param {String|Function} target
* @param {String} property name _optional_
* @param {String} message _optional_
* @namespace BDD
* @api public
Expand Down

0 comments on commit 5f3c4ae

Please sign in to comment.