assert interface: add nestedInclude and notNestedInclude

This commit is contained in:
Johannes Loewe 2017-05-01 21:59:08 +02:00
parent 875057d8ea
commit 7063b940a8

View file

@ -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])
*