mirror of
https://github.com/chaijs/chai
synced 2024-11-14 15:57:10 +00:00
assert interface: add nestedInclude and notNestedInclude
This commit is contained in:
parent
875057d8ea
commit
7063b940a8
1 changed files with 45 additions and 0 deletions
|
@ -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])
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue