@@ -1012,6 +1012,197 @@ module.exports = function (chai, util) {
1012
1012
new Assertion ( exp , msg , assert . notDeepInclude , true ) . not . deep . include ( inc ) ;
1013
1013
} ;
1014
1014
1015
+ /**
1016
+ * ### .nestedInclude(haystack, needle, [message])
1017
+ *
1018
+ * Asserts that 'haystack' includes 'needle'.
1019
+ * Can be used to assert the inclusion of a subset of properties in an
1020
+ * object.
1021
+ * Enables the use of dot- and bracket-notation for referencing nested
1022
+ * properties.
1023
+ * '[]' and '.' in property names can be escaped using double backslashes.
1024
+ *
1025
+ * assert.nestedInclude({'.a': {'b': 'x'}}, {'\\.a.[b]': 'x'});
1026
+ * assert.nestedInclude({'a': {'[b]': 'x'}}, {'a.\\[b\\]': 'x'});
1027
+ *
1028
+ * @name nestedInclude
1029
+ * @param {Object } haystack
1030
+ * @param {Object } needle
1031
+ * @param {String } message
1032
+ * @namespace Assert
1033
+ * @api public
1034
+ */
1035
+
1036
+ assert . nestedInclude = function ( exp , inc , msg ) {
1037
+ new Assertion ( exp , msg , assert . nestedInclude , true ) . nested . include ( inc ) ;
1038
+ } ;
1039
+
1040
+ /**
1041
+ * ### .notNestedInclude(haystack, needle, [message])
1042
+ *
1043
+ * Asserts that 'haystack' does not include 'needle'.
1044
+ * Can be used to assert the absence of a subset of properties in an
1045
+ * object.
1046
+ * Enables the use of dot- and bracket-notation for referencing nested
1047
+ * properties.
1048
+ * '[]' and '.' in property names can be escaped using double backslashes.
1049
+ *
1050
+ * assert.notNestedInclude({'.a': {'b': 'x'}}, {'\\.a.b': 'y'});
1051
+ * assert.notNestedInclude({'a': {'[b]': 'x'}}, {'a.\\[b\\]': 'y'});
1052
+ *
1053
+ * @name notNestedInclude
1054
+ * @param {Object } haystack
1055
+ * @param {Object } needle
1056
+ * @param {String } message
1057
+ * @namespace Assert
1058
+ * @api public
1059
+ */
1060
+
1061
+ assert . notNestedInclude = function ( exp , inc , msg ) {
1062
+ new Assertion ( exp , msg , assert . notNestedInclude , true )
1063
+ . not . nested . include ( inc ) ;
1064
+ } ;
1065
+
1066
+ /**
1067
+ * ### .deepNestedInclude(haystack, needle, [message])
1068
+ *
1069
+ * Asserts that 'haystack' includes 'needle'.
1070
+ * Can be used to assert the inclusion of a subset of properties in an
1071
+ * object while checking for deep equality.
1072
+ * Enables the use of dot- and bracket-notation for referencing nested
1073
+ * properties.
1074
+ * '[]' and '.' in property names can be escaped using double backslashes.
1075
+ *
1076
+ * assert.deepNestedInclude({a: {b: [{x: 1}]}}, {'a.b[0]': {x: 1}});
1077
+ * assert.deepNestedInclude({'.a': {'[b]': {x: 1}}}, {'\\.a.\\[b\\]': {x: 1}});
1078
+ *
1079
+ * @name deepNestedInclude
1080
+ * @param {Object } haystack
1081
+ * @param {Object } needle
1082
+ * @param {String } message
1083
+ * @namespace Assert
1084
+ * @api public
1085
+ */
1086
+
1087
+ assert . deepNestedInclude = function ( exp , inc , msg ) {
1088
+ new Assertion ( exp , msg , assert . deepNestedInclude , true )
1089
+ . deep . nested . include ( inc ) ;
1090
+ } ;
1091
+
1092
+ /**
1093
+ * ### .notDeepNestedInclude(haystack, needle, [message])
1094
+ *
1095
+ * Asserts that 'haystack' does not include 'needle'.
1096
+ * Can be used to assert the absence of a subset of properties in an
1097
+ * object while checking for deep equality.
1098
+ * Enables the use of dot- and bracket-notation for referencing nested
1099
+ * properties.
1100
+ * '[]' and '.' in property names can be escaped using double backslashes.
1101
+ *
1102
+ * assert.notDeepNestedInclude({a: {b: [{x: 1}]}}, {'a.b[0]': {y: 1}})
1103
+ * assert.notDeepNestedInclude({'.a': {'[b]': {x: 1}}}, {'\\.a.\\[b\\]': {y: 2}});
1104
+ *
1105
+ * @name notDeepNestedInclude
1106
+ * @param {Object } haystack
1107
+ * @param {Object } needle
1108
+ * @param {String } message
1109
+ * @namespace Assert
1110
+ * @api public
1111
+ */
1112
+
1113
+ assert . notDeepNestedInclude = function ( exp , inc , msg ) {
1114
+ new Assertion ( exp , msg , assert . notDeepNestedInclude , true )
1115
+ . not . deep . nested . include ( inc ) ;
1116
+ } ;
1117
+
1118
+ /**
1119
+ * ### .ownInclude(haystack, needle, [message])
1120
+ *
1121
+ * Asserts that 'haystack' includes 'needle'.
1122
+ * Can be used to assert the inclusion of a subset of properties in an
1123
+ * object while ignoring inherited properties.
1124
+ *
1125
+ * assert.ownInclude({ a: 1 }, { a: 1 });
1126
+ *
1127
+ * @name ownInclude
1128
+ * @param {Object } haystack
1129
+ * @param {Object } needle
1130
+ * @param {String } message
1131
+ * @namespace Assert
1132
+ * @api public
1133
+ */
1134
+
1135
+ assert . ownInclude = function ( exp , inc , msg ) {
1136
+ new Assertion ( exp , msg , assert . ownInclude , true ) . own . include ( inc ) ;
1137
+ } ;
1138
+
1139
+ /**
1140
+ * ### .notOwnInclude(haystack, needle, [message])
1141
+ *
1142
+ * Asserts that 'haystack' includes 'needle'.
1143
+ * Can be used to assert the absence of a subset of properties in an
1144
+ * object while ignoring inherited properties.
1145
+ *
1146
+ * Object.prototype.b = 2;
1147
+ *
1148
+ * assert.notOwnInclude({ a: 1 }, { b: 2 });
1149
+ *
1150
+ * @name notOwnInclude
1151
+ * @param {Object } haystack
1152
+ * @param {Object } needle
1153
+ * @param {String } message
1154
+ * @namespace Assert
1155
+ * @api public
1156
+ */
1157
+
1158
+ assert . notOwnInclude = function ( exp , inc , msg ) {
1159
+ new Assertion ( exp , msg , assert . notOwnInclude , true ) . not . own . include ( inc ) ;
1160
+ } ;
1161
+
1162
+ /**
1163
+ * ### .deepOwnInclude(haystack, needle, [message])
1164
+ *
1165
+ * Asserts that 'haystack' includes 'needle'.
1166
+ * Can be used to assert the inclusion of a subset of properties in an
1167
+ * object while ignoring inherited properties and checking for deep equality.
1168
+ *
1169
+ * assert.deepOwnInclude({a: {b: 2}}, {a: {b: 2}});
1170
+ *
1171
+ * @name deepOwnInclude
1172
+ * @param {Object } haystack
1173
+ * @param {Object } needle
1174
+ * @param {String } message
1175
+ * @namespace Assert
1176
+ * @api public
1177
+ */
1178
+
1179
+ assert . deepOwnInclude = function ( exp , inc , msg ) {
1180
+ new Assertion ( exp , msg , assert . deepOwnInclude , true )
1181
+ . deep . own . include ( inc ) ;
1182
+ } ;
1183
+
1184
+ /**
1185
+ * ### .notDeepOwnInclude(haystack, needle, [message])
1186
+ *
1187
+ * Asserts that 'haystack' includes 'needle'.
1188
+ * Can be used to assert the absence of a subset of properties in an
1189
+ * object while ignoring inherited properties and checking for deep equality.
1190
+ *
1191
+ * assert.notDeepOwnInclude({a: {b: 2}}, {a: {c: 3}});
1192
+ *
1193
+ * @name notDeepOwnInclude
1194
+ * @param {Object } haystack
1195
+ * @param {Object } needle
1196
+ * @param {String } message
1197
+ * @namespace Assert
1198
+ * @api public
1199
+ */
1200
+
1201
+ assert . notDeepOwnInclude = function ( exp , inc , msg ) {
1202
+ new Assertion ( exp , msg , assert . notDeepOwnInclude , true )
1203
+ . not . deep . own . include ( inc ) ;
1204
+ } ;
1205
+
1015
1206
/**
1016
1207
* ### .match(value, regexp, [message])
1017
1208
*
0 commit comments