@@ -101,12 +101,12 @@ function chaiExclude (chai, utils) {
101
101
}
102
102
103
103
/**
104
- * Override standard assertEqual method to remove the keys from other part of the equation.
104
+ * Override standard assertion logic method to remove the keys from other part of the equation.
105
105
*
106
106
* @param {Object } _super
107
107
* @returns {Function }
108
108
*/
109
- function assertEqual ( _super ) {
109
+ function removeKeysAndAssert ( _super ) {
110
110
return function ( val ) {
111
111
const props = utils . flag ( this , 'excludingProps' )
112
112
@@ -123,6 +123,18 @@ function chaiExclude (chai, utils) {
123
123
}
124
124
}
125
125
126
+ /**
127
+ * Keep standard chaining logic.
128
+ *
129
+ * @param {Object } _super
130
+ * @returns {Function }
131
+ */
132
+ function keepChainingBehavior ( _super ) {
133
+ return function ( ) {
134
+ _super . apply ( this , arguments )
135
+ }
136
+ }
137
+
126
138
/**
127
139
* Add a new method 'deepEqualExcluding' to 'chai.assert'.
128
140
*/
@@ -191,11 +203,16 @@ function chaiExclude (chai, utils) {
191
203
utils . flag ( this , 'excludingProps' , props )
192
204
} )
193
205
194
- Assertion . overwriteMethod ( 'eq' , assertEqual )
195
- Assertion . overwriteMethod ( 'eql' , assertEqual )
196
- Assertion . overwriteMethod ( 'eqls' , assertEqual )
197
- Assertion . overwriteMethod ( 'equal' , assertEqual )
198
- Assertion . overwriteMethod ( 'equals' , assertEqual )
206
+ Assertion . overwriteMethod ( 'eq' , removeKeysAndAssert )
207
+ Assertion . overwriteMethod ( 'eql' , removeKeysAndAssert )
208
+ Assertion . overwriteMethod ( 'eqls' , removeKeysAndAssert )
209
+ Assertion . overwriteMethod ( 'equal' , removeKeysAndAssert )
210
+ Assertion . overwriteMethod ( 'equals' , removeKeysAndAssert )
211
+
212
+ Assertion . addChainableMethod ( 'include' , removeKeysAndAssert , keepChainingBehavior )
213
+ Assertion . addChainableMethod ( 'contain' , removeKeysAndAssert , keepChainingBehavior )
214
+ Assertion . addChainableMethod ( 'contains' , removeKeysAndAssert , keepChainingBehavior )
215
+ Assertion . addChainableMethod ( 'includes' , removeKeysAndAssert , keepChainingBehavior )
199
216
}
200
217
201
218
module . exports = chaiExclude
0 commit comments