Skip to content

Commit

Permalink
assert interface: add nestedInclude and notNestedInclude
Browse files Browse the repository at this point in the history
  • Loading branch information
zetamorph committed May 4, 2017
1 parent 875057d commit 7063b94
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions lib/chai/interface/assert.js
Expand Up @@ -1012,6 +1012,51 @@ module.exports = function (chai, util) {
new Assertion(exp, msg, assert.notDeepInclude, true).not.deep.include(inc);
};

/**
* ### .nestedInclude
*
* Asserts that 'targetObject' includes 'nestedObject'.
* 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} targetObject
* @param {Object} nestedObject
* @param {String} message
* @namespace Assert
* @api public
*/

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

/**
* ### .notNestedInclude
*
* Asserts that 'targetObject' does not include 'nestedObject'.
* 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} targetObject
* @param {Object} nestedObject
* @param {String} message
* @namespace Assert
* @api public
*/

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

/**
* ### .match(value, regexp, [message])
*
Expand Down

0 comments on commit 7063b94

Please sign in to comment.