Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sukrosono committed Nov 21, 2017
1 parent ec3971b commit 12a70f4
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 59 deletions.
106 changes: 52 additions & 54 deletions lib/chai/interface/assert.js
Expand Up @@ -1012,49 +1012,49 @@ module.exports = function (chai, util) {

/**
* ### .nestedInclude(haystack, needle, [message])
*
* Asserts that 'haystack' includes 'needle'.
* Can be used to assert the inclusion of a subset of properties in an
*
* Asserts that 'haystack' includes 'needle'.
* Can be used to assert the inclusion of a subset of properties in an
* object.
* Enables the use of dot- and bracket-notation for referencing nested
* Enables the use of dot- and bracket-notation for referencing nested
* properties.
* '[]' and '.' in property names can be escaped using double backslashes.
*
*
* assert.nestedInclude({'.a': {'b': 'x'}}, {'\\.a.[b]': 'x'});
* assert.nestedInclude({'a': {'[b]': 'x'}}, {'a.\\[b\\]': 'x'});
*
*
* @name nestedInclude
* @param {Object} haystack
* @param {Object} needle
* @param {String} message
* @namespace Assert
* @api public
*/
* @api public
*/

assert.nestedInclude = function (exp, inc, msg) {
new Assertion(exp, msg, assert.nestedInclude, true).nested.include(inc);
};

/**
* ### .notNestedInclude(haystack, needle, [message])
*
* Asserts that 'haystack' does not include 'needle'.
* Can be used to assert the absence of a subset of properties in an
*
* Asserts that 'haystack' does not include 'needle'.
* Can be used to assert the absence of a subset of properties in an
* object.
* Enables the use of dot- and bracket-notation for referencing nested
* properties.
* Enables the use of dot- and bracket-notation for referencing nested
* properties.
* '[]' and '.' in property names can be escaped using double backslashes.
*
*
* assert.notNestedInclude({'.a': {'b': 'x'}}, {'\\.a.b': 'y'});
* assert.notNestedInclude({'a': {'[b]': 'x'}}, {'a.\\[b\\]': 'y'});
*
*
* @name notNestedInclude
* @param {Object} haystack
* @param {Object} needle
* @param {String} message
* @namespace Assert
* @api public
*/
* @api public
*/

assert.notNestedInclude = function (exp, inc, msg) {
new Assertion(exp, msg, assert.notNestedInclude, true)
Expand All @@ -1063,23 +1063,23 @@ module.exports = function (chai, util) {

/**
* ### .deepNestedInclude(haystack, needle, [message])
*
*
* Asserts that 'haystack' includes 'needle'.
* Can be used to assert the inclusion of a subset of properties in an
* Can be used to assert the inclusion of a subset of properties in an
* object while checking for deep equality.
* Enables the use of dot- and bracket-notation for referencing nested
* Enables the use of dot- and bracket-notation for referencing nested
* properties.
* '[]' and '.' in property names can be escaped using double backslashes.
*
*
* assert.deepNestedInclude({a: {b: [{x: 1}]}}, {'a.b[0]': {x: 1}});
* assert.deepNestedInclude({'.a': {'[b]': {x: 1}}}, {'\\.a.\\[b\\]': {x: 1}});
*
*
* @name deepNestedInclude
* @param {Object} haystack
* @param {Object} needle
* @param {String} message
* @namespace Assert
* @api public
* @api public
*/

assert.deepNestedInclude = function(exp, inc, msg) {
Expand All @@ -1089,23 +1089,23 @@ module.exports = function (chai, util) {

/**
* ### .notDeepNestedInclude(haystack, needle, [message])
*
*
* Asserts that 'haystack' does not include 'needle'.
* Can be used to assert the absence of a subset of properties in an
* Can be used to assert the absence of a subset of properties in an
* object while checking for deep equality.
* Enables the use of dot- and bracket-notation for referencing nested
* Enables the use of dot- and bracket-notation for referencing nested
* properties.
* '[]' and '.' in property names can be escaped using double backslashes.
*
*
* assert.notDeepNestedInclude({a: {b: [{x: 1}]}}, {'a.b[0]': {y: 1}})
* assert.notDeepNestedInclude({'.a': {'[b]': {x: 1}}}, {'\\.a.\\[b\\]': {y: 2}});
*
*
* @name notDeepNestedInclude
* @param {Object} haystack
* @param {Object} needle
* @param {String} message
* @namespace Assert
* @api public
* @api public
*/

assert.notDeepNestedInclude = function(exp, inc, msg) {
Expand All @@ -1115,13 +1115,13 @@ module.exports = function (chai, util) {

/**
* ### .ownInclude(haystack, needle, [message])
*
*
* Asserts that 'haystack' includes 'needle'.
* Can be used to assert the inclusion of a subset of properties in an
* Can be used to assert the inclusion of a subset of properties in an
* object while ignoring inherited properties.
*
*
* assert.ownInclude({ a: 1 }, { a: 1 });
*
*
* @name ownInclude
* @param {Object} haystack
* @param {Object} needle
Expand All @@ -1136,15 +1136,15 @@ module.exports = function (chai, util) {

/**
* ### .notOwnInclude(haystack, needle, [message])
*
*
* Asserts that 'haystack' includes 'needle'.
* Can be used to assert the absence of a subset of properties in an
* Can be used to assert the absence of a subset of properties in an
* object while ignoring inherited properties.
*
*
* Object.prototype.b = 2;
*
*
* assert.notOwnInclude({ a: 1 }, { b: 2 });
*
*
* @name notOwnInclude
* @param {Object} haystack
* @param {Object} needle
Expand All @@ -1159,13 +1159,13 @@ module.exports = function (chai, util) {

/**
* ### .deepOwnInclude(haystack, needle, [message])
*
*
* Asserts that 'haystack' includes 'needle'.
* Can be used to assert the inclusion of a subset of properties in an
* Can be used to assert the inclusion of a subset of properties in an
* object while ignoring inherited properties and checking for deep equality.
*
*
* assert.deepOwnInclude({a: {b: 2}}, {a: {b: 2}});
*
*
* @name deepOwnInclude
* @param {Object} haystack
* @param {Object} needle
Expand All @@ -1181,13 +1181,13 @@ module.exports = function (chai, util) {

/**
* ### .notDeepOwnInclude(haystack, needle, [message])
*
*
* Asserts that 'haystack' includes 'needle'.
* Can be used to assert the absence of a subset of properties in an
* Can be used to assert the absence of a subset of properties in an
* object while ignoring inherited properties and checking for deep equality.
*
*
* assert.notDeepOwnInclude({a: {b: 2}}, {a: {c: 3}});
*
*
* @name notDeepOwnInclude
* @param {Object} haystack
* @param {Object} needle
Expand Down Expand Up @@ -2645,7 +2645,7 @@ module.exports = function (chai, util) {
assert.increasesBy = function (fn, obj, prop, delta, msg) {
if (arguments.length === 4 && typeof obj === 'function') {
var tmpMsg = delta;
delta = prop;
prop = null;
msg = tmpMsg;
} else if (arguments.length === 3) {
delta = prop;
Expand Down Expand Up @@ -2705,9 +2705,8 @@ module.exports = function (chai, util) {

assert.increasesButNotBy = function (fn, obj, prop, delta, msg) {
if (arguments.length === 4 && typeof obj === 'function') {
var tmpMsg = delta;
delta = prop;
msg = tmpMsg;
msg = 'getter function';
prop = null;
} else if (arguments.length === 3) {
delta = prop;
prop = null;
Expand Down Expand Up @@ -2767,8 +2766,8 @@ module.exports = function (chai, util) {
assert.decreasesBy = function (fn, obj, prop, delta, msg) {
if (arguments.length === 4 && typeof obj === 'function') {
var tmpMsg = delta;
delta = prop;
msg = tmpMsg;
prop = null;
} else if (arguments.length === 3) {
delta = prop;
prop = null;
Expand Down Expand Up @@ -2860,9 +2859,8 @@ module.exports = function (chai, util) {

assert.decreasesButNotBy = function (fn, obj, prop, delta, msg) {
if (arguments.length === 4 && typeof obj === 'function') {
var tmpMsg = delta;
delta = prop;
msg = tmpMsg;
msg = 'getter function';
prop= null;
} else if (arguments.length === 3) {
delta = prop;
prop = null;
Expand Down
10 changes: 5 additions & 5 deletions test/assert.js
Expand Up @@ -2086,7 +2086,7 @@ describe('assert', function () {
err(function() {
assert.isAbove(now, now, 'blah');
}, 'blah: expected ' + now.toUTCString() + ' to be above ' + now.toUTCString());

err(function() {
assert.isAbove(null, now);
}, 'expected null to be a number or a date');
Expand Down Expand Up @@ -2315,18 +2315,18 @@ describe('assert', function () {
assert.doesNotDecrease(smFn, obj, 'value');
assert.doesNotDecrease(smFn, getterFn, 'value');
assert.decreasesBy(decFn, obj, 'value', 3);
// assert.decreasesBy(decFn, getterFn, 'value', 3);
assert.decreasesBy(decFn, getterFn, 'value', 3);
assert.decreasesButNotBy(decFn, obj, 'value', 10);
// assert.decreasesButNotBy(decFn, getterFn, 'value', 10);
assert.decreasesButNotBy(decFn, getterFn, 'value', 11);

assert.increases(incFn, obj, 'value');
assert.increases(incFn, getterFn, 'value');
assert.doesNotIncrease(smFn, obj, 'value');
assert.doesNotIncrease(smFn, getterFn, 'value');
assert.increasesBy(incFn, obj, 'value', 2);
// assert.increasesBy(incFn, getterFn, 'value', 2);
assert.increasesBy(incFn, getterFn, 'value', 2);
assert.increasesButNotBy(incFn, obj, 'value', 1);
// assert.increasesButNotBy(incFn, getterFn, 'value', 1);
assert.increasesButNotBy(incFn, getterFn, 'value', 3);

assert.decreases(popFn, lenFn);
assert.doesNotDecrease(pFn, lenFn);
Expand Down

0 comments on commit 12a70f4

Please sign in to comment.