chai 4.3.7 → 5.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/History.md +1 -1
- package/README.md +3 -36
- package/chai.cjs +4480 -0
- package/chai.js +4284 -11303
- package/index.js +1 -1
- package/{karma.conf.js → karma.conf.cjs} +3 -3
- package/lib/chai/assertion.js +150 -163
- package/lib/chai/config.js +1 -1
- package/lib/chai/core/assertions.js +3634 -3634
- package/lib/chai/interface/assert.js +3035 -3042
- package/lib/chai/interface/expect.js +39 -37
- package/lib/chai/interface/should.js +203 -204
- package/lib/chai/utils/addChainableMethod.js +8 -8
- package/lib/chai/utils/addLengthGuard.js +3 -3
- package/lib/chai/utils/addMethod.js +8 -8
- package/lib/chai/utils/addProperty.js +7 -7
- package/lib/chai/utils/compareByInspect.js +3 -3
- package/lib/chai/utils/expectTypes.js +5 -5
- package/lib/chai/utils/flag.js +2 -2
- package/lib/chai/utils/getActual.js +2 -2
- package/lib/chai/utils/getMessage.js +5 -5
- package/lib/chai/utils/getOperator.js +4 -4
- package/lib/chai/utils/getOwnEnumerableProperties.js +3 -3
- package/lib/chai/utils/getOwnEnumerablePropertySymbols.js +2 -2
- package/lib/chai/utils/getProperties.js +2 -2
- package/lib/chai/utils/index.js +30 -34
- package/lib/chai/utils/inspect.js +4 -7
- package/lib/chai/utils/isNaN.js +2 -2
- package/lib/chai/utils/isProxyEnabled.js +3 -3
- package/lib/chai/utils/objDisplay.js +5 -4
- package/lib/chai/utils/overwriteChainableMethod.js +6 -6
- package/lib/chai/utils/overwriteMethod.js +8 -8
- package/lib/chai/utils/overwriteProperty.js +7 -7
- package/lib/chai/utils/proxify.js +7 -7
- package/lib/chai/utils/test.js +4 -4
- package/lib/chai/utils/transferFlags.js +2 -2
- package/lib/chai.js +29 -28
- package/package.json +24 -13
- package/register-assert.cjs +3 -0
- package/register-assert.js +3 -1
- package/register-expect.cjs +3 -0
- package/register-expect.js +3 -1
- package/register-should.cjs +3 -0
- package/register-should.js +3 -1
package/chai.cjs
ADDED
|
@@ -0,0 +1,4480 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
31
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
+
|
|
33
|
+
// node_modules/check-error/index.js
|
|
34
|
+
var require_check_error = __commonJS({
|
|
35
|
+
"node_modules/check-error/index.js"(exports, module2) {
|
|
36
|
+
"use strict";
|
|
37
|
+
function compatibleInstance(thrown, errorLike) {
|
|
38
|
+
return errorLike instanceof Error && thrown === errorLike;
|
|
39
|
+
}
|
|
40
|
+
__name(compatibleInstance, "compatibleInstance");
|
|
41
|
+
function compatibleConstructor(thrown, errorLike) {
|
|
42
|
+
if (errorLike instanceof Error) {
|
|
43
|
+
return thrown.constructor === errorLike.constructor || thrown instanceof errorLike.constructor;
|
|
44
|
+
} else if (errorLike.prototype instanceof Error || errorLike === Error) {
|
|
45
|
+
return thrown.constructor === errorLike || thrown instanceof errorLike;
|
|
46
|
+
}
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
__name(compatibleConstructor, "compatibleConstructor");
|
|
50
|
+
function compatibleMessage(thrown, errMatcher) {
|
|
51
|
+
var comparisonString = typeof thrown === "string" ? thrown : thrown.message;
|
|
52
|
+
if (errMatcher instanceof RegExp) {
|
|
53
|
+
return errMatcher.test(comparisonString);
|
|
54
|
+
} else if (typeof errMatcher === "string") {
|
|
55
|
+
return comparisonString.indexOf(errMatcher) !== -1;
|
|
56
|
+
}
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
__name(compatibleMessage, "compatibleMessage");
|
|
60
|
+
var functionNameMatch = /\s*function(?:\s|\s*\/\*[^(?:*\/)]+\*\/\s*)*([^\(\/]+)/;
|
|
61
|
+
function getFunctionName(constructorFn) {
|
|
62
|
+
var name = "";
|
|
63
|
+
if (typeof constructorFn.name === "undefined") {
|
|
64
|
+
var match = String(constructorFn).match(functionNameMatch);
|
|
65
|
+
if (match) {
|
|
66
|
+
name = match[1];
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
name = constructorFn.name;
|
|
70
|
+
}
|
|
71
|
+
return name;
|
|
72
|
+
}
|
|
73
|
+
__name(getFunctionName, "getFunctionName");
|
|
74
|
+
function getConstructorName(errorLike) {
|
|
75
|
+
var constructorName = errorLike;
|
|
76
|
+
if (errorLike instanceof Error) {
|
|
77
|
+
constructorName = getFunctionName(errorLike.constructor);
|
|
78
|
+
} else if (typeof errorLike === "function") {
|
|
79
|
+
constructorName = getFunctionName(errorLike).trim() || getFunctionName(new errorLike());
|
|
80
|
+
}
|
|
81
|
+
return constructorName;
|
|
82
|
+
}
|
|
83
|
+
__name(getConstructorName, "getConstructorName");
|
|
84
|
+
function getMessage2(errorLike) {
|
|
85
|
+
var msg = "";
|
|
86
|
+
if (errorLike && errorLike.message) {
|
|
87
|
+
msg = errorLike.message;
|
|
88
|
+
} else if (typeof errorLike === "string") {
|
|
89
|
+
msg = errorLike;
|
|
90
|
+
}
|
|
91
|
+
return msg;
|
|
92
|
+
}
|
|
93
|
+
__name(getMessage2, "getMessage");
|
|
94
|
+
module2.exports = {
|
|
95
|
+
compatibleInstance,
|
|
96
|
+
compatibleConstructor,
|
|
97
|
+
compatibleMessage,
|
|
98
|
+
getMessage: getMessage2,
|
|
99
|
+
getConstructorName
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// node_modules/type-detect/type-detect.js
|
|
105
|
+
var require_type_detect = __commonJS({
|
|
106
|
+
"node_modules/type-detect/type-detect.js"(exports, module2) {
|
|
107
|
+
(function(global2, factory) {
|
|
108
|
+
typeof exports === "object" && typeof module2 !== "undefined" ? module2.exports = factory() : typeof define === "function" && define.amd ? define(factory) : global2.typeDetect = factory();
|
|
109
|
+
})(exports, function() {
|
|
110
|
+
"use strict";
|
|
111
|
+
var promiseExists = typeof Promise === "function";
|
|
112
|
+
var globalObject = typeof self === "object" ? self : global;
|
|
113
|
+
var symbolExists = typeof Symbol !== "undefined";
|
|
114
|
+
var mapExists = typeof Map !== "undefined";
|
|
115
|
+
var setExists = typeof Set !== "undefined";
|
|
116
|
+
var weakMapExists = typeof WeakMap !== "undefined";
|
|
117
|
+
var weakSetExists = typeof WeakSet !== "undefined";
|
|
118
|
+
var dataViewExists = typeof DataView !== "undefined";
|
|
119
|
+
var symbolIteratorExists = symbolExists && typeof Symbol.iterator !== "undefined";
|
|
120
|
+
var symbolToStringTagExists = symbolExists && typeof Symbol.toStringTag !== "undefined";
|
|
121
|
+
var setEntriesExists = setExists && typeof Set.prototype.entries === "function";
|
|
122
|
+
var mapEntriesExists = mapExists && typeof Map.prototype.entries === "function";
|
|
123
|
+
var setIteratorPrototype = setEntriesExists && Object.getPrototypeOf((/* @__PURE__ */ new Set()).entries());
|
|
124
|
+
var mapIteratorPrototype = mapEntriesExists && Object.getPrototypeOf((/* @__PURE__ */ new Map()).entries());
|
|
125
|
+
var arrayIteratorExists = symbolIteratorExists && typeof Array.prototype[Symbol.iterator] === "function";
|
|
126
|
+
var arrayIteratorPrototype = arrayIteratorExists && Object.getPrototypeOf([][Symbol.iterator]());
|
|
127
|
+
var stringIteratorExists = symbolIteratorExists && typeof String.prototype[Symbol.iterator] === "function";
|
|
128
|
+
var stringIteratorPrototype = stringIteratorExists && Object.getPrototypeOf(""[Symbol.iterator]());
|
|
129
|
+
var toStringLeftSliceLength = 8;
|
|
130
|
+
var toStringRightSliceLength = -1;
|
|
131
|
+
function typeDetect(obj) {
|
|
132
|
+
var typeofObj = typeof obj;
|
|
133
|
+
if (typeofObj !== "object") {
|
|
134
|
+
return typeofObj;
|
|
135
|
+
}
|
|
136
|
+
if (obj === null) {
|
|
137
|
+
return "null";
|
|
138
|
+
}
|
|
139
|
+
if (obj === globalObject) {
|
|
140
|
+
return "global";
|
|
141
|
+
}
|
|
142
|
+
if (Array.isArray(obj) && (symbolToStringTagExists === false || !(Symbol.toStringTag in obj))) {
|
|
143
|
+
return "Array";
|
|
144
|
+
}
|
|
145
|
+
if (typeof window === "object" && window !== null) {
|
|
146
|
+
if (typeof window.location === "object" && obj === window.location) {
|
|
147
|
+
return "Location";
|
|
148
|
+
}
|
|
149
|
+
if (typeof window.document === "object" && obj === window.document) {
|
|
150
|
+
return "Document";
|
|
151
|
+
}
|
|
152
|
+
if (typeof window.navigator === "object") {
|
|
153
|
+
if (typeof window.navigator.mimeTypes === "object" && obj === window.navigator.mimeTypes) {
|
|
154
|
+
return "MimeTypeArray";
|
|
155
|
+
}
|
|
156
|
+
if (typeof window.navigator.plugins === "object" && obj === window.navigator.plugins) {
|
|
157
|
+
return "PluginArray";
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
if ((typeof window.HTMLElement === "function" || typeof window.HTMLElement === "object") && obj instanceof window.HTMLElement) {
|
|
161
|
+
if (obj.tagName === "BLOCKQUOTE") {
|
|
162
|
+
return "HTMLQuoteElement";
|
|
163
|
+
}
|
|
164
|
+
if (obj.tagName === "TD") {
|
|
165
|
+
return "HTMLTableDataCellElement";
|
|
166
|
+
}
|
|
167
|
+
if (obj.tagName === "TH") {
|
|
168
|
+
return "HTMLTableHeaderCellElement";
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
var stringTag = symbolToStringTagExists && obj[Symbol.toStringTag];
|
|
173
|
+
if (typeof stringTag === "string") {
|
|
174
|
+
return stringTag;
|
|
175
|
+
}
|
|
176
|
+
var objPrototype = Object.getPrototypeOf(obj);
|
|
177
|
+
if (objPrototype === RegExp.prototype) {
|
|
178
|
+
return "RegExp";
|
|
179
|
+
}
|
|
180
|
+
if (objPrototype === Date.prototype) {
|
|
181
|
+
return "Date";
|
|
182
|
+
}
|
|
183
|
+
if (promiseExists && objPrototype === Promise.prototype) {
|
|
184
|
+
return "Promise";
|
|
185
|
+
}
|
|
186
|
+
if (setExists && objPrototype === Set.prototype) {
|
|
187
|
+
return "Set";
|
|
188
|
+
}
|
|
189
|
+
if (mapExists && objPrototype === Map.prototype) {
|
|
190
|
+
return "Map";
|
|
191
|
+
}
|
|
192
|
+
if (weakSetExists && objPrototype === WeakSet.prototype) {
|
|
193
|
+
return "WeakSet";
|
|
194
|
+
}
|
|
195
|
+
if (weakMapExists && objPrototype === WeakMap.prototype) {
|
|
196
|
+
return "WeakMap";
|
|
197
|
+
}
|
|
198
|
+
if (dataViewExists && objPrototype === DataView.prototype) {
|
|
199
|
+
return "DataView";
|
|
200
|
+
}
|
|
201
|
+
if (mapExists && objPrototype === mapIteratorPrototype) {
|
|
202
|
+
return "Map Iterator";
|
|
203
|
+
}
|
|
204
|
+
if (setExists && objPrototype === setIteratorPrototype) {
|
|
205
|
+
return "Set Iterator";
|
|
206
|
+
}
|
|
207
|
+
if (arrayIteratorExists && objPrototype === arrayIteratorPrototype) {
|
|
208
|
+
return "Array Iterator";
|
|
209
|
+
}
|
|
210
|
+
if (stringIteratorExists && objPrototype === stringIteratorPrototype) {
|
|
211
|
+
return "String Iterator";
|
|
212
|
+
}
|
|
213
|
+
if (objPrototype === null) {
|
|
214
|
+
return "Object";
|
|
215
|
+
}
|
|
216
|
+
return Object.prototype.toString.call(obj).slice(toStringLeftSliceLength, toStringRightSliceLength);
|
|
217
|
+
}
|
|
218
|
+
__name(typeDetect, "typeDetect");
|
|
219
|
+
return typeDetect;
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
// node_modules/assertion-error/index.js
|
|
225
|
+
var require_assertion_error = __commonJS({
|
|
226
|
+
"node_modules/assertion-error/index.js"(exports, module2) {
|
|
227
|
+
function exclude() {
|
|
228
|
+
var excludes = [].slice.call(arguments);
|
|
229
|
+
function excludeProps(res, obj) {
|
|
230
|
+
Object.keys(obj).forEach(function(key) {
|
|
231
|
+
if (!~excludes.indexOf(key))
|
|
232
|
+
res[key] = obj[key];
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
__name(excludeProps, "excludeProps");
|
|
236
|
+
return /* @__PURE__ */ __name(function extendExclude() {
|
|
237
|
+
var args = [].slice.call(arguments), i = 0, res = {};
|
|
238
|
+
for (; i < args.length; i++) {
|
|
239
|
+
excludeProps(res, args[i]);
|
|
240
|
+
}
|
|
241
|
+
return res;
|
|
242
|
+
}, "extendExclude");
|
|
243
|
+
}
|
|
244
|
+
__name(exclude, "exclude");
|
|
245
|
+
module2.exports = AssertionError8;
|
|
246
|
+
function AssertionError8(message, _props, ssf) {
|
|
247
|
+
var extend = exclude("name", "message", "stack", "constructor", "toJSON"), props = extend(_props || {});
|
|
248
|
+
this.message = message || "Unspecified AssertionError";
|
|
249
|
+
this.showDiff = false;
|
|
250
|
+
for (var key in props) {
|
|
251
|
+
this[key] = props[key];
|
|
252
|
+
}
|
|
253
|
+
ssf = ssf || AssertionError8;
|
|
254
|
+
if (Error.captureStackTrace) {
|
|
255
|
+
Error.captureStackTrace(this, ssf);
|
|
256
|
+
} else {
|
|
257
|
+
try {
|
|
258
|
+
throw new Error();
|
|
259
|
+
} catch (e) {
|
|
260
|
+
this.stack = e.stack;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
__name(AssertionError8, "AssertionError");
|
|
265
|
+
AssertionError8.prototype = Object.create(Error.prototype);
|
|
266
|
+
AssertionError8.prototype.name = "AssertionError";
|
|
267
|
+
AssertionError8.prototype.constructor = AssertionError8;
|
|
268
|
+
AssertionError8.prototype.toJSON = function(stack) {
|
|
269
|
+
var extend = exclude("constructor", "toJSON", "stack"), props = extend({ name: this.name }, this);
|
|
270
|
+
if (false !== stack && this.stack) {
|
|
271
|
+
props.stack = this.stack;
|
|
272
|
+
}
|
|
273
|
+
return props;
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
// (disabled):util
|
|
279
|
+
var require_util = __commonJS({
|
|
280
|
+
"(disabled):util"() {
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
// node_modules/loupe/loupe.js
|
|
285
|
+
var require_loupe = __commonJS({
|
|
286
|
+
"node_modules/loupe/loupe.js"(exports, module2) {
|
|
287
|
+
(function(global2, factory) {
|
|
288
|
+
typeof exports === "object" && typeof module2 !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, factory(global2.loupe = {}));
|
|
289
|
+
})(exports, function(exports2) {
|
|
290
|
+
"use strict";
|
|
291
|
+
function _typeof(obj) {
|
|
292
|
+
"@babel/helpers - typeof";
|
|
293
|
+
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
|
294
|
+
_typeof = /* @__PURE__ */ __name(function(obj2) {
|
|
295
|
+
return typeof obj2;
|
|
296
|
+
}, "_typeof");
|
|
297
|
+
} else {
|
|
298
|
+
_typeof = /* @__PURE__ */ __name(function(obj2) {
|
|
299
|
+
return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
|
300
|
+
}, "_typeof");
|
|
301
|
+
}
|
|
302
|
+
return _typeof(obj);
|
|
303
|
+
}
|
|
304
|
+
__name(_typeof, "_typeof");
|
|
305
|
+
function _slicedToArray(arr, i) {
|
|
306
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
307
|
+
}
|
|
308
|
+
__name(_slicedToArray, "_slicedToArray");
|
|
309
|
+
function _arrayWithHoles(arr) {
|
|
310
|
+
if (Array.isArray(arr))
|
|
311
|
+
return arr;
|
|
312
|
+
}
|
|
313
|
+
__name(_arrayWithHoles, "_arrayWithHoles");
|
|
314
|
+
function _iterableToArrayLimit(arr, i) {
|
|
315
|
+
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr)))
|
|
316
|
+
return;
|
|
317
|
+
var _arr = [];
|
|
318
|
+
var _n = true;
|
|
319
|
+
var _d = false;
|
|
320
|
+
var _e = void 0;
|
|
321
|
+
try {
|
|
322
|
+
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
|
323
|
+
_arr.push(_s.value);
|
|
324
|
+
if (i && _arr.length === i)
|
|
325
|
+
break;
|
|
326
|
+
}
|
|
327
|
+
} catch (err) {
|
|
328
|
+
_d = true;
|
|
329
|
+
_e = err;
|
|
330
|
+
} finally {
|
|
331
|
+
try {
|
|
332
|
+
if (!_n && _i["return"] != null)
|
|
333
|
+
_i["return"]();
|
|
334
|
+
} finally {
|
|
335
|
+
if (_d)
|
|
336
|
+
throw _e;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
return _arr;
|
|
340
|
+
}
|
|
341
|
+
__name(_iterableToArrayLimit, "_iterableToArrayLimit");
|
|
342
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
343
|
+
if (!o)
|
|
344
|
+
return;
|
|
345
|
+
if (typeof o === "string")
|
|
346
|
+
return _arrayLikeToArray(o, minLen);
|
|
347
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
348
|
+
if (n === "Object" && o.constructor)
|
|
349
|
+
n = o.constructor.name;
|
|
350
|
+
if (n === "Map" || n === "Set")
|
|
351
|
+
return Array.from(o);
|
|
352
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
|
|
353
|
+
return _arrayLikeToArray(o, minLen);
|
|
354
|
+
}
|
|
355
|
+
__name(_unsupportedIterableToArray, "_unsupportedIterableToArray");
|
|
356
|
+
function _arrayLikeToArray(arr, len) {
|
|
357
|
+
if (len == null || len > arr.length)
|
|
358
|
+
len = arr.length;
|
|
359
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
360
|
+
arr2[i] = arr[i];
|
|
361
|
+
return arr2;
|
|
362
|
+
}
|
|
363
|
+
__name(_arrayLikeToArray, "_arrayLikeToArray");
|
|
364
|
+
function _nonIterableRest() {
|
|
365
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
366
|
+
}
|
|
367
|
+
__name(_nonIterableRest, "_nonIterableRest");
|
|
368
|
+
var ansiColors = {
|
|
369
|
+
bold: ["1", "22"],
|
|
370
|
+
dim: ["2", "22"],
|
|
371
|
+
italic: ["3", "23"],
|
|
372
|
+
underline: ["4", "24"],
|
|
373
|
+
// 5 & 6 are blinking
|
|
374
|
+
inverse: ["7", "27"],
|
|
375
|
+
hidden: ["8", "28"],
|
|
376
|
+
strike: ["9", "29"],
|
|
377
|
+
// 10-20 are fonts
|
|
378
|
+
// 21-29 are resets for 1-9
|
|
379
|
+
black: ["30", "39"],
|
|
380
|
+
red: ["31", "39"],
|
|
381
|
+
green: ["32", "39"],
|
|
382
|
+
yellow: ["33", "39"],
|
|
383
|
+
blue: ["34", "39"],
|
|
384
|
+
magenta: ["35", "39"],
|
|
385
|
+
cyan: ["36", "39"],
|
|
386
|
+
white: ["37", "39"],
|
|
387
|
+
brightblack: ["30;1", "39"],
|
|
388
|
+
brightred: ["31;1", "39"],
|
|
389
|
+
brightgreen: ["32;1", "39"],
|
|
390
|
+
brightyellow: ["33;1", "39"],
|
|
391
|
+
brightblue: ["34;1", "39"],
|
|
392
|
+
brightmagenta: ["35;1", "39"],
|
|
393
|
+
brightcyan: ["36;1", "39"],
|
|
394
|
+
brightwhite: ["37;1", "39"],
|
|
395
|
+
grey: ["90", "39"]
|
|
396
|
+
};
|
|
397
|
+
var styles = {
|
|
398
|
+
special: "cyan",
|
|
399
|
+
number: "yellow",
|
|
400
|
+
bigint: "yellow",
|
|
401
|
+
boolean: "yellow",
|
|
402
|
+
undefined: "grey",
|
|
403
|
+
null: "bold",
|
|
404
|
+
string: "green",
|
|
405
|
+
symbol: "green",
|
|
406
|
+
date: "magenta",
|
|
407
|
+
regexp: "red"
|
|
408
|
+
};
|
|
409
|
+
var truncator = "\u2026";
|
|
410
|
+
function colorise(value, styleType) {
|
|
411
|
+
var color = ansiColors[styles[styleType]] || ansiColors[styleType];
|
|
412
|
+
if (!color) {
|
|
413
|
+
return String(value);
|
|
414
|
+
}
|
|
415
|
+
return "\x1B[".concat(color[0], "m").concat(String(value), "\x1B[").concat(color[1], "m");
|
|
416
|
+
}
|
|
417
|
+
__name(colorise, "colorise");
|
|
418
|
+
function normaliseOptions() {
|
|
419
|
+
var _ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, _ref$showHidden = _ref.showHidden, showHidden = _ref$showHidden === void 0 ? false : _ref$showHidden, _ref$depth = _ref.depth, depth = _ref$depth === void 0 ? 2 : _ref$depth, _ref$colors = _ref.colors, colors = _ref$colors === void 0 ? false : _ref$colors, _ref$customInspect = _ref.customInspect, customInspect = _ref$customInspect === void 0 ? true : _ref$customInspect, _ref$showProxy = _ref.showProxy, showProxy = _ref$showProxy === void 0 ? false : _ref$showProxy, _ref$maxArrayLength = _ref.maxArrayLength, maxArrayLength = _ref$maxArrayLength === void 0 ? Infinity : _ref$maxArrayLength, _ref$breakLength = _ref.breakLength, breakLength = _ref$breakLength === void 0 ? Infinity : _ref$breakLength, _ref$seen = _ref.seen, seen = _ref$seen === void 0 ? [] : _ref$seen, _ref$truncate = _ref.truncate, truncate2 = _ref$truncate === void 0 ? Infinity : _ref$truncate, _ref$stylize = _ref.stylize, stylize = _ref$stylize === void 0 ? String : _ref$stylize;
|
|
420
|
+
var options = {
|
|
421
|
+
showHidden: Boolean(showHidden),
|
|
422
|
+
depth: Number(depth),
|
|
423
|
+
colors: Boolean(colors),
|
|
424
|
+
customInspect: Boolean(customInspect),
|
|
425
|
+
showProxy: Boolean(showProxy),
|
|
426
|
+
maxArrayLength: Number(maxArrayLength),
|
|
427
|
+
breakLength: Number(breakLength),
|
|
428
|
+
truncate: Number(truncate2),
|
|
429
|
+
seen,
|
|
430
|
+
stylize
|
|
431
|
+
};
|
|
432
|
+
if (options.colors) {
|
|
433
|
+
options.stylize = colorise;
|
|
434
|
+
}
|
|
435
|
+
return options;
|
|
436
|
+
}
|
|
437
|
+
__name(normaliseOptions, "normaliseOptions");
|
|
438
|
+
function truncate(string, length) {
|
|
439
|
+
var tail = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : truncator;
|
|
440
|
+
string = String(string);
|
|
441
|
+
var tailLength = tail.length;
|
|
442
|
+
var stringLength = string.length;
|
|
443
|
+
if (tailLength > length && stringLength > tailLength) {
|
|
444
|
+
return tail;
|
|
445
|
+
}
|
|
446
|
+
if (stringLength > length && stringLength > tailLength) {
|
|
447
|
+
return "".concat(string.slice(0, length - tailLength)).concat(tail);
|
|
448
|
+
}
|
|
449
|
+
return string;
|
|
450
|
+
}
|
|
451
|
+
__name(truncate, "truncate");
|
|
452
|
+
function inspectList(list, options, inspectItem) {
|
|
453
|
+
var separator = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : ", ";
|
|
454
|
+
inspectItem = inspectItem || options.inspect;
|
|
455
|
+
var size = list.length;
|
|
456
|
+
if (size === 0)
|
|
457
|
+
return "";
|
|
458
|
+
var originalLength = options.truncate;
|
|
459
|
+
var output = "";
|
|
460
|
+
var peek = "";
|
|
461
|
+
var truncated = "";
|
|
462
|
+
for (var i = 0; i < size; i += 1) {
|
|
463
|
+
var last = i + 1 === list.length;
|
|
464
|
+
var secondToLast = i + 2 === list.length;
|
|
465
|
+
truncated = "".concat(truncator, "(").concat(list.length - i, ")");
|
|
466
|
+
var value = list[i];
|
|
467
|
+
options.truncate = originalLength - output.length - (last ? 0 : separator.length);
|
|
468
|
+
var string = peek || inspectItem(value, options) + (last ? "" : separator);
|
|
469
|
+
var nextLength = output.length + string.length;
|
|
470
|
+
var truncatedLength = nextLength + truncated.length;
|
|
471
|
+
if (last && nextLength > originalLength && output.length + truncated.length <= originalLength) {
|
|
472
|
+
break;
|
|
473
|
+
}
|
|
474
|
+
if (!last && !secondToLast && truncatedLength > originalLength) {
|
|
475
|
+
break;
|
|
476
|
+
}
|
|
477
|
+
peek = last ? "" : inspectItem(list[i + 1], options) + (secondToLast ? "" : separator);
|
|
478
|
+
if (!last && secondToLast && truncatedLength > originalLength && nextLength + peek.length > originalLength) {
|
|
479
|
+
break;
|
|
480
|
+
}
|
|
481
|
+
output += string;
|
|
482
|
+
if (!last && !secondToLast && nextLength + peek.length >= originalLength) {
|
|
483
|
+
truncated = "".concat(truncator, "(").concat(list.length - i - 1, ")");
|
|
484
|
+
break;
|
|
485
|
+
}
|
|
486
|
+
truncated = "";
|
|
487
|
+
}
|
|
488
|
+
return "".concat(output).concat(truncated);
|
|
489
|
+
}
|
|
490
|
+
__name(inspectList, "inspectList");
|
|
491
|
+
function quoteComplexKey(key) {
|
|
492
|
+
if (key.match(/^[a-zA-Z_][a-zA-Z_0-9]*$/)) {
|
|
493
|
+
return key;
|
|
494
|
+
}
|
|
495
|
+
return JSON.stringify(key).replace(/'/g, "\\'").replace(/\\"/g, '"').replace(/(^"|"$)/g, "'");
|
|
496
|
+
}
|
|
497
|
+
__name(quoteComplexKey, "quoteComplexKey");
|
|
498
|
+
function inspectProperty(_ref2, options) {
|
|
499
|
+
var _ref3 = _slicedToArray(_ref2, 2), key = _ref3[0], value = _ref3[1];
|
|
500
|
+
options.truncate -= 2;
|
|
501
|
+
if (typeof key === "string") {
|
|
502
|
+
key = quoteComplexKey(key);
|
|
503
|
+
} else if (typeof key !== "number") {
|
|
504
|
+
key = "[".concat(options.inspect(key, options), "]");
|
|
505
|
+
}
|
|
506
|
+
options.truncate -= key.length;
|
|
507
|
+
value = options.inspect(value, options);
|
|
508
|
+
return "".concat(key, ": ").concat(value);
|
|
509
|
+
}
|
|
510
|
+
__name(inspectProperty, "inspectProperty");
|
|
511
|
+
function inspectArray(array, options) {
|
|
512
|
+
var nonIndexProperties = Object.keys(array).slice(array.length);
|
|
513
|
+
if (!array.length && !nonIndexProperties.length)
|
|
514
|
+
return "[]";
|
|
515
|
+
options.truncate -= 4;
|
|
516
|
+
var listContents = inspectList(array, options);
|
|
517
|
+
options.truncate -= listContents.length;
|
|
518
|
+
var propertyContents = "";
|
|
519
|
+
if (nonIndexProperties.length) {
|
|
520
|
+
propertyContents = inspectList(nonIndexProperties.map(function(key) {
|
|
521
|
+
return [key, array[key]];
|
|
522
|
+
}), options, inspectProperty);
|
|
523
|
+
}
|
|
524
|
+
return "[ ".concat(listContents).concat(propertyContents ? ", ".concat(propertyContents) : "", " ]");
|
|
525
|
+
}
|
|
526
|
+
__name(inspectArray, "inspectArray");
|
|
527
|
+
var toString = Function.prototype.toString;
|
|
528
|
+
var functionNameMatch = /\s*function(?:\s|\s*\/\*[^(?:*\/)]+\*\/\s*)*([^\s\(\/]+)/;
|
|
529
|
+
function getFuncName(aFunc) {
|
|
530
|
+
if (typeof aFunc !== "function") {
|
|
531
|
+
return null;
|
|
532
|
+
}
|
|
533
|
+
var name = "";
|
|
534
|
+
if (typeof Function.prototype.name === "undefined" && typeof aFunc.name === "undefined") {
|
|
535
|
+
var match = toString.call(aFunc).match(functionNameMatch);
|
|
536
|
+
if (match) {
|
|
537
|
+
name = match[1];
|
|
538
|
+
}
|
|
539
|
+
} else {
|
|
540
|
+
name = aFunc.name;
|
|
541
|
+
}
|
|
542
|
+
return name;
|
|
543
|
+
}
|
|
544
|
+
__name(getFuncName, "getFuncName");
|
|
545
|
+
var getFuncName_1 = getFuncName;
|
|
546
|
+
var getArrayName = /* @__PURE__ */ __name(function getArrayName2(array) {
|
|
547
|
+
if (typeof Buffer === "function" && array instanceof Buffer) {
|
|
548
|
+
return "Buffer";
|
|
549
|
+
}
|
|
550
|
+
if (array[Symbol.toStringTag]) {
|
|
551
|
+
return array[Symbol.toStringTag];
|
|
552
|
+
}
|
|
553
|
+
return getFuncName_1(array.constructor);
|
|
554
|
+
}, "getArrayName");
|
|
555
|
+
function inspectTypedArray(array, options) {
|
|
556
|
+
var name = getArrayName(array);
|
|
557
|
+
options.truncate -= name.length + 4;
|
|
558
|
+
var nonIndexProperties = Object.keys(array).slice(array.length);
|
|
559
|
+
if (!array.length && !nonIndexProperties.length)
|
|
560
|
+
return "".concat(name, "[]");
|
|
561
|
+
var output = "";
|
|
562
|
+
for (var i = 0; i < array.length; i++) {
|
|
563
|
+
var string = "".concat(options.stylize(truncate(array[i], options.truncate), "number")).concat(i === array.length - 1 ? "" : ", ");
|
|
564
|
+
options.truncate -= string.length;
|
|
565
|
+
if (array[i] !== array.length && options.truncate <= 3) {
|
|
566
|
+
output += "".concat(truncator, "(").concat(array.length - array[i] + 1, ")");
|
|
567
|
+
break;
|
|
568
|
+
}
|
|
569
|
+
output += string;
|
|
570
|
+
}
|
|
571
|
+
var propertyContents = "";
|
|
572
|
+
if (nonIndexProperties.length) {
|
|
573
|
+
propertyContents = inspectList(nonIndexProperties.map(function(key) {
|
|
574
|
+
return [key, array[key]];
|
|
575
|
+
}), options, inspectProperty);
|
|
576
|
+
}
|
|
577
|
+
return "".concat(name, "[ ").concat(output).concat(propertyContents ? ", ".concat(propertyContents) : "", " ]");
|
|
578
|
+
}
|
|
579
|
+
__name(inspectTypedArray, "inspectTypedArray");
|
|
580
|
+
function inspectDate(dateObject, options) {
|
|
581
|
+
var stringRepresentation = dateObject.toJSON();
|
|
582
|
+
if (stringRepresentation === null) {
|
|
583
|
+
return "Invalid Date";
|
|
584
|
+
}
|
|
585
|
+
var split = stringRepresentation.split("T");
|
|
586
|
+
var date = split[0];
|
|
587
|
+
return options.stylize("".concat(date, "T").concat(truncate(split[1], options.truncate - date.length - 1)), "date");
|
|
588
|
+
}
|
|
589
|
+
__name(inspectDate, "inspectDate");
|
|
590
|
+
function inspectFunction(func, options) {
|
|
591
|
+
var name = getFuncName_1(func);
|
|
592
|
+
if (!name) {
|
|
593
|
+
return options.stylize("[Function]", "special");
|
|
594
|
+
}
|
|
595
|
+
return options.stylize("[Function ".concat(truncate(name, options.truncate - 11), "]"), "special");
|
|
596
|
+
}
|
|
597
|
+
__name(inspectFunction, "inspectFunction");
|
|
598
|
+
function inspectMapEntry(_ref, options) {
|
|
599
|
+
var _ref2 = _slicedToArray(_ref, 2), key = _ref2[0], value = _ref2[1];
|
|
600
|
+
options.truncate -= 4;
|
|
601
|
+
key = options.inspect(key, options);
|
|
602
|
+
options.truncate -= key.length;
|
|
603
|
+
value = options.inspect(value, options);
|
|
604
|
+
return "".concat(key, " => ").concat(value);
|
|
605
|
+
}
|
|
606
|
+
__name(inspectMapEntry, "inspectMapEntry");
|
|
607
|
+
function mapToEntries(map) {
|
|
608
|
+
var entries = [];
|
|
609
|
+
map.forEach(function(value, key) {
|
|
610
|
+
entries.push([key, value]);
|
|
611
|
+
});
|
|
612
|
+
return entries;
|
|
613
|
+
}
|
|
614
|
+
__name(mapToEntries, "mapToEntries");
|
|
615
|
+
function inspectMap(map, options) {
|
|
616
|
+
var size = map.size - 1;
|
|
617
|
+
if (size <= 0) {
|
|
618
|
+
return "Map{}";
|
|
619
|
+
}
|
|
620
|
+
options.truncate -= 7;
|
|
621
|
+
return "Map{ ".concat(inspectList(mapToEntries(map), options, inspectMapEntry), " }");
|
|
622
|
+
}
|
|
623
|
+
__name(inspectMap, "inspectMap");
|
|
624
|
+
var isNaN2 = Number.isNaN || function(i) {
|
|
625
|
+
return i !== i;
|
|
626
|
+
};
|
|
627
|
+
function inspectNumber(number, options) {
|
|
628
|
+
if (isNaN2(number)) {
|
|
629
|
+
return options.stylize("NaN", "number");
|
|
630
|
+
}
|
|
631
|
+
if (number === Infinity) {
|
|
632
|
+
return options.stylize("Infinity", "number");
|
|
633
|
+
}
|
|
634
|
+
if (number === -Infinity) {
|
|
635
|
+
return options.stylize("-Infinity", "number");
|
|
636
|
+
}
|
|
637
|
+
if (number === 0) {
|
|
638
|
+
return options.stylize(1 / number === Infinity ? "+0" : "-0", "number");
|
|
639
|
+
}
|
|
640
|
+
return options.stylize(truncate(number, options.truncate), "number");
|
|
641
|
+
}
|
|
642
|
+
__name(inspectNumber, "inspectNumber");
|
|
643
|
+
function inspectBigInt(number, options) {
|
|
644
|
+
var nums = truncate(number.toString(), options.truncate - 1);
|
|
645
|
+
if (nums !== truncator)
|
|
646
|
+
nums += "n";
|
|
647
|
+
return options.stylize(nums, "bigint");
|
|
648
|
+
}
|
|
649
|
+
__name(inspectBigInt, "inspectBigInt");
|
|
650
|
+
function inspectRegExp(value, options) {
|
|
651
|
+
var flags = value.toString().split("/")[2];
|
|
652
|
+
var sourceLength = options.truncate - (2 + flags.length);
|
|
653
|
+
var source = value.source;
|
|
654
|
+
return options.stylize("/".concat(truncate(source, sourceLength), "/").concat(flags), "regexp");
|
|
655
|
+
}
|
|
656
|
+
__name(inspectRegExp, "inspectRegExp");
|
|
657
|
+
function arrayFromSet(set) {
|
|
658
|
+
var values = [];
|
|
659
|
+
set.forEach(function(value) {
|
|
660
|
+
values.push(value);
|
|
661
|
+
});
|
|
662
|
+
return values;
|
|
663
|
+
}
|
|
664
|
+
__name(arrayFromSet, "arrayFromSet");
|
|
665
|
+
function inspectSet(set, options) {
|
|
666
|
+
if (set.size === 0)
|
|
667
|
+
return "Set{}";
|
|
668
|
+
options.truncate -= 7;
|
|
669
|
+
return "Set{ ".concat(inspectList(arrayFromSet(set), options), " }");
|
|
670
|
+
}
|
|
671
|
+
__name(inspectSet, "inspectSet");
|
|
672
|
+
var stringEscapeChars = new RegExp("['\\u0000-\\u001f\\u007f-\\u009f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]", "g");
|
|
673
|
+
var escapeCharacters = {
|
|
674
|
+
"\b": "\\b",
|
|
675
|
+
" ": "\\t",
|
|
676
|
+
"\n": "\\n",
|
|
677
|
+
"\f": "\\f",
|
|
678
|
+
"\r": "\\r",
|
|
679
|
+
"'": "\\'",
|
|
680
|
+
"\\": "\\\\"
|
|
681
|
+
};
|
|
682
|
+
var hex = 16;
|
|
683
|
+
var unicodeLength = 4;
|
|
684
|
+
function escape(char) {
|
|
685
|
+
return escapeCharacters[char] || "\\u".concat("0000".concat(char.charCodeAt(0).toString(hex)).slice(-unicodeLength));
|
|
686
|
+
}
|
|
687
|
+
__name(escape, "escape");
|
|
688
|
+
function inspectString(string, options) {
|
|
689
|
+
if (stringEscapeChars.test(string)) {
|
|
690
|
+
string = string.replace(stringEscapeChars, escape);
|
|
691
|
+
}
|
|
692
|
+
return options.stylize("'".concat(truncate(string, options.truncate - 2), "'"), "string");
|
|
693
|
+
}
|
|
694
|
+
__name(inspectString, "inspectString");
|
|
695
|
+
function inspectSymbol(value) {
|
|
696
|
+
if ("description" in Symbol.prototype) {
|
|
697
|
+
return value.description ? "Symbol(".concat(value.description, ")") : "Symbol()";
|
|
698
|
+
}
|
|
699
|
+
return value.toString();
|
|
700
|
+
}
|
|
701
|
+
__name(inspectSymbol, "inspectSymbol");
|
|
702
|
+
var getPromiseValue = /* @__PURE__ */ __name(function getPromiseValue2() {
|
|
703
|
+
return "Promise{\u2026}";
|
|
704
|
+
}, "getPromiseValue");
|
|
705
|
+
try {
|
|
706
|
+
var _process$binding = process.binding("util"), getPromiseDetails = _process$binding.getPromiseDetails, kPending = _process$binding.kPending, kRejected = _process$binding.kRejected;
|
|
707
|
+
if (Array.isArray(getPromiseDetails(Promise.resolve()))) {
|
|
708
|
+
getPromiseValue = /* @__PURE__ */ __name(function getPromiseValue2(value, options) {
|
|
709
|
+
var _getPromiseDetails = getPromiseDetails(value), _getPromiseDetails2 = _slicedToArray(_getPromiseDetails, 2), state = _getPromiseDetails2[0], innerValue = _getPromiseDetails2[1];
|
|
710
|
+
if (state === kPending) {
|
|
711
|
+
return "Promise{<pending>}";
|
|
712
|
+
}
|
|
713
|
+
return "Promise".concat(state === kRejected ? "!" : "", "{").concat(options.inspect(innerValue, options), "}");
|
|
714
|
+
}, "getPromiseValue");
|
|
715
|
+
}
|
|
716
|
+
} catch (notNode) {
|
|
717
|
+
}
|
|
718
|
+
var inspectPromise = getPromiseValue;
|
|
719
|
+
function inspectObject(object, options) {
|
|
720
|
+
var properties = Object.getOwnPropertyNames(object);
|
|
721
|
+
var symbols = Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(object) : [];
|
|
722
|
+
if (properties.length === 0 && symbols.length === 0) {
|
|
723
|
+
return "{}";
|
|
724
|
+
}
|
|
725
|
+
options.truncate -= 4;
|
|
726
|
+
options.seen = options.seen || [];
|
|
727
|
+
if (options.seen.indexOf(object) >= 0) {
|
|
728
|
+
return "[Circular]";
|
|
729
|
+
}
|
|
730
|
+
options.seen.push(object);
|
|
731
|
+
var propertyContents = inspectList(properties.map(function(key) {
|
|
732
|
+
return [key, object[key]];
|
|
733
|
+
}), options, inspectProperty);
|
|
734
|
+
var symbolContents = inspectList(symbols.map(function(key) {
|
|
735
|
+
return [key, object[key]];
|
|
736
|
+
}), options, inspectProperty);
|
|
737
|
+
options.seen.pop();
|
|
738
|
+
var sep = "";
|
|
739
|
+
if (propertyContents && symbolContents) {
|
|
740
|
+
sep = ", ";
|
|
741
|
+
}
|
|
742
|
+
return "{ ".concat(propertyContents).concat(sep).concat(symbolContents, " }");
|
|
743
|
+
}
|
|
744
|
+
__name(inspectObject, "inspectObject");
|
|
745
|
+
var toStringTag = typeof Symbol !== "undefined" && Symbol.toStringTag ? Symbol.toStringTag : false;
|
|
746
|
+
function inspectClass(value, options) {
|
|
747
|
+
var name = "";
|
|
748
|
+
if (toStringTag && toStringTag in value) {
|
|
749
|
+
name = value[toStringTag];
|
|
750
|
+
}
|
|
751
|
+
name = name || getFuncName_1(value.constructor);
|
|
752
|
+
if (!name || name === "_class") {
|
|
753
|
+
name = "<Anonymous Class>";
|
|
754
|
+
}
|
|
755
|
+
options.truncate -= name.length;
|
|
756
|
+
return "".concat(name).concat(inspectObject(value, options));
|
|
757
|
+
}
|
|
758
|
+
__name(inspectClass, "inspectClass");
|
|
759
|
+
function inspectArguments(args, options) {
|
|
760
|
+
if (args.length === 0)
|
|
761
|
+
return "Arguments[]";
|
|
762
|
+
options.truncate -= 13;
|
|
763
|
+
return "Arguments[ ".concat(inspectList(args, options), " ]");
|
|
764
|
+
}
|
|
765
|
+
__name(inspectArguments, "inspectArguments");
|
|
766
|
+
var errorKeys = ["stack", "line", "column", "name", "message", "fileName", "lineNumber", "columnNumber", "number", "description"];
|
|
767
|
+
function inspectObject$1(error, options) {
|
|
768
|
+
var properties = Object.getOwnPropertyNames(error).filter(function(key) {
|
|
769
|
+
return errorKeys.indexOf(key) === -1;
|
|
770
|
+
});
|
|
771
|
+
var name = error.name;
|
|
772
|
+
options.truncate -= name.length;
|
|
773
|
+
var message = "";
|
|
774
|
+
if (typeof error.message === "string") {
|
|
775
|
+
message = truncate(error.message, options.truncate);
|
|
776
|
+
} else {
|
|
777
|
+
properties.unshift("message");
|
|
778
|
+
}
|
|
779
|
+
message = message ? ": ".concat(message) : "";
|
|
780
|
+
options.truncate -= message.length + 5;
|
|
781
|
+
var propertyContents = inspectList(properties.map(function(key) {
|
|
782
|
+
return [key, error[key]];
|
|
783
|
+
}), options, inspectProperty);
|
|
784
|
+
return "".concat(name).concat(message).concat(propertyContents ? " { ".concat(propertyContents, " }") : "");
|
|
785
|
+
}
|
|
786
|
+
__name(inspectObject$1, "inspectObject$1");
|
|
787
|
+
function inspectAttribute(_ref, options) {
|
|
788
|
+
var _ref2 = _slicedToArray(_ref, 2), key = _ref2[0], value = _ref2[1];
|
|
789
|
+
options.truncate -= 3;
|
|
790
|
+
if (!value) {
|
|
791
|
+
return "".concat(options.stylize(key, "yellow"));
|
|
792
|
+
}
|
|
793
|
+
return "".concat(options.stylize(key, "yellow"), "=").concat(options.stylize('"'.concat(value, '"'), "string"));
|
|
794
|
+
}
|
|
795
|
+
__name(inspectAttribute, "inspectAttribute");
|
|
796
|
+
function inspectHTMLCollection(collection, options) {
|
|
797
|
+
return inspectList(collection, options, inspectHTML, "\n");
|
|
798
|
+
}
|
|
799
|
+
__name(inspectHTMLCollection, "inspectHTMLCollection");
|
|
800
|
+
function inspectHTML(element, options) {
|
|
801
|
+
var properties = element.getAttributeNames();
|
|
802
|
+
var name = element.tagName.toLowerCase();
|
|
803
|
+
var head = options.stylize("<".concat(name), "special");
|
|
804
|
+
var headClose = options.stylize(">", "special");
|
|
805
|
+
var tail = options.stylize("</".concat(name, ">"), "special");
|
|
806
|
+
options.truncate -= name.length * 2 + 5;
|
|
807
|
+
var propertyContents = "";
|
|
808
|
+
if (properties.length > 0) {
|
|
809
|
+
propertyContents += " ";
|
|
810
|
+
propertyContents += inspectList(properties.map(function(key) {
|
|
811
|
+
return [key, element.getAttribute(key)];
|
|
812
|
+
}), options, inspectAttribute, " ");
|
|
813
|
+
}
|
|
814
|
+
options.truncate -= propertyContents.length;
|
|
815
|
+
var truncate2 = options.truncate;
|
|
816
|
+
var children = inspectHTMLCollection(element.children, options);
|
|
817
|
+
if (children && children.length > truncate2) {
|
|
818
|
+
children = "".concat(truncator, "(").concat(element.children.length, ")");
|
|
819
|
+
}
|
|
820
|
+
return "".concat(head).concat(propertyContents).concat(headClose).concat(children).concat(tail);
|
|
821
|
+
}
|
|
822
|
+
__name(inspectHTML, "inspectHTML");
|
|
823
|
+
var symbolsSupported = typeof Symbol === "function" && typeof Symbol.for === "function";
|
|
824
|
+
var chaiInspect = symbolsSupported ? Symbol.for("chai/inspect") : "@@chai/inspect";
|
|
825
|
+
var nodeInspect = false;
|
|
826
|
+
try {
|
|
827
|
+
var nodeUtil = require_util();
|
|
828
|
+
nodeInspect = nodeUtil.inspect ? nodeUtil.inspect.custom : false;
|
|
829
|
+
} catch (noNodeInspect) {
|
|
830
|
+
nodeInspect = false;
|
|
831
|
+
}
|
|
832
|
+
function FakeMap() {
|
|
833
|
+
this.key = "chai/loupe__" + Math.random() + Date.now();
|
|
834
|
+
}
|
|
835
|
+
__name(FakeMap, "FakeMap");
|
|
836
|
+
FakeMap.prototype = {
|
|
837
|
+
// eslint-disable-next-line object-shorthand
|
|
838
|
+
get: /* @__PURE__ */ __name(function get(key) {
|
|
839
|
+
return key[this.key];
|
|
840
|
+
}, "get"),
|
|
841
|
+
// eslint-disable-next-line object-shorthand
|
|
842
|
+
has: /* @__PURE__ */ __name(function has(key) {
|
|
843
|
+
return this.key in key;
|
|
844
|
+
}, "has"),
|
|
845
|
+
// eslint-disable-next-line object-shorthand
|
|
846
|
+
set: /* @__PURE__ */ __name(function set(key, value) {
|
|
847
|
+
if (Object.isExtensible(key)) {
|
|
848
|
+
Object.defineProperty(key, this.key, {
|
|
849
|
+
// eslint-disable-next-line object-shorthand
|
|
850
|
+
value,
|
|
851
|
+
configurable: true
|
|
852
|
+
});
|
|
853
|
+
}
|
|
854
|
+
}, "set")
|
|
855
|
+
};
|
|
856
|
+
var constructorMap = new (typeof WeakMap === "function" ? WeakMap : FakeMap)();
|
|
857
|
+
var stringTagMap = {};
|
|
858
|
+
var baseTypesMap = {
|
|
859
|
+
undefined: /* @__PURE__ */ __name(function undefined$1(value, options) {
|
|
860
|
+
return options.stylize("undefined", "undefined");
|
|
861
|
+
}, "undefined$1"),
|
|
862
|
+
null: /* @__PURE__ */ __name(function _null(value, options) {
|
|
863
|
+
return options.stylize(null, "null");
|
|
864
|
+
}, "_null"),
|
|
865
|
+
boolean: /* @__PURE__ */ __name(function boolean(value, options) {
|
|
866
|
+
return options.stylize(value, "boolean");
|
|
867
|
+
}, "boolean"),
|
|
868
|
+
Boolean: /* @__PURE__ */ __name(function Boolean2(value, options) {
|
|
869
|
+
return options.stylize(value, "boolean");
|
|
870
|
+
}, "Boolean"),
|
|
871
|
+
number: inspectNumber,
|
|
872
|
+
Number: inspectNumber,
|
|
873
|
+
bigint: inspectBigInt,
|
|
874
|
+
BigInt: inspectBigInt,
|
|
875
|
+
string: inspectString,
|
|
876
|
+
String: inspectString,
|
|
877
|
+
function: inspectFunction,
|
|
878
|
+
Function: inspectFunction,
|
|
879
|
+
symbol: inspectSymbol,
|
|
880
|
+
// A Symbol polyfill will return `Symbol` not `symbol` from typedetect
|
|
881
|
+
Symbol: inspectSymbol,
|
|
882
|
+
Array: inspectArray,
|
|
883
|
+
Date: inspectDate,
|
|
884
|
+
Map: inspectMap,
|
|
885
|
+
Set: inspectSet,
|
|
886
|
+
RegExp: inspectRegExp,
|
|
887
|
+
Promise: inspectPromise,
|
|
888
|
+
// WeakSet, WeakMap are totally opaque to us
|
|
889
|
+
WeakSet: /* @__PURE__ */ __name(function WeakSet2(value, options) {
|
|
890
|
+
return options.stylize("WeakSet{\u2026}", "special");
|
|
891
|
+
}, "WeakSet"),
|
|
892
|
+
WeakMap: /* @__PURE__ */ __name(function WeakMap2(value, options) {
|
|
893
|
+
return options.stylize("WeakMap{\u2026}", "special");
|
|
894
|
+
}, "WeakMap"),
|
|
895
|
+
Arguments: inspectArguments,
|
|
896
|
+
Int8Array: inspectTypedArray,
|
|
897
|
+
Uint8Array: inspectTypedArray,
|
|
898
|
+
Uint8ClampedArray: inspectTypedArray,
|
|
899
|
+
Int16Array: inspectTypedArray,
|
|
900
|
+
Uint16Array: inspectTypedArray,
|
|
901
|
+
Int32Array: inspectTypedArray,
|
|
902
|
+
Uint32Array: inspectTypedArray,
|
|
903
|
+
Float32Array: inspectTypedArray,
|
|
904
|
+
Float64Array: inspectTypedArray,
|
|
905
|
+
Generator: /* @__PURE__ */ __name(function Generator() {
|
|
906
|
+
return "";
|
|
907
|
+
}, "Generator"),
|
|
908
|
+
DataView: /* @__PURE__ */ __name(function DataView2() {
|
|
909
|
+
return "";
|
|
910
|
+
}, "DataView"),
|
|
911
|
+
ArrayBuffer: /* @__PURE__ */ __name(function ArrayBuffer() {
|
|
912
|
+
return "";
|
|
913
|
+
}, "ArrayBuffer"),
|
|
914
|
+
Error: inspectObject$1,
|
|
915
|
+
HTMLCollection: inspectHTMLCollection,
|
|
916
|
+
NodeList: inspectHTMLCollection
|
|
917
|
+
};
|
|
918
|
+
var inspectCustom = /* @__PURE__ */ __name(function inspectCustom2(value, options, type3) {
|
|
919
|
+
if (chaiInspect in value && typeof value[chaiInspect] === "function") {
|
|
920
|
+
return value[chaiInspect](options);
|
|
921
|
+
}
|
|
922
|
+
if (nodeInspect && nodeInspect in value && typeof value[nodeInspect] === "function") {
|
|
923
|
+
return value[nodeInspect](options.depth, options);
|
|
924
|
+
}
|
|
925
|
+
if ("inspect" in value && typeof value.inspect === "function") {
|
|
926
|
+
return value.inspect(options.depth, options);
|
|
927
|
+
}
|
|
928
|
+
if ("constructor" in value && constructorMap.has(value.constructor)) {
|
|
929
|
+
return constructorMap.get(value.constructor)(value, options);
|
|
930
|
+
}
|
|
931
|
+
if (stringTagMap[type3]) {
|
|
932
|
+
return stringTagMap[type3](value, options);
|
|
933
|
+
}
|
|
934
|
+
return "";
|
|
935
|
+
}, "inspectCustom");
|
|
936
|
+
var toString$1 = Object.prototype.toString;
|
|
937
|
+
function inspect2(value, options) {
|
|
938
|
+
options = normaliseOptions(options);
|
|
939
|
+
options.inspect = inspect2;
|
|
940
|
+
var _options = options, customInspect = _options.customInspect;
|
|
941
|
+
var type3 = value === null ? "null" : _typeof(value);
|
|
942
|
+
if (type3 === "object") {
|
|
943
|
+
type3 = toString$1.call(value).slice(8, -1);
|
|
944
|
+
}
|
|
945
|
+
if (baseTypesMap[type3]) {
|
|
946
|
+
return baseTypesMap[type3](value, options);
|
|
947
|
+
}
|
|
948
|
+
if (customInspect && value) {
|
|
949
|
+
var output = inspectCustom(value, options, type3);
|
|
950
|
+
if (output) {
|
|
951
|
+
if (typeof output === "string")
|
|
952
|
+
return output;
|
|
953
|
+
return inspect2(output, options);
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
var proto = value ? Object.getPrototypeOf(value) : false;
|
|
957
|
+
if (proto === Object.prototype || proto === null) {
|
|
958
|
+
return inspectObject(value, options);
|
|
959
|
+
}
|
|
960
|
+
if (value && typeof HTMLElement === "function" && value instanceof HTMLElement) {
|
|
961
|
+
return inspectHTML(value, options);
|
|
962
|
+
}
|
|
963
|
+
if ("constructor" in value) {
|
|
964
|
+
if (value.constructor !== Object) {
|
|
965
|
+
return inspectClass(value, options);
|
|
966
|
+
}
|
|
967
|
+
return inspectObject(value, options);
|
|
968
|
+
}
|
|
969
|
+
if (value === Object(value)) {
|
|
970
|
+
return inspectObject(value, options);
|
|
971
|
+
}
|
|
972
|
+
return options.stylize(String(value), type3);
|
|
973
|
+
}
|
|
974
|
+
__name(inspect2, "inspect");
|
|
975
|
+
function registerConstructor(constructor, inspector) {
|
|
976
|
+
if (constructorMap.has(constructor)) {
|
|
977
|
+
return false;
|
|
978
|
+
}
|
|
979
|
+
constructorMap.set(constructor, inspector);
|
|
980
|
+
return true;
|
|
981
|
+
}
|
|
982
|
+
__name(registerConstructor, "registerConstructor");
|
|
983
|
+
function registerStringTag(stringTag, inspector) {
|
|
984
|
+
if (stringTag in stringTagMap) {
|
|
985
|
+
return false;
|
|
986
|
+
}
|
|
987
|
+
stringTagMap[stringTag] = inspector;
|
|
988
|
+
return true;
|
|
989
|
+
}
|
|
990
|
+
__name(registerStringTag, "registerStringTag");
|
|
991
|
+
var custom = chaiInspect;
|
|
992
|
+
exports2.custom = custom;
|
|
993
|
+
exports2.default = inspect2;
|
|
994
|
+
exports2.inspect = inspect2;
|
|
995
|
+
exports2.registerConstructor = registerConstructor;
|
|
996
|
+
exports2.registerStringTag = registerStringTag;
|
|
997
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
998
|
+
});
|
|
999
|
+
}
|
|
1000
|
+
});
|
|
1001
|
+
|
|
1002
|
+
// node_modules/deep-eql/index.js
|
|
1003
|
+
var require_deep_eql = __commonJS({
|
|
1004
|
+
"node_modules/deep-eql/index.js"(exports, module2) {
|
|
1005
|
+
"use strict";
|
|
1006
|
+
var type3 = require_type_detect();
|
|
1007
|
+
function FakeMap() {
|
|
1008
|
+
this._key = "chai/deep-eql__" + Math.random() + Date.now();
|
|
1009
|
+
}
|
|
1010
|
+
__name(FakeMap, "FakeMap");
|
|
1011
|
+
FakeMap.prototype = {
|
|
1012
|
+
get: /* @__PURE__ */ __name(function get(key) {
|
|
1013
|
+
return key[this._key];
|
|
1014
|
+
}, "get"),
|
|
1015
|
+
set: /* @__PURE__ */ __name(function set(key, value) {
|
|
1016
|
+
if (Object.isExtensible(key)) {
|
|
1017
|
+
Object.defineProperty(key, this._key, {
|
|
1018
|
+
value,
|
|
1019
|
+
configurable: true
|
|
1020
|
+
});
|
|
1021
|
+
}
|
|
1022
|
+
}, "set")
|
|
1023
|
+
};
|
|
1024
|
+
var MemoizeMap = typeof WeakMap === "function" ? WeakMap : FakeMap;
|
|
1025
|
+
function memoizeCompare(leftHandOperand, rightHandOperand, memoizeMap) {
|
|
1026
|
+
if (!memoizeMap || isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand)) {
|
|
1027
|
+
return null;
|
|
1028
|
+
}
|
|
1029
|
+
var leftHandMap = memoizeMap.get(leftHandOperand);
|
|
1030
|
+
if (leftHandMap) {
|
|
1031
|
+
var result = leftHandMap.get(rightHandOperand);
|
|
1032
|
+
if (typeof result === "boolean") {
|
|
1033
|
+
return result;
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
return null;
|
|
1037
|
+
}
|
|
1038
|
+
__name(memoizeCompare, "memoizeCompare");
|
|
1039
|
+
function memoizeSet(leftHandOperand, rightHandOperand, memoizeMap, result) {
|
|
1040
|
+
if (!memoizeMap || isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand)) {
|
|
1041
|
+
return;
|
|
1042
|
+
}
|
|
1043
|
+
var leftHandMap = memoizeMap.get(leftHandOperand);
|
|
1044
|
+
if (leftHandMap) {
|
|
1045
|
+
leftHandMap.set(rightHandOperand, result);
|
|
1046
|
+
} else {
|
|
1047
|
+
leftHandMap = new MemoizeMap();
|
|
1048
|
+
leftHandMap.set(rightHandOperand, result);
|
|
1049
|
+
memoizeMap.set(leftHandOperand, leftHandMap);
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
__name(memoizeSet, "memoizeSet");
|
|
1053
|
+
module2.exports = deepEqual;
|
|
1054
|
+
module2.exports.MemoizeMap = MemoizeMap;
|
|
1055
|
+
function deepEqual(leftHandOperand, rightHandOperand, options) {
|
|
1056
|
+
if (options && options.comparator) {
|
|
1057
|
+
return extensiveDeepEqual(leftHandOperand, rightHandOperand, options);
|
|
1058
|
+
}
|
|
1059
|
+
var simpleResult = simpleEqual(leftHandOperand, rightHandOperand);
|
|
1060
|
+
if (simpleResult !== null) {
|
|
1061
|
+
return simpleResult;
|
|
1062
|
+
}
|
|
1063
|
+
return extensiveDeepEqual(leftHandOperand, rightHandOperand, options);
|
|
1064
|
+
}
|
|
1065
|
+
__name(deepEqual, "deepEqual");
|
|
1066
|
+
function simpleEqual(leftHandOperand, rightHandOperand) {
|
|
1067
|
+
if (leftHandOperand === rightHandOperand) {
|
|
1068
|
+
return leftHandOperand !== 0 || 1 / leftHandOperand === 1 / rightHandOperand;
|
|
1069
|
+
}
|
|
1070
|
+
if (leftHandOperand !== leftHandOperand && // eslint-disable-line no-self-compare
|
|
1071
|
+
rightHandOperand !== rightHandOperand) {
|
|
1072
|
+
return true;
|
|
1073
|
+
}
|
|
1074
|
+
if (isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand)) {
|
|
1075
|
+
return false;
|
|
1076
|
+
}
|
|
1077
|
+
return null;
|
|
1078
|
+
}
|
|
1079
|
+
__name(simpleEqual, "simpleEqual");
|
|
1080
|
+
function extensiveDeepEqual(leftHandOperand, rightHandOperand, options) {
|
|
1081
|
+
options = options || {};
|
|
1082
|
+
options.memoize = options.memoize === false ? false : options.memoize || new MemoizeMap();
|
|
1083
|
+
var comparator = options && options.comparator;
|
|
1084
|
+
var memoizeResultLeft = memoizeCompare(leftHandOperand, rightHandOperand, options.memoize);
|
|
1085
|
+
if (memoizeResultLeft !== null) {
|
|
1086
|
+
return memoizeResultLeft;
|
|
1087
|
+
}
|
|
1088
|
+
var memoizeResultRight = memoizeCompare(rightHandOperand, leftHandOperand, options.memoize);
|
|
1089
|
+
if (memoizeResultRight !== null) {
|
|
1090
|
+
return memoizeResultRight;
|
|
1091
|
+
}
|
|
1092
|
+
if (comparator) {
|
|
1093
|
+
var comparatorResult = comparator(leftHandOperand, rightHandOperand);
|
|
1094
|
+
if (comparatorResult === false || comparatorResult === true) {
|
|
1095
|
+
memoizeSet(leftHandOperand, rightHandOperand, options.memoize, comparatorResult);
|
|
1096
|
+
return comparatorResult;
|
|
1097
|
+
}
|
|
1098
|
+
var simpleResult = simpleEqual(leftHandOperand, rightHandOperand);
|
|
1099
|
+
if (simpleResult !== null) {
|
|
1100
|
+
return simpleResult;
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
var leftHandType = type3(leftHandOperand);
|
|
1104
|
+
if (leftHandType !== type3(rightHandOperand)) {
|
|
1105
|
+
memoizeSet(leftHandOperand, rightHandOperand, options.memoize, false);
|
|
1106
|
+
return false;
|
|
1107
|
+
}
|
|
1108
|
+
memoizeSet(leftHandOperand, rightHandOperand, options.memoize, true);
|
|
1109
|
+
var result = extensiveDeepEqualByType(leftHandOperand, rightHandOperand, leftHandType, options);
|
|
1110
|
+
memoizeSet(leftHandOperand, rightHandOperand, options.memoize, result);
|
|
1111
|
+
return result;
|
|
1112
|
+
}
|
|
1113
|
+
__name(extensiveDeepEqual, "extensiveDeepEqual");
|
|
1114
|
+
function extensiveDeepEqualByType(leftHandOperand, rightHandOperand, leftHandType, options) {
|
|
1115
|
+
switch (leftHandType) {
|
|
1116
|
+
case "String":
|
|
1117
|
+
case "Number":
|
|
1118
|
+
case "Boolean":
|
|
1119
|
+
case "Date":
|
|
1120
|
+
return deepEqual(leftHandOperand.valueOf(), rightHandOperand.valueOf());
|
|
1121
|
+
case "Promise":
|
|
1122
|
+
case "Symbol":
|
|
1123
|
+
case "function":
|
|
1124
|
+
case "WeakMap":
|
|
1125
|
+
case "WeakSet":
|
|
1126
|
+
return leftHandOperand === rightHandOperand;
|
|
1127
|
+
case "Error":
|
|
1128
|
+
return keysEqual(leftHandOperand, rightHandOperand, ["name", "message", "code"], options);
|
|
1129
|
+
case "Arguments":
|
|
1130
|
+
case "Int8Array":
|
|
1131
|
+
case "Uint8Array":
|
|
1132
|
+
case "Uint8ClampedArray":
|
|
1133
|
+
case "Int16Array":
|
|
1134
|
+
case "Uint16Array":
|
|
1135
|
+
case "Int32Array":
|
|
1136
|
+
case "Uint32Array":
|
|
1137
|
+
case "Float32Array":
|
|
1138
|
+
case "Float64Array":
|
|
1139
|
+
case "Array":
|
|
1140
|
+
return iterableEqual(leftHandOperand, rightHandOperand, options);
|
|
1141
|
+
case "RegExp":
|
|
1142
|
+
return regexpEqual(leftHandOperand, rightHandOperand);
|
|
1143
|
+
case "Generator":
|
|
1144
|
+
return generatorEqual(leftHandOperand, rightHandOperand, options);
|
|
1145
|
+
case "DataView":
|
|
1146
|
+
return iterableEqual(new Uint8Array(leftHandOperand.buffer), new Uint8Array(rightHandOperand.buffer), options);
|
|
1147
|
+
case "ArrayBuffer":
|
|
1148
|
+
return iterableEqual(new Uint8Array(leftHandOperand), new Uint8Array(rightHandOperand), options);
|
|
1149
|
+
case "Set":
|
|
1150
|
+
return entriesEqual(leftHandOperand, rightHandOperand, options);
|
|
1151
|
+
case "Map":
|
|
1152
|
+
return entriesEqual(leftHandOperand, rightHandOperand, options);
|
|
1153
|
+
case "Temporal.PlainDate":
|
|
1154
|
+
case "Temporal.PlainTime":
|
|
1155
|
+
case "Temporal.PlainDateTime":
|
|
1156
|
+
case "Temporal.Instant":
|
|
1157
|
+
case "Temporal.ZonedDateTime":
|
|
1158
|
+
case "Temporal.PlainYearMonth":
|
|
1159
|
+
case "Temporal.PlainMonthDay":
|
|
1160
|
+
return leftHandOperand.equals(rightHandOperand);
|
|
1161
|
+
case "Temporal.Duration":
|
|
1162
|
+
return leftHandOperand.total("nanoseconds") === rightHandOperand.total("nanoseconds");
|
|
1163
|
+
case "Temporal.TimeZone":
|
|
1164
|
+
case "Temporal.Calendar":
|
|
1165
|
+
return leftHandOperand.toString() === rightHandOperand.toString();
|
|
1166
|
+
default:
|
|
1167
|
+
return objectEqual(leftHandOperand, rightHandOperand, options);
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
__name(extensiveDeepEqualByType, "extensiveDeepEqualByType");
|
|
1171
|
+
function regexpEqual(leftHandOperand, rightHandOperand) {
|
|
1172
|
+
return leftHandOperand.toString() === rightHandOperand.toString();
|
|
1173
|
+
}
|
|
1174
|
+
__name(regexpEqual, "regexpEqual");
|
|
1175
|
+
function entriesEqual(leftHandOperand, rightHandOperand, options) {
|
|
1176
|
+
if (leftHandOperand.size !== rightHandOperand.size) {
|
|
1177
|
+
return false;
|
|
1178
|
+
}
|
|
1179
|
+
if (leftHandOperand.size === 0) {
|
|
1180
|
+
return true;
|
|
1181
|
+
}
|
|
1182
|
+
var leftHandItems = [];
|
|
1183
|
+
var rightHandItems = [];
|
|
1184
|
+
leftHandOperand.forEach(/* @__PURE__ */ __name(function gatherEntries(key, value) {
|
|
1185
|
+
leftHandItems.push([key, value]);
|
|
1186
|
+
}, "gatherEntries"));
|
|
1187
|
+
rightHandOperand.forEach(/* @__PURE__ */ __name(function gatherEntries(key, value) {
|
|
1188
|
+
rightHandItems.push([key, value]);
|
|
1189
|
+
}, "gatherEntries"));
|
|
1190
|
+
return iterableEqual(leftHandItems.sort(), rightHandItems.sort(), options);
|
|
1191
|
+
}
|
|
1192
|
+
__name(entriesEqual, "entriesEqual");
|
|
1193
|
+
function iterableEqual(leftHandOperand, rightHandOperand, options) {
|
|
1194
|
+
var length = leftHandOperand.length;
|
|
1195
|
+
if (length !== rightHandOperand.length) {
|
|
1196
|
+
return false;
|
|
1197
|
+
}
|
|
1198
|
+
if (length === 0) {
|
|
1199
|
+
return true;
|
|
1200
|
+
}
|
|
1201
|
+
var index = -1;
|
|
1202
|
+
while (++index < length) {
|
|
1203
|
+
if (deepEqual(leftHandOperand[index], rightHandOperand[index], options) === false) {
|
|
1204
|
+
return false;
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
return true;
|
|
1208
|
+
}
|
|
1209
|
+
__name(iterableEqual, "iterableEqual");
|
|
1210
|
+
function generatorEqual(leftHandOperand, rightHandOperand, options) {
|
|
1211
|
+
return iterableEqual(getGeneratorEntries(leftHandOperand), getGeneratorEntries(rightHandOperand), options);
|
|
1212
|
+
}
|
|
1213
|
+
__name(generatorEqual, "generatorEqual");
|
|
1214
|
+
function hasIteratorFunction(target) {
|
|
1215
|
+
return typeof Symbol !== "undefined" && typeof target === "object" && typeof Symbol.iterator !== "undefined" && typeof target[Symbol.iterator] === "function";
|
|
1216
|
+
}
|
|
1217
|
+
__name(hasIteratorFunction, "hasIteratorFunction");
|
|
1218
|
+
function getIteratorEntries(target) {
|
|
1219
|
+
if (hasIteratorFunction(target)) {
|
|
1220
|
+
try {
|
|
1221
|
+
return getGeneratorEntries(target[Symbol.iterator]());
|
|
1222
|
+
} catch (iteratorError) {
|
|
1223
|
+
return [];
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
return [];
|
|
1227
|
+
}
|
|
1228
|
+
__name(getIteratorEntries, "getIteratorEntries");
|
|
1229
|
+
function getGeneratorEntries(generator) {
|
|
1230
|
+
var generatorResult = generator.next();
|
|
1231
|
+
var accumulator = [generatorResult.value];
|
|
1232
|
+
while (generatorResult.done === false) {
|
|
1233
|
+
generatorResult = generator.next();
|
|
1234
|
+
accumulator.push(generatorResult.value);
|
|
1235
|
+
}
|
|
1236
|
+
return accumulator;
|
|
1237
|
+
}
|
|
1238
|
+
__name(getGeneratorEntries, "getGeneratorEntries");
|
|
1239
|
+
function getEnumerableKeys(target) {
|
|
1240
|
+
var keys = [];
|
|
1241
|
+
for (var key in target) {
|
|
1242
|
+
keys.push(key);
|
|
1243
|
+
}
|
|
1244
|
+
return keys;
|
|
1245
|
+
}
|
|
1246
|
+
__name(getEnumerableKeys, "getEnumerableKeys");
|
|
1247
|
+
function getEnumerableSymbols(target) {
|
|
1248
|
+
var keys = [];
|
|
1249
|
+
var allKeys = Object.getOwnPropertySymbols(target);
|
|
1250
|
+
for (var i = 0; i < allKeys.length; i += 1) {
|
|
1251
|
+
var key = allKeys[i];
|
|
1252
|
+
if (Object.getOwnPropertyDescriptor(target, key).enumerable) {
|
|
1253
|
+
keys.push(key);
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
return keys;
|
|
1257
|
+
}
|
|
1258
|
+
__name(getEnumerableSymbols, "getEnumerableSymbols");
|
|
1259
|
+
function keysEqual(leftHandOperand, rightHandOperand, keys, options) {
|
|
1260
|
+
var length = keys.length;
|
|
1261
|
+
if (length === 0) {
|
|
1262
|
+
return true;
|
|
1263
|
+
}
|
|
1264
|
+
for (var i = 0; i < length; i += 1) {
|
|
1265
|
+
if (deepEqual(leftHandOperand[keys[i]], rightHandOperand[keys[i]], options) === false) {
|
|
1266
|
+
return false;
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
return true;
|
|
1270
|
+
}
|
|
1271
|
+
__name(keysEqual, "keysEqual");
|
|
1272
|
+
function objectEqual(leftHandOperand, rightHandOperand, options) {
|
|
1273
|
+
var leftHandKeys = getEnumerableKeys(leftHandOperand);
|
|
1274
|
+
var rightHandKeys = getEnumerableKeys(rightHandOperand);
|
|
1275
|
+
var leftHandSymbols = getEnumerableSymbols(leftHandOperand);
|
|
1276
|
+
var rightHandSymbols = getEnumerableSymbols(rightHandOperand);
|
|
1277
|
+
leftHandKeys = leftHandKeys.concat(leftHandSymbols);
|
|
1278
|
+
rightHandKeys = rightHandKeys.concat(rightHandSymbols);
|
|
1279
|
+
if (leftHandKeys.length && leftHandKeys.length === rightHandKeys.length) {
|
|
1280
|
+
if (iterableEqual(mapSymbols(leftHandKeys).sort(), mapSymbols(rightHandKeys).sort()) === false) {
|
|
1281
|
+
return false;
|
|
1282
|
+
}
|
|
1283
|
+
return keysEqual(leftHandOperand, rightHandOperand, leftHandKeys, options);
|
|
1284
|
+
}
|
|
1285
|
+
var leftHandEntries = getIteratorEntries(leftHandOperand);
|
|
1286
|
+
var rightHandEntries = getIteratorEntries(rightHandOperand);
|
|
1287
|
+
if (leftHandEntries.length && leftHandEntries.length === rightHandEntries.length) {
|
|
1288
|
+
leftHandEntries.sort();
|
|
1289
|
+
rightHandEntries.sort();
|
|
1290
|
+
return iterableEqual(leftHandEntries, rightHandEntries, options);
|
|
1291
|
+
}
|
|
1292
|
+
if (leftHandKeys.length === 0 && leftHandEntries.length === 0 && rightHandKeys.length === 0 && rightHandEntries.length === 0) {
|
|
1293
|
+
return true;
|
|
1294
|
+
}
|
|
1295
|
+
return false;
|
|
1296
|
+
}
|
|
1297
|
+
__name(objectEqual, "objectEqual");
|
|
1298
|
+
function isPrimitive(value) {
|
|
1299
|
+
return value === null || typeof value !== "object";
|
|
1300
|
+
}
|
|
1301
|
+
__name(isPrimitive, "isPrimitive");
|
|
1302
|
+
function mapSymbols(arr) {
|
|
1303
|
+
return arr.map(/* @__PURE__ */ __name(function mapSymbol(entry) {
|
|
1304
|
+
if (typeof entry === "symbol") {
|
|
1305
|
+
return entry.toString();
|
|
1306
|
+
}
|
|
1307
|
+
return entry;
|
|
1308
|
+
}, "mapSymbol"));
|
|
1309
|
+
}
|
|
1310
|
+
__name(mapSymbols, "mapSymbols");
|
|
1311
|
+
}
|
|
1312
|
+
});
|
|
1313
|
+
|
|
1314
|
+
// node_modules/pathval/index.js
|
|
1315
|
+
var require_pathval = __commonJS({
|
|
1316
|
+
"node_modules/pathval/index.js"(exports, module2) {
|
|
1317
|
+
"use strict";
|
|
1318
|
+
function hasProperty2(obj, name) {
|
|
1319
|
+
if (typeof obj === "undefined" || obj === null) {
|
|
1320
|
+
return false;
|
|
1321
|
+
}
|
|
1322
|
+
return name in Object(obj);
|
|
1323
|
+
}
|
|
1324
|
+
__name(hasProperty2, "hasProperty");
|
|
1325
|
+
function parsePath(path) {
|
|
1326
|
+
var str = path.replace(/([^\\])\[/g, "$1.[");
|
|
1327
|
+
var parts = str.match(/(\\\.|[^.]+?)+/g);
|
|
1328
|
+
return parts.map(/* @__PURE__ */ __name(function mapMatches(value) {
|
|
1329
|
+
if (value === "constructor" || value === "__proto__" || value === "prototype") {
|
|
1330
|
+
return {};
|
|
1331
|
+
}
|
|
1332
|
+
var regexp = /^\[(\d+)\]$/;
|
|
1333
|
+
var mArr = regexp.exec(value);
|
|
1334
|
+
var parsed = null;
|
|
1335
|
+
if (mArr) {
|
|
1336
|
+
parsed = { i: parseFloat(mArr[1]) };
|
|
1337
|
+
} else {
|
|
1338
|
+
parsed = { p: value.replace(/\\([.[\]])/g, "$1") };
|
|
1339
|
+
}
|
|
1340
|
+
return parsed;
|
|
1341
|
+
}, "mapMatches"));
|
|
1342
|
+
}
|
|
1343
|
+
__name(parsePath, "parsePath");
|
|
1344
|
+
function internalGetPathValue(obj, parsed, pathDepth) {
|
|
1345
|
+
var temporaryValue = obj;
|
|
1346
|
+
var res = null;
|
|
1347
|
+
pathDepth = typeof pathDepth === "undefined" ? parsed.length : pathDepth;
|
|
1348
|
+
for (var i = 0; i < pathDepth; i++) {
|
|
1349
|
+
var part = parsed[i];
|
|
1350
|
+
if (temporaryValue) {
|
|
1351
|
+
if (typeof part.p === "undefined") {
|
|
1352
|
+
temporaryValue = temporaryValue[part.i];
|
|
1353
|
+
} else {
|
|
1354
|
+
temporaryValue = temporaryValue[part.p];
|
|
1355
|
+
}
|
|
1356
|
+
if (i === pathDepth - 1) {
|
|
1357
|
+
res = temporaryValue;
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
return res;
|
|
1362
|
+
}
|
|
1363
|
+
__name(internalGetPathValue, "internalGetPathValue");
|
|
1364
|
+
function internalSetPathValue(obj, val, parsed) {
|
|
1365
|
+
var tempObj = obj;
|
|
1366
|
+
var pathDepth = parsed.length;
|
|
1367
|
+
var part = null;
|
|
1368
|
+
for (var i = 0; i < pathDepth; i++) {
|
|
1369
|
+
var propName = null;
|
|
1370
|
+
var propVal = null;
|
|
1371
|
+
part = parsed[i];
|
|
1372
|
+
if (i === pathDepth - 1) {
|
|
1373
|
+
propName = typeof part.p === "undefined" ? part.i : part.p;
|
|
1374
|
+
tempObj[propName] = val;
|
|
1375
|
+
} else if (typeof part.p !== "undefined" && tempObj[part.p]) {
|
|
1376
|
+
tempObj = tempObj[part.p];
|
|
1377
|
+
} else if (typeof part.i !== "undefined" && tempObj[part.i]) {
|
|
1378
|
+
tempObj = tempObj[part.i];
|
|
1379
|
+
} else {
|
|
1380
|
+
var next = parsed[i + 1];
|
|
1381
|
+
propName = typeof part.p === "undefined" ? part.i : part.p;
|
|
1382
|
+
propVal = typeof next.p === "undefined" ? [] : {};
|
|
1383
|
+
tempObj[propName] = propVal;
|
|
1384
|
+
tempObj = tempObj[propName];
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
__name(internalSetPathValue, "internalSetPathValue");
|
|
1389
|
+
function getPathInfo2(obj, path) {
|
|
1390
|
+
var parsed = parsePath(path);
|
|
1391
|
+
var last = parsed[parsed.length - 1];
|
|
1392
|
+
var info = {
|
|
1393
|
+
parent: parsed.length > 1 ? internalGetPathValue(obj, parsed, parsed.length - 1) : obj,
|
|
1394
|
+
name: last.p || last.i,
|
|
1395
|
+
value: internalGetPathValue(obj, parsed)
|
|
1396
|
+
};
|
|
1397
|
+
info.exists = hasProperty2(info.parent, info.name);
|
|
1398
|
+
return info;
|
|
1399
|
+
}
|
|
1400
|
+
__name(getPathInfo2, "getPathInfo");
|
|
1401
|
+
function getPathValue(obj, path) {
|
|
1402
|
+
var info = getPathInfo2(obj, path);
|
|
1403
|
+
return info.value;
|
|
1404
|
+
}
|
|
1405
|
+
__name(getPathValue, "getPathValue");
|
|
1406
|
+
function setPathValue(obj, path, val) {
|
|
1407
|
+
var parsed = parsePath(path);
|
|
1408
|
+
internalSetPathValue(obj, val, parsed);
|
|
1409
|
+
return obj;
|
|
1410
|
+
}
|
|
1411
|
+
__name(setPathValue, "setPathValue");
|
|
1412
|
+
module2.exports = {
|
|
1413
|
+
hasProperty: hasProperty2,
|
|
1414
|
+
getPathInfo: getPathInfo2,
|
|
1415
|
+
getPathValue,
|
|
1416
|
+
setPathValue
|
|
1417
|
+
};
|
|
1418
|
+
}
|
|
1419
|
+
});
|
|
1420
|
+
|
|
1421
|
+
// index.js
|
|
1422
|
+
var chai_exports = {};
|
|
1423
|
+
__export(chai_exports, {
|
|
1424
|
+
Assertion: () => Assertion,
|
|
1425
|
+
AssertionError: () => import_assertion_error7.default,
|
|
1426
|
+
Should: () => Should,
|
|
1427
|
+
assert: () => assert,
|
|
1428
|
+
config: () => config,
|
|
1429
|
+
expect: () => expect,
|
|
1430
|
+
should: () => should,
|
|
1431
|
+
use: () => use,
|
|
1432
|
+
util: () => utils_exports,
|
|
1433
|
+
version: () => version
|
|
1434
|
+
});
|
|
1435
|
+
module.exports = __toCommonJS(chai_exports);
|
|
1436
|
+
|
|
1437
|
+
// lib/chai/utils/index.js
|
|
1438
|
+
var utils_exports = {};
|
|
1439
|
+
__export(utils_exports, {
|
|
1440
|
+
addChainableMethod: () => addChainableMethod,
|
|
1441
|
+
addLengthGuard: () => addLengthGuard,
|
|
1442
|
+
addMethod: () => addMethod,
|
|
1443
|
+
addProperty: () => addProperty,
|
|
1444
|
+
checkError: () => checkError,
|
|
1445
|
+
compareByInspect: () => compareByInspect,
|
|
1446
|
+
eql: () => import_deep_eql.default,
|
|
1447
|
+
expectTypes: () => expectTypes,
|
|
1448
|
+
flag: () => flag,
|
|
1449
|
+
getActual: () => getActual,
|
|
1450
|
+
getMessage: () => getMessage,
|
|
1451
|
+
getName: () => getName,
|
|
1452
|
+
getOperator: () => getOperator,
|
|
1453
|
+
getOwnEnumerableProperties: () => getOwnEnumerableProperties,
|
|
1454
|
+
getOwnEnumerablePropertySymbols: () => getOwnEnumerablePropertySymbols,
|
|
1455
|
+
getPathInfo: () => import_pathval.getPathInfo,
|
|
1456
|
+
hasProperty: () => import_pathval.hasProperty,
|
|
1457
|
+
inspect: () => inspect,
|
|
1458
|
+
isNaN: () => isNaN,
|
|
1459
|
+
isProxyEnabled: () => isProxyEnabled,
|
|
1460
|
+
objDisplay: () => objDisplay,
|
|
1461
|
+
overwriteChainableMethod: () => overwriteChainableMethod,
|
|
1462
|
+
overwriteMethod: () => overwriteMethod,
|
|
1463
|
+
overwriteProperty: () => overwriteProperty,
|
|
1464
|
+
proxify: () => proxify,
|
|
1465
|
+
test: () => test,
|
|
1466
|
+
transferFlags: () => transferFlags,
|
|
1467
|
+
type: () => import_type_detect3.default
|
|
1468
|
+
});
|
|
1469
|
+
var checkError = __toESM(require_check_error(), 1);
|
|
1470
|
+
|
|
1471
|
+
// lib/chai/utils/flag.js
|
|
1472
|
+
function flag(obj, key, value) {
|
|
1473
|
+
var flags = obj.__flags || (obj.__flags = /* @__PURE__ */ Object.create(null));
|
|
1474
|
+
if (arguments.length === 3) {
|
|
1475
|
+
flags[key] = value;
|
|
1476
|
+
} else {
|
|
1477
|
+
return flags[key];
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1480
|
+
__name(flag, "flag");
|
|
1481
|
+
|
|
1482
|
+
// lib/chai/utils/test.js
|
|
1483
|
+
function test(obj, args) {
|
|
1484
|
+
var negate = flag(obj, "negate"), expr = args[0];
|
|
1485
|
+
return negate ? !expr : expr;
|
|
1486
|
+
}
|
|
1487
|
+
__name(test, "test");
|
|
1488
|
+
|
|
1489
|
+
// lib/chai/utils/index.js
|
|
1490
|
+
var import_type_detect3 = __toESM(require_type_detect(), 1);
|
|
1491
|
+
|
|
1492
|
+
// lib/chai/utils/expectTypes.js
|
|
1493
|
+
var import_assertion_error = __toESM(require_assertion_error(), 1);
|
|
1494
|
+
var import_type_detect = __toESM(require_type_detect(), 1);
|
|
1495
|
+
function expectTypes(obj, types) {
|
|
1496
|
+
var flagMsg = flag(obj, "message");
|
|
1497
|
+
var ssfi = flag(obj, "ssfi");
|
|
1498
|
+
flagMsg = flagMsg ? flagMsg + ": " : "";
|
|
1499
|
+
obj = flag(obj, "object");
|
|
1500
|
+
types = types.map(function(t) {
|
|
1501
|
+
return t.toLowerCase();
|
|
1502
|
+
});
|
|
1503
|
+
types.sort();
|
|
1504
|
+
var str = types.map(function(t, index) {
|
|
1505
|
+
var art = ~["a", "e", "i", "o", "u"].indexOf(t.charAt(0)) ? "an" : "a";
|
|
1506
|
+
var or = types.length > 1 && index === types.length - 1 ? "or " : "";
|
|
1507
|
+
return or + art + " " + t;
|
|
1508
|
+
}).join(", ");
|
|
1509
|
+
var objType = (0, import_type_detect.default)(obj).toLowerCase();
|
|
1510
|
+
if (!types.some(function(expected) {
|
|
1511
|
+
return objType === expected;
|
|
1512
|
+
})) {
|
|
1513
|
+
throw new import_assertion_error.default(
|
|
1514
|
+
flagMsg + "object tested must be " + str + ", but " + objType + " given",
|
|
1515
|
+
void 0,
|
|
1516
|
+
ssfi
|
|
1517
|
+
);
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
__name(expectTypes, "expectTypes");
|
|
1521
|
+
|
|
1522
|
+
// lib/chai/utils/getActual.js
|
|
1523
|
+
function getActual(obj, args) {
|
|
1524
|
+
return args.length > 4 ? args[4] : obj._obj;
|
|
1525
|
+
}
|
|
1526
|
+
__name(getActual, "getActual");
|
|
1527
|
+
|
|
1528
|
+
// lib/chai/utils/inspect.js
|
|
1529
|
+
var import_loupe = __toESM(require_loupe(), 1);
|
|
1530
|
+
|
|
1531
|
+
// lib/chai/config.js
|
|
1532
|
+
var config = {
|
|
1533
|
+
/**
|
|
1534
|
+
* ### config.includeStack
|
|
1535
|
+
*
|
|
1536
|
+
* User configurable property, influences whether stack trace
|
|
1537
|
+
* is included in Assertion error message. Default of false
|
|
1538
|
+
* suppresses stack trace in the error message.
|
|
1539
|
+
*
|
|
1540
|
+
* chai.config.includeStack = true; // enable stack on error
|
|
1541
|
+
*
|
|
1542
|
+
* @param {Boolean}
|
|
1543
|
+
* @api public
|
|
1544
|
+
*/
|
|
1545
|
+
includeStack: false,
|
|
1546
|
+
/**
|
|
1547
|
+
* ### config.showDiff
|
|
1548
|
+
*
|
|
1549
|
+
* User configurable property, influences whether or not
|
|
1550
|
+
* the `showDiff` flag should be included in the thrown
|
|
1551
|
+
* AssertionErrors. `false` will always be `false`; `true`
|
|
1552
|
+
* will be true when the assertion has requested a diff
|
|
1553
|
+
* be shown.
|
|
1554
|
+
*
|
|
1555
|
+
* @param {Boolean}
|
|
1556
|
+
* @api public
|
|
1557
|
+
*/
|
|
1558
|
+
showDiff: true,
|
|
1559
|
+
/**
|
|
1560
|
+
* ### config.truncateThreshold
|
|
1561
|
+
*
|
|
1562
|
+
* User configurable property, sets length threshold for actual and
|
|
1563
|
+
* expected values in assertion errors. If this threshold is exceeded, for
|
|
1564
|
+
* example for large data structures, the value is replaced with something
|
|
1565
|
+
* like `[ Array(3) ]` or `{ Object (prop1, prop2) }`.
|
|
1566
|
+
*
|
|
1567
|
+
* Set it to zero if you want to disable truncating altogether.
|
|
1568
|
+
*
|
|
1569
|
+
* This is especially userful when doing assertions on arrays: having this
|
|
1570
|
+
* set to a reasonable large value makes the failure messages readily
|
|
1571
|
+
* inspectable.
|
|
1572
|
+
*
|
|
1573
|
+
* chai.config.truncateThreshold = 0; // disable truncating
|
|
1574
|
+
*
|
|
1575
|
+
* @param {Number}
|
|
1576
|
+
* @api public
|
|
1577
|
+
*/
|
|
1578
|
+
truncateThreshold: 40,
|
|
1579
|
+
/**
|
|
1580
|
+
* ### config.useProxy
|
|
1581
|
+
*
|
|
1582
|
+
* User configurable property, defines if chai will use a Proxy to throw
|
|
1583
|
+
* an error when a non-existent property is read, which protects users
|
|
1584
|
+
* from typos when using property-based assertions.
|
|
1585
|
+
*
|
|
1586
|
+
* Set it to false if you want to disable this feature.
|
|
1587
|
+
*
|
|
1588
|
+
* chai.config.useProxy = false; // disable use of Proxy
|
|
1589
|
+
*
|
|
1590
|
+
* This feature is automatically disabled regardless of this config value
|
|
1591
|
+
* in environments that don't support proxies.
|
|
1592
|
+
*
|
|
1593
|
+
* @param {Boolean}
|
|
1594
|
+
* @api public
|
|
1595
|
+
*/
|
|
1596
|
+
useProxy: true,
|
|
1597
|
+
/**
|
|
1598
|
+
* ### config.proxyExcludedKeys
|
|
1599
|
+
*
|
|
1600
|
+
* User configurable property, defines which properties should be ignored
|
|
1601
|
+
* instead of throwing an error if they do not exist on the assertion.
|
|
1602
|
+
* This is only applied if the environment Chai is running in supports proxies and
|
|
1603
|
+
* if the `useProxy` configuration setting is enabled.
|
|
1604
|
+
* By default, `then` and `inspect` will not throw an error if they do not exist on the
|
|
1605
|
+
* assertion object because the `.inspect` property is read by `util.inspect` (for example, when
|
|
1606
|
+
* using `console.log` on the assertion object) and `.then` is necessary for promise type-checking.
|
|
1607
|
+
*
|
|
1608
|
+
* // By default these keys will not throw an error if they do not exist on the assertion object
|
|
1609
|
+
* chai.config.proxyExcludedKeys = ['then', 'inspect'];
|
|
1610
|
+
*
|
|
1611
|
+
* @param {Array}
|
|
1612
|
+
* @api public
|
|
1613
|
+
*/
|
|
1614
|
+
proxyExcludedKeys: ["then", "catch", "inspect", "toJSON"]
|
|
1615
|
+
};
|
|
1616
|
+
|
|
1617
|
+
// lib/chai/utils/inspect.js
|
|
1618
|
+
function inspect(obj, showHidden, depth, colors) {
|
|
1619
|
+
var options = {
|
|
1620
|
+
colors,
|
|
1621
|
+
depth: typeof depth === "undefined" ? 2 : depth,
|
|
1622
|
+
showHidden,
|
|
1623
|
+
truncate: config.truncateThreshold ? config.truncateThreshold : Infinity
|
|
1624
|
+
};
|
|
1625
|
+
return (0, import_loupe.inspect)(obj, options);
|
|
1626
|
+
}
|
|
1627
|
+
__name(inspect, "inspect");
|
|
1628
|
+
|
|
1629
|
+
// lib/chai/utils/objDisplay.js
|
|
1630
|
+
function objDisplay(obj) {
|
|
1631
|
+
var str = inspect(obj), type3 = Object.prototype.toString.call(obj);
|
|
1632
|
+
if (config.truncateThreshold && str.length >= config.truncateThreshold) {
|
|
1633
|
+
if (type3 === "[object Function]") {
|
|
1634
|
+
return !obj.name || obj.name === "" ? "[Function]" : "[Function: " + obj.name + "]";
|
|
1635
|
+
} else if (type3 === "[object Array]") {
|
|
1636
|
+
return "[ Array(" + obj.length + ") ]";
|
|
1637
|
+
} else if (type3 === "[object Object]") {
|
|
1638
|
+
var keys = Object.keys(obj), kstr = keys.length > 2 ? keys.splice(0, 2).join(", ") + ", ..." : keys.join(", ");
|
|
1639
|
+
return "{ Object (" + kstr + ") }";
|
|
1640
|
+
} else {
|
|
1641
|
+
return str;
|
|
1642
|
+
}
|
|
1643
|
+
} else {
|
|
1644
|
+
return str;
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
__name(objDisplay, "objDisplay");
|
|
1648
|
+
|
|
1649
|
+
// lib/chai/utils/getMessage.js
|
|
1650
|
+
function getMessage(obj, args) {
|
|
1651
|
+
var negate = flag(obj, "negate"), val = flag(obj, "object"), expected = args[3], actual = getActual(obj, args), msg = negate ? args[2] : args[1], flagMsg = flag(obj, "message");
|
|
1652
|
+
if (typeof msg === "function")
|
|
1653
|
+
msg = msg();
|
|
1654
|
+
msg = msg || "";
|
|
1655
|
+
msg = msg.replace(/#\{this\}/g, function() {
|
|
1656
|
+
return objDisplay(val);
|
|
1657
|
+
}).replace(/#\{act\}/g, function() {
|
|
1658
|
+
return objDisplay(actual);
|
|
1659
|
+
}).replace(/#\{exp\}/g, function() {
|
|
1660
|
+
return objDisplay(expected);
|
|
1661
|
+
});
|
|
1662
|
+
return flagMsg ? flagMsg + ": " + msg : msg;
|
|
1663
|
+
}
|
|
1664
|
+
__name(getMessage, "getMessage");
|
|
1665
|
+
|
|
1666
|
+
// lib/chai/utils/transferFlags.js
|
|
1667
|
+
function transferFlags(assertion, object, includeAll) {
|
|
1668
|
+
var flags = assertion.__flags || (assertion.__flags = /* @__PURE__ */ Object.create(null));
|
|
1669
|
+
if (!object.__flags) {
|
|
1670
|
+
object.__flags = /* @__PURE__ */ Object.create(null);
|
|
1671
|
+
}
|
|
1672
|
+
includeAll = arguments.length === 3 ? includeAll : true;
|
|
1673
|
+
for (var flag3 in flags) {
|
|
1674
|
+
if (includeAll || flag3 !== "object" && flag3 !== "ssfi" && flag3 !== "lockSsfi" && flag3 != "message") {
|
|
1675
|
+
object.__flags[flag3] = flags[flag3];
|
|
1676
|
+
}
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
__name(transferFlags, "transferFlags");
|
|
1680
|
+
|
|
1681
|
+
// lib/chai/utils/index.js
|
|
1682
|
+
var import_deep_eql = __toESM(require_deep_eql(), 1);
|
|
1683
|
+
var import_pathval = __toESM(require_pathval(), 1);
|
|
1684
|
+
|
|
1685
|
+
// lib/chai/assertion.js
|
|
1686
|
+
var import_assertion_error2 = __toESM(require_assertion_error(), 1);
|
|
1687
|
+
function Assertion(obj, msg, ssfi, lockSsfi) {
|
|
1688
|
+
flag(this, "ssfi", ssfi || Assertion);
|
|
1689
|
+
flag(this, "lockSsfi", lockSsfi);
|
|
1690
|
+
flag(this, "object", obj);
|
|
1691
|
+
flag(this, "message", msg);
|
|
1692
|
+
return proxify(this);
|
|
1693
|
+
}
|
|
1694
|
+
__name(Assertion, "Assertion");
|
|
1695
|
+
Object.defineProperty(Assertion, "includeStack", {
|
|
1696
|
+
get: function() {
|
|
1697
|
+
console.warn("Assertion.includeStack is deprecated, use chai.config.includeStack instead.");
|
|
1698
|
+
return config.includeStack;
|
|
1699
|
+
},
|
|
1700
|
+
set: function(value) {
|
|
1701
|
+
console.warn("Assertion.includeStack is deprecated, use chai.config.includeStack instead.");
|
|
1702
|
+
config.includeStack = value;
|
|
1703
|
+
}
|
|
1704
|
+
});
|
|
1705
|
+
Object.defineProperty(Assertion, "showDiff", {
|
|
1706
|
+
get: function() {
|
|
1707
|
+
console.warn("Assertion.showDiff is deprecated, use chai.config.showDiff instead.");
|
|
1708
|
+
return config.showDiff;
|
|
1709
|
+
},
|
|
1710
|
+
set: function(value) {
|
|
1711
|
+
console.warn("Assertion.showDiff is deprecated, use chai.config.showDiff instead.");
|
|
1712
|
+
config.showDiff = value;
|
|
1713
|
+
}
|
|
1714
|
+
});
|
|
1715
|
+
Assertion.addProperty = function(name, fn) {
|
|
1716
|
+
addProperty(this.prototype, name, fn);
|
|
1717
|
+
};
|
|
1718
|
+
Assertion.addMethod = function(name, fn) {
|
|
1719
|
+
addMethod(this.prototype, name, fn);
|
|
1720
|
+
};
|
|
1721
|
+
Assertion.addChainableMethod = function(name, fn, chainingBehavior) {
|
|
1722
|
+
addChainableMethod(this.prototype, name, fn, chainingBehavior);
|
|
1723
|
+
};
|
|
1724
|
+
Assertion.overwriteProperty = function(name, fn) {
|
|
1725
|
+
overwriteProperty(this.prototype, name, fn);
|
|
1726
|
+
};
|
|
1727
|
+
Assertion.overwriteMethod = function(name, fn) {
|
|
1728
|
+
overwriteMethod(this.prototype, name, fn);
|
|
1729
|
+
};
|
|
1730
|
+
Assertion.overwriteChainableMethod = function(name, fn, chainingBehavior) {
|
|
1731
|
+
overwriteChainableMethod(this.prototype, name, fn, chainingBehavior);
|
|
1732
|
+
};
|
|
1733
|
+
Assertion.prototype.assert = function(expr, msg, negateMsg, expected, _actual, showDiff) {
|
|
1734
|
+
var ok = test(this, arguments);
|
|
1735
|
+
if (false !== showDiff)
|
|
1736
|
+
showDiff = true;
|
|
1737
|
+
if (void 0 === expected && void 0 === _actual)
|
|
1738
|
+
showDiff = false;
|
|
1739
|
+
if (true !== config.showDiff)
|
|
1740
|
+
showDiff = false;
|
|
1741
|
+
if (!ok) {
|
|
1742
|
+
msg = getMessage(this, arguments);
|
|
1743
|
+
var actual = getActual(this, arguments);
|
|
1744
|
+
var assertionErrorObjectProperties = {
|
|
1745
|
+
actual,
|
|
1746
|
+
expected,
|
|
1747
|
+
showDiff
|
|
1748
|
+
};
|
|
1749
|
+
var operator = getOperator(this, arguments);
|
|
1750
|
+
if (operator) {
|
|
1751
|
+
assertionErrorObjectProperties.operator = operator;
|
|
1752
|
+
}
|
|
1753
|
+
throw new import_assertion_error2.default(
|
|
1754
|
+
msg,
|
|
1755
|
+
assertionErrorObjectProperties,
|
|
1756
|
+
config.includeStack ? this.assert : flag(this, "ssfi")
|
|
1757
|
+
);
|
|
1758
|
+
}
|
|
1759
|
+
};
|
|
1760
|
+
Object.defineProperty(
|
|
1761
|
+
Assertion.prototype,
|
|
1762
|
+
"_obj",
|
|
1763
|
+
{
|
|
1764
|
+
get: function() {
|
|
1765
|
+
return flag(this, "object");
|
|
1766
|
+
},
|
|
1767
|
+
set: function(val) {
|
|
1768
|
+
flag(this, "object", val);
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1771
|
+
);
|
|
1772
|
+
|
|
1773
|
+
// lib/chai/utils/isProxyEnabled.js
|
|
1774
|
+
function isProxyEnabled() {
|
|
1775
|
+
return config.useProxy && typeof Proxy !== "undefined" && typeof Reflect !== "undefined";
|
|
1776
|
+
}
|
|
1777
|
+
__name(isProxyEnabled, "isProxyEnabled");
|
|
1778
|
+
|
|
1779
|
+
// lib/chai/utils/addProperty.js
|
|
1780
|
+
function addProperty(ctx, name, getter) {
|
|
1781
|
+
getter = getter === void 0 ? function() {
|
|
1782
|
+
} : getter;
|
|
1783
|
+
Object.defineProperty(
|
|
1784
|
+
ctx,
|
|
1785
|
+
name,
|
|
1786
|
+
{
|
|
1787
|
+
get: /* @__PURE__ */ __name(function propertyGetter() {
|
|
1788
|
+
if (!isProxyEnabled() && !flag(this, "lockSsfi")) {
|
|
1789
|
+
flag(this, "ssfi", propertyGetter);
|
|
1790
|
+
}
|
|
1791
|
+
var result = getter.call(this);
|
|
1792
|
+
if (result !== void 0)
|
|
1793
|
+
return result;
|
|
1794
|
+
var newAssertion = new Assertion();
|
|
1795
|
+
transferFlags(this, newAssertion);
|
|
1796
|
+
return newAssertion;
|
|
1797
|
+
}, "propertyGetter"),
|
|
1798
|
+
configurable: true
|
|
1799
|
+
}
|
|
1800
|
+
);
|
|
1801
|
+
}
|
|
1802
|
+
__name(addProperty, "addProperty");
|
|
1803
|
+
|
|
1804
|
+
// lib/chai/utils/addLengthGuard.js
|
|
1805
|
+
var fnLengthDesc = Object.getOwnPropertyDescriptor(function() {
|
|
1806
|
+
}, "length");
|
|
1807
|
+
function addLengthGuard(fn, assertionName, isChainable) {
|
|
1808
|
+
if (!fnLengthDesc.configurable)
|
|
1809
|
+
return fn;
|
|
1810
|
+
Object.defineProperty(fn, "length", {
|
|
1811
|
+
get: function() {
|
|
1812
|
+
if (isChainable) {
|
|
1813
|
+
throw Error("Invalid Chai property: " + assertionName + '.length. Due to a compatibility issue, "length" cannot directly follow "' + assertionName + '". Use "' + assertionName + '.lengthOf" instead.');
|
|
1814
|
+
}
|
|
1815
|
+
throw Error("Invalid Chai property: " + assertionName + '.length. See docs for proper usage of "' + assertionName + '".');
|
|
1816
|
+
}
|
|
1817
|
+
});
|
|
1818
|
+
return fn;
|
|
1819
|
+
}
|
|
1820
|
+
__name(addLengthGuard, "addLengthGuard");
|
|
1821
|
+
|
|
1822
|
+
// lib/chai/utils/getProperties.js
|
|
1823
|
+
function getProperties(object) {
|
|
1824
|
+
var result = Object.getOwnPropertyNames(object);
|
|
1825
|
+
function addProperty2(property) {
|
|
1826
|
+
if (result.indexOf(property) === -1) {
|
|
1827
|
+
result.push(property);
|
|
1828
|
+
}
|
|
1829
|
+
}
|
|
1830
|
+
__name(addProperty2, "addProperty");
|
|
1831
|
+
var proto = Object.getPrototypeOf(object);
|
|
1832
|
+
while (proto !== null) {
|
|
1833
|
+
Object.getOwnPropertyNames(proto).forEach(addProperty2);
|
|
1834
|
+
proto = Object.getPrototypeOf(proto);
|
|
1835
|
+
}
|
|
1836
|
+
return result;
|
|
1837
|
+
}
|
|
1838
|
+
__name(getProperties, "getProperties");
|
|
1839
|
+
|
|
1840
|
+
// lib/chai/utils/proxify.js
|
|
1841
|
+
var builtins = ["__flags", "__methods", "_obj", "assert"];
|
|
1842
|
+
function proxify(obj, nonChainableMethodName) {
|
|
1843
|
+
if (!isProxyEnabled())
|
|
1844
|
+
return obj;
|
|
1845
|
+
return new Proxy(obj, {
|
|
1846
|
+
get: /* @__PURE__ */ __name(function proxyGetter(target, property) {
|
|
1847
|
+
if (typeof property === "string" && config.proxyExcludedKeys.indexOf(property) === -1 && !Reflect.has(target, property)) {
|
|
1848
|
+
if (nonChainableMethodName) {
|
|
1849
|
+
throw Error("Invalid Chai property: " + nonChainableMethodName + "." + property + '. See docs for proper usage of "' + nonChainableMethodName + '".');
|
|
1850
|
+
}
|
|
1851
|
+
var suggestion = null;
|
|
1852
|
+
var suggestionDistance = 4;
|
|
1853
|
+
getProperties(target).forEach(function(prop) {
|
|
1854
|
+
if (!Object.prototype.hasOwnProperty(prop) && builtins.indexOf(prop) === -1) {
|
|
1855
|
+
var dist = stringDistanceCapped(
|
|
1856
|
+
property,
|
|
1857
|
+
prop,
|
|
1858
|
+
suggestionDistance
|
|
1859
|
+
);
|
|
1860
|
+
if (dist < suggestionDistance) {
|
|
1861
|
+
suggestion = prop;
|
|
1862
|
+
suggestionDistance = dist;
|
|
1863
|
+
}
|
|
1864
|
+
}
|
|
1865
|
+
});
|
|
1866
|
+
if (suggestion !== null) {
|
|
1867
|
+
throw Error("Invalid Chai property: " + property + '. Did you mean "' + suggestion + '"?');
|
|
1868
|
+
} else {
|
|
1869
|
+
throw Error("Invalid Chai property: " + property);
|
|
1870
|
+
}
|
|
1871
|
+
}
|
|
1872
|
+
if (builtins.indexOf(property) === -1 && !flag(target, "lockSsfi")) {
|
|
1873
|
+
flag(target, "ssfi", proxyGetter);
|
|
1874
|
+
}
|
|
1875
|
+
return Reflect.get(target, property);
|
|
1876
|
+
}, "proxyGetter")
|
|
1877
|
+
});
|
|
1878
|
+
}
|
|
1879
|
+
__name(proxify, "proxify");
|
|
1880
|
+
function stringDistanceCapped(strA, strB, cap) {
|
|
1881
|
+
if (Math.abs(strA.length - strB.length) >= cap) {
|
|
1882
|
+
return cap;
|
|
1883
|
+
}
|
|
1884
|
+
var memo = [];
|
|
1885
|
+
for (var i = 0; i <= strA.length; i++) {
|
|
1886
|
+
memo[i] = Array(strB.length + 1).fill(0);
|
|
1887
|
+
memo[i][0] = i;
|
|
1888
|
+
}
|
|
1889
|
+
for (var j = 0; j < strB.length; j++) {
|
|
1890
|
+
memo[0][j] = j;
|
|
1891
|
+
}
|
|
1892
|
+
for (var i = 1; i <= strA.length; i++) {
|
|
1893
|
+
var ch = strA.charCodeAt(i - 1);
|
|
1894
|
+
for (var j = 1; j <= strB.length; j++) {
|
|
1895
|
+
if (Math.abs(i - j) >= cap) {
|
|
1896
|
+
memo[i][j] = cap;
|
|
1897
|
+
continue;
|
|
1898
|
+
}
|
|
1899
|
+
memo[i][j] = Math.min(
|
|
1900
|
+
memo[i - 1][j] + 1,
|
|
1901
|
+
memo[i][j - 1] + 1,
|
|
1902
|
+
memo[i - 1][j - 1] + (ch === strB.charCodeAt(j - 1) ? 0 : 1)
|
|
1903
|
+
);
|
|
1904
|
+
}
|
|
1905
|
+
}
|
|
1906
|
+
return memo[strA.length][strB.length];
|
|
1907
|
+
}
|
|
1908
|
+
__name(stringDistanceCapped, "stringDistanceCapped");
|
|
1909
|
+
|
|
1910
|
+
// lib/chai/utils/addMethod.js
|
|
1911
|
+
function addMethod(ctx, name, method) {
|
|
1912
|
+
var methodWrapper = /* @__PURE__ */ __name(function() {
|
|
1913
|
+
if (!flag(this, "lockSsfi")) {
|
|
1914
|
+
flag(this, "ssfi", methodWrapper);
|
|
1915
|
+
}
|
|
1916
|
+
var result = method.apply(this, arguments);
|
|
1917
|
+
if (result !== void 0)
|
|
1918
|
+
return result;
|
|
1919
|
+
var newAssertion = new Assertion();
|
|
1920
|
+
transferFlags(this, newAssertion);
|
|
1921
|
+
return newAssertion;
|
|
1922
|
+
}, "methodWrapper");
|
|
1923
|
+
addLengthGuard(methodWrapper, name, false);
|
|
1924
|
+
ctx[name] = proxify(methodWrapper, name);
|
|
1925
|
+
}
|
|
1926
|
+
__name(addMethod, "addMethod");
|
|
1927
|
+
|
|
1928
|
+
// lib/chai/utils/overwriteProperty.js
|
|
1929
|
+
function overwriteProperty(ctx, name, getter) {
|
|
1930
|
+
var _get = Object.getOwnPropertyDescriptor(ctx, name), _super = /* @__PURE__ */ __name(function() {
|
|
1931
|
+
}, "_super");
|
|
1932
|
+
if (_get && "function" === typeof _get.get)
|
|
1933
|
+
_super = _get.get;
|
|
1934
|
+
Object.defineProperty(
|
|
1935
|
+
ctx,
|
|
1936
|
+
name,
|
|
1937
|
+
{
|
|
1938
|
+
get: /* @__PURE__ */ __name(function overwritingPropertyGetter() {
|
|
1939
|
+
if (!isProxyEnabled() && !flag(this, "lockSsfi")) {
|
|
1940
|
+
flag(this, "ssfi", overwritingPropertyGetter);
|
|
1941
|
+
}
|
|
1942
|
+
var origLockSsfi = flag(this, "lockSsfi");
|
|
1943
|
+
flag(this, "lockSsfi", true);
|
|
1944
|
+
var result = getter(_super).call(this);
|
|
1945
|
+
flag(this, "lockSsfi", origLockSsfi);
|
|
1946
|
+
if (result !== void 0) {
|
|
1947
|
+
return result;
|
|
1948
|
+
}
|
|
1949
|
+
var newAssertion = new Assertion();
|
|
1950
|
+
transferFlags(this, newAssertion);
|
|
1951
|
+
return newAssertion;
|
|
1952
|
+
}, "overwritingPropertyGetter"),
|
|
1953
|
+
configurable: true
|
|
1954
|
+
}
|
|
1955
|
+
);
|
|
1956
|
+
}
|
|
1957
|
+
__name(overwriteProperty, "overwriteProperty");
|
|
1958
|
+
|
|
1959
|
+
// lib/chai/utils/overwriteMethod.js
|
|
1960
|
+
function overwriteMethod(ctx, name, method) {
|
|
1961
|
+
var _method = ctx[name], _super = /* @__PURE__ */ __name(function() {
|
|
1962
|
+
throw new Error(name + " is not a function");
|
|
1963
|
+
}, "_super");
|
|
1964
|
+
if (_method && "function" === typeof _method)
|
|
1965
|
+
_super = _method;
|
|
1966
|
+
var overwritingMethodWrapper = /* @__PURE__ */ __name(function() {
|
|
1967
|
+
if (!flag(this, "lockSsfi")) {
|
|
1968
|
+
flag(this, "ssfi", overwritingMethodWrapper);
|
|
1969
|
+
}
|
|
1970
|
+
var origLockSsfi = flag(this, "lockSsfi");
|
|
1971
|
+
flag(this, "lockSsfi", true);
|
|
1972
|
+
var result = method(_super).apply(this, arguments);
|
|
1973
|
+
flag(this, "lockSsfi", origLockSsfi);
|
|
1974
|
+
if (result !== void 0) {
|
|
1975
|
+
return result;
|
|
1976
|
+
}
|
|
1977
|
+
var newAssertion = new Assertion();
|
|
1978
|
+
transferFlags(this, newAssertion);
|
|
1979
|
+
return newAssertion;
|
|
1980
|
+
}, "overwritingMethodWrapper");
|
|
1981
|
+
addLengthGuard(overwritingMethodWrapper, name, false);
|
|
1982
|
+
ctx[name] = proxify(overwritingMethodWrapper, name);
|
|
1983
|
+
}
|
|
1984
|
+
__name(overwriteMethod, "overwriteMethod");
|
|
1985
|
+
|
|
1986
|
+
// lib/chai/utils/addChainableMethod.js
|
|
1987
|
+
var canSetPrototype = typeof Object.setPrototypeOf === "function";
|
|
1988
|
+
var testFn = /* @__PURE__ */ __name(function() {
|
|
1989
|
+
}, "testFn");
|
|
1990
|
+
var excludeNames = Object.getOwnPropertyNames(testFn).filter(function(name) {
|
|
1991
|
+
var propDesc = Object.getOwnPropertyDescriptor(testFn, name);
|
|
1992
|
+
if (typeof propDesc !== "object")
|
|
1993
|
+
return true;
|
|
1994
|
+
return !propDesc.configurable;
|
|
1995
|
+
});
|
|
1996
|
+
var call = Function.prototype.call;
|
|
1997
|
+
var apply = Function.prototype.apply;
|
|
1998
|
+
function addChainableMethod(ctx, name, method, chainingBehavior) {
|
|
1999
|
+
if (typeof chainingBehavior !== "function") {
|
|
2000
|
+
chainingBehavior = /* @__PURE__ */ __name(function() {
|
|
2001
|
+
}, "chainingBehavior");
|
|
2002
|
+
}
|
|
2003
|
+
var chainableBehavior = {
|
|
2004
|
+
method,
|
|
2005
|
+
chainingBehavior
|
|
2006
|
+
};
|
|
2007
|
+
if (!ctx.__methods) {
|
|
2008
|
+
ctx.__methods = {};
|
|
2009
|
+
}
|
|
2010
|
+
ctx.__methods[name] = chainableBehavior;
|
|
2011
|
+
Object.defineProperty(
|
|
2012
|
+
ctx,
|
|
2013
|
+
name,
|
|
2014
|
+
{
|
|
2015
|
+
get: /* @__PURE__ */ __name(function chainableMethodGetter() {
|
|
2016
|
+
chainableBehavior.chainingBehavior.call(this);
|
|
2017
|
+
var chainableMethodWrapper = /* @__PURE__ */ __name(function() {
|
|
2018
|
+
if (!flag(this, "lockSsfi")) {
|
|
2019
|
+
flag(this, "ssfi", chainableMethodWrapper);
|
|
2020
|
+
}
|
|
2021
|
+
var result = chainableBehavior.method.apply(this, arguments);
|
|
2022
|
+
if (result !== void 0) {
|
|
2023
|
+
return result;
|
|
2024
|
+
}
|
|
2025
|
+
var newAssertion = new Assertion();
|
|
2026
|
+
transferFlags(this, newAssertion);
|
|
2027
|
+
return newAssertion;
|
|
2028
|
+
}, "chainableMethodWrapper");
|
|
2029
|
+
addLengthGuard(chainableMethodWrapper, name, true);
|
|
2030
|
+
if (canSetPrototype) {
|
|
2031
|
+
var prototype = Object.create(this);
|
|
2032
|
+
prototype.call = call;
|
|
2033
|
+
prototype.apply = apply;
|
|
2034
|
+
Object.setPrototypeOf(chainableMethodWrapper, prototype);
|
|
2035
|
+
} else {
|
|
2036
|
+
var asserterNames = Object.getOwnPropertyNames(ctx);
|
|
2037
|
+
asserterNames.forEach(function(asserterName) {
|
|
2038
|
+
if (excludeNames.indexOf(asserterName) !== -1) {
|
|
2039
|
+
return;
|
|
2040
|
+
}
|
|
2041
|
+
var pd = Object.getOwnPropertyDescriptor(ctx, asserterName);
|
|
2042
|
+
Object.defineProperty(chainableMethodWrapper, asserterName, pd);
|
|
2043
|
+
});
|
|
2044
|
+
}
|
|
2045
|
+
transferFlags(this, chainableMethodWrapper);
|
|
2046
|
+
return proxify(chainableMethodWrapper);
|
|
2047
|
+
}, "chainableMethodGetter"),
|
|
2048
|
+
configurable: true
|
|
2049
|
+
}
|
|
2050
|
+
);
|
|
2051
|
+
}
|
|
2052
|
+
__name(addChainableMethod, "addChainableMethod");
|
|
2053
|
+
|
|
2054
|
+
// lib/chai/utils/overwriteChainableMethod.js
|
|
2055
|
+
function overwriteChainableMethod(ctx, name, method, chainingBehavior) {
|
|
2056
|
+
var chainableBehavior = ctx.__methods[name];
|
|
2057
|
+
var _chainingBehavior = chainableBehavior.chainingBehavior;
|
|
2058
|
+
chainableBehavior.chainingBehavior = /* @__PURE__ */ __name(function overwritingChainableMethodGetter() {
|
|
2059
|
+
var result = chainingBehavior(_chainingBehavior).call(this);
|
|
2060
|
+
if (result !== void 0) {
|
|
2061
|
+
return result;
|
|
2062
|
+
}
|
|
2063
|
+
var newAssertion = new Assertion();
|
|
2064
|
+
transferFlags(this, newAssertion);
|
|
2065
|
+
return newAssertion;
|
|
2066
|
+
}, "overwritingChainableMethodGetter");
|
|
2067
|
+
var _method = chainableBehavior.method;
|
|
2068
|
+
chainableBehavior.method = /* @__PURE__ */ __name(function overwritingChainableMethodWrapper() {
|
|
2069
|
+
var result = method(_method).apply(this, arguments);
|
|
2070
|
+
if (result !== void 0) {
|
|
2071
|
+
return result;
|
|
2072
|
+
}
|
|
2073
|
+
var newAssertion = new Assertion();
|
|
2074
|
+
transferFlags(this, newAssertion);
|
|
2075
|
+
return newAssertion;
|
|
2076
|
+
}, "overwritingChainableMethodWrapper");
|
|
2077
|
+
}
|
|
2078
|
+
__name(overwriteChainableMethod, "overwriteChainableMethod");
|
|
2079
|
+
|
|
2080
|
+
// lib/chai/utils/compareByInspect.js
|
|
2081
|
+
function compareByInspect(a, b) {
|
|
2082
|
+
return inspect(a) < inspect(b) ? -1 : 1;
|
|
2083
|
+
}
|
|
2084
|
+
__name(compareByInspect, "compareByInspect");
|
|
2085
|
+
|
|
2086
|
+
// lib/chai/utils/getOwnEnumerablePropertySymbols.js
|
|
2087
|
+
function getOwnEnumerablePropertySymbols(obj) {
|
|
2088
|
+
if (typeof Object.getOwnPropertySymbols !== "function")
|
|
2089
|
+
return [];
|
|
2090
|
+
return Object.getOwnPropertySymbols(obj).filter(function(sym) {
|
|
2091
|
+
return Object.getOwnPropertyDescriptor(obj, sym).enumerable;
|
|
2092
|
+
});
|
|
2093
|
+
}
|
|
2094
|
+
__name(getOwnEnumerablePropertySymbols, "getOwnEnumerablePropertySymbols");
|
|
2095
|
+
|
|
2096
|
+
// lib/chai/utils/getOwnEnumerableProperties.js
|
|
2097
|
+
function getOwnEnumerableProperties(obj) {
|
|
2098
|
+
return Object.keys(obj).concat(getOwnEnumerablePropertySymbols(obj));
|
|
2099
|
+
}
|
|
2100
|
+
__name(getOwnEnumerableProperties, "getOwnEnumerableProperties");
|
|
2101
|
+
|
|
2102
|
+
// lib/chai/utils/isNaN.js
|
|
2103
|
+
function _isNaN(value) {
|
|
2104
|
+
return value !== value;
|
|
2105
|
+
}
|
|
2106
|
+
__name(_isNaN, "_isNaN");
|
|
2107
|
+
var isNaN = Number.isNaN || _isNaN;
|
|
2108
|
+
|
|
2109
|
+
// lib/chai/utils/getOperator.js
|
|
2110
|
+
var import_type_detect2 = __toESM(require_type_detect(), 1);
|
|
2111
|
+
function isObjectType(obj) {
|
|
2112
|
+
var objectType = (0, import_type_detect2.default)(obj);
|
|
2113
|
+
var objectTypes = ["Array", "Object", "function"];
|
|
2114
|
+
return objectTypes.indexOf(objectType) !== -1;
|
|
2115
|
+
}
|
|
2116
|
+
__name(isObjectType, "isObjectType");
|
|
2117
|
+
function getOperator(obj, args) {
|
|
2118
|
+
var operator = flag(obj, "operator");
|
|
2119
|
+
var negate = flag(obj, "negate");
|
|
2120
|
+
var expected = args[3];
|
|
2121
|
+
var msg = negate ? args[2] : args[1];
|
|
2122
|
+
if (operator) {
|
|
2123
|
+
return operator;
|
|
2124
|
+
}
|
|
2125
|
+
if (typeof msg === "function")
|
|
2126
|
+
msg = msg();
|
|
2127
|
+
msg = msg || "";
|
|
2128
|
+
if (!msg) {
|
|
2129
|
+
return void 0;
|
|
2130
|
+
}
|
|
2131
|
+
if (/\shave\s/.test(msg)) {
|
|
2132
|
+
return void 0;
|
|
2133
|
+
}
|
|
2134
|
+
var isObject = isObjectType(expected);
|
|
2135
|
+
if (/\snot\s/.test(msg)) {
|
|
2136
|
+
return isObject ? "notDeepStrictEqual" : "notStrictEqual";
|
|
2137
|
+
}
|
|
2138
|
+
return isObject ? "deepStrictEqual" : "strictEqual";
|
|
2139
|
+
}
|
|
2140
|
+
__name(getOperator, "getOperator");
|
|
2141
|
+
|
|
2142
|
+
// lib/chai/utils/index.js
|
|
2143
|
+
function getName(fn) {
|
|
2144
|
+
return fn.name;
|
|
2145
|
+
}
|
|
2146
|
+
__name(getName, "getName");
|
|
2147
|
+
|
|
2148
|
+
// lib/chai.js
|
|
2149
|
+
var import_assertion_error7 = __toESM(require_assertion_error(), 1);
|
|
2150
|
+
|
|
2151
|
+
// lib/chai/core/assertions.js
|
|
2152
|
+
var import_assertion_error3 = __toESM(require_assertion_error(), 1);
|
|
2153
|
+
var { flag: flag2 } = utils_exports;
|
|
2154
|
+
[
|
|
2155
|
+
"to",
|
|
2156
|
+
"be",
|
|
2157
|
+
"been",
|
|
2158
|
+
"is",
|
|
2159
|
+
"and",
|
|
2160
|
+
"has",
|
|
2161
|
+
"have",
|
|
2162
|
+
"with",
|
|
2163
|
+
"that",
|
|
2164
|
+
"which",
|
|
2165
|
+
"at",
|
|
2166
|
+
"of",
|
|
2167
|
+
"same",
|
|
2168
|
+
"but",
|
|
2169
|
+
"does",
|
|
2170
|
+
"still",
|
|
2171
|
+
"also"
|
|
2172
|
+
].forEach(function(chain) {
|
|
2173
|
+
Assertion.addProperty(chain);
|
|
2174
|
+
});
|
|
2175
|
+
Assertion.addProperty("not", function() {
|
|
2176
|
+
flag2(this, "negate", true);
|
|
2177
|
+
});
|
|
2178
|
+
Assertion.addProperty("deep", function() {
|
|
2179
|
+
flag2(this, "deep", true);
|
|
2180
|
+
});
|
|
2181
|
+
Assertion.addProperty("nested", function() {
|
|
2182
|
+
flag2(this, "nested", true);
|
|
2183
|
+
});
|
|
2184
|
+
Assertion.addProperty("own", function() {
|
|
2185
|
+
flag2(this, "own", true);
|
|
2186
|
+
});
|
|
2187
|
+
Assertion.addProperty("ordered", function() {
|
|
2188
|
+
flag2(this, "ordered", true);
|
|
2189
|
+
});
|
|
2190
|
+
Assertion.addProperty("any", function() {
|
|
2191
|
+
flag2(this, "any", true);
|
|
2192
|
+
flag2(this, "all", false);
|
|
2193
|
+
});
|
|
2194
|
+
Assertion.addProperty("all", function() {
|
|
2195
|
+
flag2(this, "all", true);
|
|
2196
|
+
flag2(this, "any", false);
|
|
2197
|
+
});
|
|
2198
|
+
function an(type3, msg) {
|
|
2199
|
+
if (msg)
|
|
2200
|
+
flag2(this, "message", msg);
|
|
2201
|
+
type3 = type3.toLowerCase();
|
|
2202
|
+
var obj = flag2(this, "object"), article = ~["a", "e", "i", "o", "u"].indexOf(type3.charAt(0)) ? "an " : "a ";
|
|
2203
|
+
this.assert(
|
|
2204
|
+
type3 === import_type_detect3.default(obj).toLowerCase(),
|
|
2205
|
+
"expected #{this} to be " + article + type3,
|
|
2206
|
+
"expected #{this} not to be " + article + type3
|
|
2207
|
+
);
|
|
2208
|
+
}
|
|
2209
|
+
__name(an, "an");
|
|
2210
|
+
Assertion.addChainableMethod("an", an);
|
|
2211
|
+
Assertion.addChainableMethod("a", an);
|
|
2212
|
+
function SameValueZero(a, b) {
|
|
2213
|
+
return isNaN(a) && isNaN(b) || a === b;
|
|
2214
|
+
}
|
|
2215
|
+
__name(SameValueZero, "SameValueZero");
|
|
2216
|
+
function includeChainingBehavior() {
|
|
2217
|
+
flag2(this, "contains", true);
|
|
2218
|
+
}
|
|
2219
|
+
__name(includeChainingBehavior, "includeChainingBehavior");
|
|
2220
|
+
function include(val, msg) {
|
|
2221
|
+
if (msg)
|
|
2222
|
+
flag2(this, "message", msg);
|
|
2223
|
+
var obj = flag2(this, "object"), objType = import_type_detect3.default(obj).toLowerCase(), flagMsg = flag2(this, "message"), negate = flag2(this, "negate"), ssfi = flag2(this, "ssfi"), isDeep = flag2(this, "deep"), descriptor = isDeep ? "deep " : "";
|
|
2224
|
+
flagMsg = flagMsg ? flagMsg + ": " : "";
|
|
2225
|
+
var included = false;
|
|
2226
|
+
switch (objType) {
|
|
2227
|
+
case "string":
|
|
2228
|
+
included = obj.indexOf(val) !== -1;
|
|
2229
|
+
break;
|
|
2230
|
+
case "weakset":
|
|
2231
|
+
if (isDeep) {
|
|
2232
|
+
throw new import_assertion_error3.default(
|
|
2233
|
+
flagMsg + "unable to use .deep.include with WeakSet",
|
|
2234
|
+
void 0,
|
|
2235
|
+
ssfi
|
|
2236
|
+
);
|
|
2237
|
+
}
|
|
2238
|
+
included = obj.has(val);
|
|
2239
|
+
break;
|
|
2240
|
+
case "map":
|
|
2241
|
+
var isEql = isDeep ? import_deep_eql.default : SameValueZero;
|
|
2242
|
+
obj.forEach(function(item) {
|
|
2243
|
+
included = included || isEql(item, val);
|
|
2244
|
+
});
|
|
2245
|
+
break;
|
|
2246
|
+
case "set":
|
|
2247
|
+
if (isDeep) {
|
|
2248
|
+
obj.forEach(function(item) {
|
|
2249
|
+
included = included || import_deep_eql.default(item, val);
|
|
2250
|
+
});
|
|
2251
|
+
} else {
|
|
2252
|
+
included = obj.has(val);
|
|
2253
|
+
}
|
|
2254
|
+
break;
|
|
2255
|
+
case "array":
|
|
2256
|
+
if (isDeep) {
|
|
2257
|
+
included = obj.some(function(item) {
|
|
2258
|
+
return import_deep_eql.default(item, val);
|
|
2259
|
+
});
|
|
2260
|
+
} else {
|
|
2261
|
+
included = obj.indexOf(val) !== -1;
|
|
2262
|
+
}
|
|
2263
|
+
break;
|
|
2264
|
+
default:
|
|
2265
|
+
if (val !== Object(val)) {
|
|
2266
|
+
throw new import_assertion_error3.default(
|
|
2267
|
+
flagMsg + "the given combination of arguments (" + objType + " and " + import_type_detect3.default(val).toLowerCase() + ") is invalid for this assertion. You can use an array, a map, an object, a set, a string, or a weakset instead of a " + import_type_detect3.default(val).toLowerCase(),
|
|
2268
|
+
void 0,
|
|
2269
|
+
ssfi
|
|
2270
|
+
);
|
|
2271
|
+
}
|
|
2272
|
+
var props = Object.keys(val), firstErr = null, numErrs = 0;
|
|
2273
|
+
props.forEach(function(prop) {
|
|
2274
|
+
var propAssertion = new Assertion(obj);
|
|
2275
|
+
transferFlags(this, propAssertion, true);
|
|
2276
|
+
flag2(propAssertion, "lockSsfi", true);
|
|
2277
|
+
if (!negate || props.length === 1) {
|
|
2278
|
+
propAssertion.property(prop, val[prop]);
|
|
2279
|
+
return;
|
|
2280
|
+
}
|
|
2281
|
+
try {
|
|
2282
|
+
propAssertion.property(prop, val[prop]);
|
|
2283
|
+
} catch (err) {
|
|
2284
|
+
if (!checkError.compatibleConstructor(err, import_assertion_error3.default)) {
|
|
2285
|
+
throw err;
|
|
2286
|
+
}
|
|
2287
|
+
if (firstErr === null)
|
|
2288
|
+
firstErr = err;
|
|
2289
|
+
numErrs++;
|
|
2290
|
+
}
|
|
2291
|
+
}, this);
|
|
2292
|
+
if (negate && props.length > 1 && numErrs === props.length) {
|
|
2293
|
+
throw firstErr;
|
|
2294
|
+
}
|
|
2295
|
+
return;
|
|
2296
|
+
}
|
|
2297
|
+
this.assert(
|
|
2298
|
+
included,
|
|
2299
|
+
"expected #{this} to " + descriptor + "include " + inspect(val),
|
|
2300
|
+
"expected #{this} to not " + descriptor + "include " + inspect(val)
|
|
2301
|
+
);
|
|
2302
|
+
}
|
|
2303
|
+
__name(include, "include");
|
|
2304
|
+
Assertion.addChainableMethod("include", include, includeChainingBehavior);
|
|
2305
|
+
Assertion.addChainableMethod("contain", include, includeChainingBehavior);
|
|
2306
|
+
Assertion.addChainableMethod("contains", include, includeChainingBehavior);
|
|
2307
|
+
Assertion.addChainableMethod("includes", include, includeChainingBehavior);
|
|
2308
|
+
Assertion.addProperty("ok", function() {
|
|
2309
|
+
this.assert(
|
|
2310
|
+
flag2(this, "object"),
|
|
2311
|
+
"expected #{this} to be truthy",
|
|
2312
|
+
"expected #{this} to be falsy"
|
|
2313
|
+
);
|
|
2314
|
+
});
|
|
2315
|
+
Assertion.addProperty("true", function() {
|
|
2316
|
+
this.assert(
|
|
2317
|
+
true === flag2(this, "object"),
|
|
2318
|
+
"expected #{this} to be true",
|
|
2319
|
+
"expected #{this} to be false",
|
|
2320
|
+
flag2(this, "negate") ? false : true
|
|
2321
|
+
);
|
|
2322
|
+
});
|
|
2323
|
+
Assertion.addProperty("false", function() {
|
|
2324
|
+
this.assert(
|
|
2325
|
+
false === flag2(this, "object"),
|
|
2326
|
+
"expected #{this} to be false",
|
|
2327
|
+
"expected #{this} to be true",
|
|
2328
|
+
flag2(this, "negate") ? true : false
|
|
2329
|
+
);
|
|
2330
|
+
});
|
|
2331
|
+
Assertion.addProperty("null", function() {
|
|
2332
|
+
this.assert(
|
|
2333
|
+
null === flag2(this, "object"),
|
|
2334
|
+
"expected #{this} to be null",
|
|
2335
|
+
"expected #{this} not to be null"
|
|
2336
|
+
);
|
|
2337
|
+
});
|
|
2338
|
+
Assertion.addProperty("undefined", function() {
|
|
2339
|
+
this.assert(
|
|
2340
|
+
void 0 === flag2(this, "object"),
|
|
2341
|
+
"expected #{this} to be undefined",
|
|
2342
|
+
"expected #{this} not to be undefined"
|
|
2343
|
+
);
|
|
2344
|
+
});
|
|
2345
|
+
Assertion.addProperty("NaN", function() {
|
|
2346
|
+
this.assert(
|
|
2347
|
+
isNaN(flag2(this, "object")),
|
|
2348
|
+
"expected #{this} to be NaN",
|
|
2349
|
+
"expected #{this} not to be NaN"
|
|
2350
|
+
);
|
|
2351
|
+
});
|
|
2352
|
+
function assertExist() {
|
|
2353
|
+
var val = flag2(this, "object");
|
|
2354
|
+
this.assert(
|
|
2355
|
+
val !== null && val !== void 0,
|
|
2356
|
+
"expected #{this} to exist",
|
|
2357
|
+
"expected #{this} to not exist"
|
|
2358
|
+
);
|
|
2359
|
+
}
|
|
2360
|
+
__name(assertExist, "assertExist");
|
|
2361
|
+
Assertion.addProperty("exist", assertExist);
|
|
2362
|
+
Assertion.addProperty("exists", assertExist);
|
|
2363
|
+
Assertion.addProperty("empty", function() {
|
|
2364
|
+
var val = flag2(this, "object"), ssfi = flag2(this, "ssfi"), flagMsg = flag2(this, "message"), itemsCount;
|
|
2365
|
+
flagMsg = flagMsg ? flagMsg + ": " : "";
|
|
2366
|
+
switch (import_type_detect3.default(val).toLowerCase()) {
|
|
2367
|
+
case "array":
|
|
2368
|
+
case "string":
|
|
2369
|
+
itemsCount = val.length;
|
|
2370
|
+
break;
|
|
2371
|
+
case "map":
|
|
2372
|
+
case "set":
|
|
2373
|
+
itemsCount = val.size;
|
|
2374
|
+
break;
|
|
2375
|
+
case "weakmap":
|
|
2376
|
+
case "weakset":
|
|
2377
|
+
throw new import_assertion_error3.default(
|
|
2378
|
+
flagMsg + ".empty was passed a weak collection",
|
|
2379
|
+
void 0,
|
|
2380
|
+
ssfi
|
|
2381
|
+
);
|
|
2382
|
+
case "function":
|
|
2383
|
+
var msg = flagMsg + ".empty was passed a function " + getName(val);
|
|
2384
|
+
throw new import_assertion_error3.default(msg.trim(), void 0, ssfi);
|
|
2385
|
+
default:
|
|
2386
|
+
if (val !== Object(val)) {
|
|
2387
|
+
throw new import_assertion_error3.default(
|
|
2388
|
+
flagMsg + ".empty was passed non-string primitive " + inspect(val),
|
|
2389
|
+
void 0,
|
|
2390
|
+
ssfi
|
|
2391
|
+
);
|
|
2392
|
+
}
|
|
2393
|
+
itemsCount = Object.keys(val).length;
|
|
2394
|
+
}
|
|
2395
|
+
this.assert(
|
|
2396
|
+
0 === itemsCount,
|
|
2397
|
+
"expected #{this} to be empty",
|
|
2398
|
+
"expected #{this} not to be empty"
|
|
2399
|
+
);
|
|
2400
|
+
});
|
|
2401
|
+
function checkArguments() {
|
|
2402
|
+
var obj = flag2(this, "object"), type3 = import_type_detect3.default(obj);
|
|
2403
|
+
this.assert(
|
|
2404
|
+
"Arguments" === type3,
|
|
2405
|
+
"expected #{this} to be arguments but got " + type3,
|
|
2406
|
+
"expected #{this} to not be arguments"
|
|
2407
|
+
);
|
|
2408
|
+
}
|
|
2409
|
+
__name(checkArguments, "checkArguments");
|
|
2410
|
+
Assertion.addProperty("arguments", checkArguments);
|
|
2411
|
+
Assertion.addProperty("Arguments", checkArguments);
|
|
2412
|
+
function assertEqual(val, msg) {
|
|
2413
|
+
if (msg)
|
|
2414
|
+
flag2(this, "message", msg);
|
|
2415
|
+
var obj = flag2(this, "object");
|
|
2416
|
+
if (flag2(this, "deep")) {
|
|
2417
|
+
var prevLockSsfi = flag2(this, "lockSsfi");
|
|
2418
|
+
flag2(this, "lockSsfi", true);
|
|
2419
|
+
this.eql(val);
|
|
2420
|
+
flag2(this, "lockSsfi", prevLockSsfi);
|
|
2421
|
+
} else {
|
|
2422
|
+
this.assert(
|
|
2423
|
+
val === obj,
|
|
2424
|
+
"expected #{this} to equal #{exp}",
|
|
2425
|
+
"expected #{this} to not equal #{exp}",
|
|
2426
|
+
val,
|
|
2427
|
+
this._obj,
|
|
2428
|
+
true
|
|
2429
|
+
);
|
|
2430
|
+
}
|
|
2431
|
+
}
|
|
2432
|
+
__name(assertEqual, "assertEqual");
|
|
2433
|
+
Assertion.addMethod("equal", assertEqual);
|
|
2434
|
+
Assertion.addMethod("equals", assertEqual);
|
|
2435
|
+
Assertion.addMethod("eq", assertEqual);
|
|
2436
|
+
function assertEql(obj, msg) {
|
|
2437
|
+
if (msg)
|
|
2438
|
+
flag2(this, "message", msg);
|
|
2439
|
+
this.assert(
|
|
2440
|
+
import_deep_eql.default(obj, flag2(this, "object")),
|
|
2441
|
+
"expected #{this} to deeply equal #{exp}",
|
|
2442
|
+
"expected #{this} to not deeply equal #{exp}",
|
|
2443
|
+
obj,
|
|
2444
|
+
this._obj,
|
|
2445
|
+
true
|
|
2446
|
+
);
|
|
2447
|
+
}
|
|
2448
|
+
__name(assertEql, "assertEql");
|
|
2449
|
+
Assertion.addMethod("eql", assertEql);
|
|
2450
|
+
Assertion.addMethod("eqls", assertEql);
|
|
2451
|
+
function assertAbove(n, msg) {
|
|
2452
|
+
if (msg)
|
|
2453
|
+
flag2(this, "message", msg);
|
|
2454
|
+
var obj = flag2(this, "object"), doLength = flag2(this, "doLength"), flagMsg = flag2(this, "message"), msgPrefix = flagMsg ? flagMsg + ": " : "", ssfi = flag2(this, "ssfi"), objType = import_type_detect3.default(obj).toLowerCase(), nType = import_type_detect3.default(n).toLowerCase(), errorMessage, shouldThrow = true;
|
|
2455
|
+
if (doLength && objType !== "map" && objType !== "set") {
|
|
2456
|
+
new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
|
|
2457
|
+
}
|
|
2458
|
+
if (!doLength && (objType === "date" && nType !== "date")) {
|
|
2459
|
+
errorMessage = msgPrefix + "the argument to above must be a date";
|
|
2460
|
+
} else if (nType !== "number" && (doLength || objType === "number")) {
|
|
2461
|
+
errorMessage = msgPrefix + "the argument to above must be a number";
|
|
2462
|
+
} else if (!doLength && (objType !== "date" && objType !== "number")) {
|
|
2463
|
+
var printObj = objType === "string" ? "'" + obj + "'" : obj;
|
|
2464
|
+
errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
|
|
2465
|
+
} else {
|
|
2466
|
+
shouldThrow = false;
|
|
2467
|
+
}
|
|
2468
|
+
if (shouldThrow) {
|
|
2469
|
+
throw new import_assertion_error3.default(errorMessage, void 0, ssfi);
|
|
2470
|
+
}
|
|
2471
|
+
if (doLength) {
|
|
2472
|
+
var descriptor = "length", itemsCount;
|
|
2473
|
+
if (objType === "map" || objType === "set") {
|
|
2474
|
+
descriptor = "size";
|
|
2475
|
+
itemsCount = obj.size;
|
|
2476
|
+
} else {
|
|
2477
|
+
itemsCount = obj.length;
|
|
2478
|
+
}
|
|
2479
|
+
this.assert(
|
|
2480
|
+
itemsCount > n,
|
|
2481
|
+
"expected #{this} to have a " + descriptor + " above #{exp} but got #{act}",
|
|
2482
|
+
"expected #{this} to not have a " + descriptor + " above #{exp}",
|
|
2483
|
+
n,
|
|
2484
|
+
itemsCount
|
|
2485
|
+
);
|
|
2486
|
+
} else {
|
|
2487
|
+
this.assert(
|
|
2488
|
+
obj > n,
|
|
2489
|
+
"expected #{this} to be above #{exp}",
|
|
2490
|
+
"expected #{this} to be at most #{exp}",
|
|
2491
|
+
n
|
|
2492
|
+
);
|
|
2493
|
+
}
|
|
2494
|
+
}
|
|
2495
|
+
__name(assertAbove, "assertAbove");
|
|
2496
|
+
Assertion.addMethod("above", assertAbove);
|
|
2497
|
+
Assertion.addMethod("gt", assertAbove);
|
|
2498
|
+
Assertion.addMethod("greaterThan", assertAbove);
|
|
2499
|
+
function assertLeast(n, msg) {
|
|
2500
|
+
if (msg)
|
|
2501
|
+
flag2(this, "message", msg);
|
|
2502
|
+
var obj = flag2(this, "object"), doLength = flag2(this, "doLength"), flagMsg = flag2(this, "message"), msgPrefix = flagMsg ? flagMsg + ": " : "", ssfi = flag2(this, "ssfi"), objType = import_type_detect3.default(obj).toLowerCase(), nType = import_type_detect3.default(n).toLowerCase(), errorMessage, shouldThrow = true;
|
|
2503
|
+
if (doLength && objType !== "map" && objType !== "set") {
|
|
2504
|
+
new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
|
|
2505
|
+
}
|
|
2506
|
+
if (!doLength && (objType === "date" && nType !== "date")) {
|
|
2507
|
+
errorMessage = msgPrefix + "the argument to least must be a date";
|
|
2508
|
+
} else if (nType !== "number" && (doLength || objType === "number")) {
|
|
2509
|
+
errorMessage = msgPrefix + "the argument to least must be a number";
|
|
2510
|
+
} else if (!doLength && (objType !== "date" && objType !== "number")) {
|
|
2511
|
+
var printObj = objType === "string" ? "'" + obj + "'" : obj;
|
|
2512
|
+
errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
|
|
2513
|
+
} else {
|
|
2514
|
+
shouldThrow = false;
|
|
2515
|
+
}
|
|
2516
|
+
if (shouldThrow) {
|
|
2517
|
+
throw new import_assertion_error3.default(errorMessage, void 0, ssfi);
|
|
2518
|
+
}
|
|
2519
|
+
if (doLength) {
|
|
2520
|
+
var descriptor = "length", itemsCount;
|
|
2521
|
+
if (objType === "map" || objType === "set") {
|
|
2522
|
+
descriptor = "size";
|
|
2523
|
+
itemsCount = obj.size;
|
|
2524
|
+
} else {
|
|
2525
|
+
itemsCount = obj.length;
|
|
2526
|
+
}
|
|
2527
|
+
this.assert(
|
|
2528
|
+
itemsCount >= n,
|
|
2529
|
+
"expected #{this} to have a " + descriptor + " at least #{exp} but got #{act}",
|
|
2530
|
+
"expected #{this} to have a " + descriptor + " below #{exp}",
|
|
2531
|
+
n,
|
|
2532
|
+
itemsCount
|
|
2533
|
+
);
|
|
2534
|
+
} else {
|
|
2535
|
+
this.assert(
|
|
2536
|
+
obj >= n,
|
|
2537
|
+
"expected #{this} to be at least #{exp}",
|
|
2538
|
+
"expected #{this} to be below #{exp}",
|
|
2539
|
+
n
|
|
2540
|
+
);
|
|
2541
|
+
}
|
|
2542
|
+
}
|
|
2543
|
+
__name(assertLeast, "assertLeast");
|
|
2544
|
+
Assertion.addMethod("least", assertLeast);
|
|
2545
|
+
Assertion.addMethod("gte", assertLeast);
|
|
2546
|
+
Assertion.addMethod("greaterThanOrEqual", assertLeast);
|
|
2547
|
+
function assertBelow(n, msg) {
|
|
2548
|
+
if (msg)
|
|
2549
|
+
flag2(this, "message", msg);
|
|
2550
|
+
var obj = flag2(this, "object"), doLength = flag2(this, "doLength"), flagMsg = flag2(this, "message"), msgPrefix = flagMsg ? flagMsg + ": " : "", ssfi = flag2(this, "ssfi"), objType = import_type_detect3.default(obj).toLowerCase(), nType = import_type_detect3.default(n).toLowerCase(), errorMessage, shouldThrow = true;
|
|
2551
|
+
if (doLength && objType !== "map" && objType !== "set") {
|
|
2552
|
+
new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
|
|
2553
|
+
}
|
|
2554
|
+
if (!doLength && (objType === "date" && nType !== "date")) {
|
|
2555
|
+
errorMessage = msgPrefix + "the argument to below must be a date";
|
|
2556
|
+
} else if (nType !== "number" && (doLength || objType === "number")) {
|
|
2557
|
+
errorMessage = msgPrefix + "the argument to below must be a number";
|
|
2558
|
+
} else if (!doLength && (objType !== "date" && objType !== "number")) {
|
|
2559
|
+
var printObj = objType === "string" ? "'" + obj + "'" : obj;
|
|
2560
|
+
errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
|
|
2561
|
+
} else {
|
|
2562
|
+
shouldThrow = false;
|
|
2563
|
+
}
|
|
2564
|
+
if (shouldThrow) {
|
|
2565
|
+
throw new import_assertion_error3.default(errorMessage, void 0, ssfi);
|
|
2566
|
+
}
|
|
2567
|
+
if (doLength) {
|
|
2568
|
+
var descriptor = "length", itemsCount;
|
|
2569
|
+
if (objType === "map" || objType === "set") {
|
|
2570
|
+
descriptor = "size";
|
|
2571
|
+
itemsCount = obj.size;
|
|
2572
|
+
} else {
|
|
2573
|
+
itemsCount = obj.length;
|
|
2574
|
+
}
|
|
2575
|
+
this.assert(
|
|
2576
|
+
itemsCount < n,
|
|
2577
|
+
"expected #{this} to have a " + descriptor + " below #{exp} but got #{act}",
|
|
2578
|
+
"expected #{this} to not have a " + descriptor + " below #{exp}",
|
|
2579
|
+
n,
|
|
2580
|
+
itemsCount
|
|
2581
|
+
);
|
|
2582
|
+
} else {
|
|
2583
|
+
this.assert(
|
|
2584
|
+
obj < n,
|
|
2585
|
+
"expected #{this} to be below #{exp}",
|
|
2586
|
+
"expected #{this} to be at least #{exp}",
|
|
2587
|
+
n
|
|
2588
|
+
);
|
|
2589
|
+
}
|
|
2590
|
+
}
|
|
2591
|
+
__name(assertBelow, "assertBelow");
|
|
2592
|
+
Assertion.addMethod("below", assertBelow);
|
|
2593
|
+
Assertion.addMethod("lt", assertBelow);
|
|
2594
|
+
Assertion.addMethod("lessThan", assertBelow);
|
|
2595
|
+
function assertMost(n, msg) {
|
|
2596
|
+
if (msg)
|
|
2597
|
+
flag2(this, "message", msg);
|
|
2598
|
+
var obj = flag2(this, "object"), doLength = flag2(this, "doLength"), flagMsg = flag2(this, "message"), msgPrefix = flagMsg ? flagMsg + ": " : "", ssfi = flag2(this, "ssfi"), objType = import_type_detect3.default(obj).toLowerCase(), nType = import_type_detect3.default(n).toLowerCase(), errorMessage, shouldThrow = true;
|
|
2599
|
+
if (doLength && objType !== "map" && objType !== "set") {
|
|
2600
|
+
new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
|
|
2601
|
+
}
|
|
2602
|
+
if (!doLength && (objType === "date" && nType !== "date")) {
|
|
2603
|
+
errorMessage = msgPrefix + "the argument to most must be a date";
|
|
2604
|
+
} else if (nType !== "number" && (doLength || objType === "number")) {
|
|
2605
|
+
errorMessage = msgPrefix + "the argument to most must be a number";
|
|
2606
|
+
} else if (!doLength && (objType !== "date" && objType !== "number")) {
|
|
2607
|
+
var printObj = objType === "string" ? "'" + obj + "'" : obj;
|
|
2608
|
+
errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
|
|
2609
|
+
} else {
|
|
2610
|
+
shouldThrow = false;
|
|
2611
|
+
}
|
|
2612
|
+
if (shouldThrow) {
|
|
2613
|
+
throw new import_assertion_error3.default(errorMessage, void 0, ssfi);
|
|
2614
|
+
}
|
|
2615
|
+
if (doLength) {
|
|
2616
|
+
var descriptor = "length", itemsCount;
|
|
2617
|
+
if (objType === "map" || objType === "set") {
|
|
2618
|
+
descriptor = "size";
|
|
2619
|
+
itemsCount = obj.size;
|
|
2620
|
+
} else {
|
|
2621
|
+
itemsCount = obj.length;
|
|
2622
|
+
}
|
|
2623
|
+
this.assert(
|
|
2624
|
+
itemsCount <= n,
|
|
2625
|
+
"expected #{this} to have a " + descriptor + " at most #{exp} but got #{act}",
|
|
2626
|
+
"expected #{this} to have a " + descriptor + " above #{exp}",
|
|
2627
|
+
n,
|
|
2628
|
+
itemsCount
|
|
2629
|
+
);
|
|
2630
|
+
} else {
|
|
2631
|
+
this.assert(
|
|
2632
|
+
obj <= n,
|
|
2633
|
+
"expected #{this} to be at most #{exp}",
|
|
2634
|
+
"expected #{this} to be above #{exp}",
|
|
2635
|
+
n
|
|
2636
|
+
);
|
|
2637
|
+
}
|
|
2638
|
+
}
|
|
2639
|
+
__name(assertMost, "assertMost");
|
|
2640
|
+
Assertion.addMethod("most", assertMost);
|
|
2641
|
+
Assertion.addMethod("lte", assertMost);
|
|
2642
|
+
Assertion.addMethod("lessThanOrEqual", assertMost);
|
|
2643
|
+
Assertion.addMethod("within", function(start, finish, msg) {
|
|
2644
|
+
if (msg)
|
|
2645
|
+
flag2(this, "message", msg);
|
|
2646
|
+
var obj = flag2(this, "object"), doLength = flag2(this, "doLength"), flagMsg = flag2(this, "message"), msgPrefix = flagMsg ? flagMsg + ": " : "", ssfi = flag2(this, "ssfi"), objType = import_type_detect3.default(obj).toLowerCase(), startType = import_type_detect3.default(start).toLowerCase(), finishType = import_type_detect3.default(finish).toLowerCase(), errorMessage, shouldThrow = true, range = startType === "date" && finishType === "date" ? start.toISOString() + ".." + finish.toISOString() : start + ".." + finish;
|
|
2647
|
+
if (doLength && objType !== "map" && objType !== "set") {
|
|
2648
|
+
new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
|
|
2649
|
+
}
|
|
2650
|
+
if (!doLength && (objType === "date" && (startType !== "date" || finishType !== "date"))) {
|
|
2651
|
+
errorMessage = msgPrefix + "the arguments to within must be dates";
|
|
2652
|
+
} else if ((startType !== "number" || finishType !== "number") && (doLength || objType === "number")) {
|
|
2653
|
+
errorMessage = msgPrefix + "the arguments to within must be numbers";
|
|
2654
|
+
} else if (!doLength && (objType !== "date" && objType !== "number")) {
|
|
2655
|
+
var printObj = objType === "string" ? "'" + obj + "'" : obj;
|
|
2656
|
+
errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
|
|
2657
|
+
} else {
|
|
2658
|
+
shouldThrow = false;
|
|
2659
|
+
}
|
|
2660
|
+
if (shouldThrow) {
|
|
2661
|
+
throw new import_assertion_error3.default(errorMessage, void 0, ssfi);
|
|
2662
|
+
}
|
|
2663
|
+
if (doLength) {
|
|
2664
|
+
var descriptor = "length", itemsCount;
|
|
2665
|
+
if (objType === "map" || objType === "set") {
|
|
2666
|
+
descriptor = "size";
|
|
2667
|
+
itemsCount = obj.size;
|
|
2668
|
+
} else {
|
|
2669
|
+
itemsCount = obj.length;
|
|
2670
|
+
}
|
|
2671
|
+
this.assert(
|
|
2672
|
+
itemsCount >= start && itemsCount <= finish,
|
|
2673
|
+
"expected #{this} to have a " + descriptor + " within " + range,
|
|
2674
|
+
"expected #{this} to not have a " + descriptor + " within " + range
|
|
2675
|
+
);
|
|
2676
|
+
} else {
|
|
2677
|
+
this.assert(
|
|
2678
|
+
obj >= start && obj <= finish,
|
|
2679
|
+
"expected #{this} to be within " + range,
|
|
2680
|
+
"expected #{this} to not be within " + range
|
|
2681
|
+
);
|
|
2682
|
+
}
|
|
2683
|
+
});
|
|
2684
|
+
function assertInstanceOf(constructor, msg) {
|
|
2685
|
+
if (msg)
|
|
2686
|
+
flag2(this, "message", msg);
|
|
2687
|
+
var target = flag2(this, "object");
|
|
2688
|
+
var ssfi = flag2(this, "ssfi");
|
|
2689
|
+
var flagMsg = flag2(this, "message");
|
|
2690
|
+
try {
|
|
2691
|
+
var isInstanceOf = target instanceof constructor;
|
|
2692
|
+
} catch (err) {
|
|
2693
|
+
if (err instanceof TypeError) {
|
|
2694
|
+
flagMsg = flagMsg ? flagMsg + ": " : "";
|
|
2695
|
+
throw new import_assertion_error3.default(
|
|
2696
|
+
flagMsg + "The instanceof assertion needs a constructor but " + import_type_detect3.default(constructor) + " was given.",
|
|
2697
|
+
void 0,
|
|
2698
|
+
ssfi
|
|
2699
|
+
);
|
|
2700
|
+
}
|
|
2701
|
+
throw err;
|
|
2702
|
+
}
|
|
2703
|
+
var name = getName(constructor);
|
|
2704
|
+
if (name == null) {
|
|
2705
|
+
name = "an unnamed constructor";
|
|
2706
|
+
}
|
|
2707
|
+
this.assert(
|
|
2708
|
+
isInstanceOf,
|
|
2709
|
+
"expected #{this} to be an instance of " + name,
|
|
2710
|
+
"expected #{this} to not be an instance of " + name
|
|
2711
|
+
);
|
|
2712
|
+
}
|
|
2713
|
+
__name(assertInstanceOf, "assertInstanceOf");
|
|
2714
|
+
Assertion.addMethod("instanceof", assertInstanceOf);
|
|
2715
|
+
Assertion.addMethod("instanceOf", assertInstanceOf);
|
|
2716
|
+
function assertProperty(name, val, msg) {
|
|
2717
|
+
if (msg)
|
|
2718
|
+
flag2(this, "message", msg);
|
|
2719
|
+
var isNested = flag2(this, "nested"), isOwn = flag2(this, "own"), flagMsg = flag2(this, "message"), obj = flag2(this, "object"), ssfi = flag2(this, "ssfi"), nameType = typeof name;
|
|
2720
|
+
flagMsg = flagMsg ? flagMsg + ": " : "";
|
|
2721
|
+
if (isNested) {
|
|
2722
|
+
if (nameType !== "string") {
|
|
2723
|
+
throw new import_assertion_error3.default(
|
|
2724
|
+
flagMsg + "the argument to property must be a string when using nested syntax",
|
|
2725
|
+
void 0,
|
|
2726
|
+
ssfi
|
|
2727
|
+
);
|
|
2728
|
+
}
|
|
2729
|
+
} else {
|
|
2730
|
+
if (nameType !== "string" && nameType !== "number" && nameType !== "symbol") {
|
|
2731
|
+
throw new import_assertion_error3.default(
|
|
2732
|
+
flagMsg + "the argument to property must be a string, number, or symbol",
|
|
2733
|
+
void 0,
|
|
2734
|
+
ssfi
|
|
2735
|
+
);
|
|
2736
|
+
}
|
|
2737
|
+
}
|
|
2738
|
+
if (isNested && isOwn) {
|
|
2739
|
+
throw new import_assertion_error3.default(
|
|
2740
|
+
flagMsg + 'The "nested" and "own" flags cannot be combined.',
|
|
2741
|
+
void 0,
|
|
2742
|
+
ssfi
|
|
2743
|
+
);
|
|
2744
|
+
}
|
|
2745
|
+
if (obj === null || obj === void 0) {
|
|
2746
|
+
throw new import_assertion_error3.default(
|
|
2747
|
+
flagMsg + "Target cannot be null or undefined.",
|
|
2748
|
+
void 0,
|
|
2749
|
+
ssfi
|
|
2750
|
+
);
|
|
2751
|
+
}
|
|
2752
|
+
var isDeep = flag2(this, "deep"), negate = flag2(this, "negate"), pathInfo = isNested ? import_pathval.getPathInfo(obj, name) : null, value = isNested ? pathInfo.value : obj[name];
|
|
2753
|
+
var descriptor = "";
|
|
2754
|
+
if (isDeep)
|
|
2755
|
+
descriptor += "deep ";
|
|
2756
|
+
if (isOwn)
|
|
2757
|
+
descriptor += "own ";
|
|
2758
|
+
if (isNested)
|
|
2759
|
+
descriptor += "nested ";
|
|
2760
|
+
descriptor += "property ";
|
|
2761
|
+
var hasProperty2;
|
|
2762
|
+
if (isOwn)
|
|
2763
|
+
hasProperty2 = Object.prototype.hasOwnProperty.call(obj, name);
|
|
2764
|
+
else if (isNested)
|
|
2765
|
+
hasProperty2 = pathInfo.exists;
|
|
2766
|
+
else
|
|
2767
|
+
hasProperty2 = import_pathval.hasProperty(obj, name);
|
|
2768
|
+
if (!negate || arguments.length === 1) {
|
|
2769
|
+
this.assert(
|
|
2770
|
+
hasProperty2,
|
|
2771
|
+
"expected #{this} to have " + descriptor + inspect(name),
|
|
2772
|
+
"expected #{this} to not have " + descriptor + inspect(name)
|
|
2773
|
+
);
|
|
2774
|
+
}
|
|
2775
|
+
if (arguments.length > 1) {
|
|
2776
|
+
this.assert(
|
|
2777
|
+
hasProperty2 && (isDeep ? import_deep_eql.default(val, value) : val === value),
|
|
2778
|
+
"expected #{this} to have " + descriptor + inspect(name) + " of #{exp}, but got #{act}",
|
|
2779
|
+
"expected #{this} to not have " + descriptor + inspect(name) + " of #{act}",
|
|
2780
|
+
val,
|
|
2781
|
+
value
|
|
2782
|
+
);
|
|
2783
|
+
}
|
|
2784
|
+
flag2(this, "object", value);
|
|
2785
|
+
}
|
|
2786
|
+
__name(assertProperty, "assertProperty");
|
|
2787
|
+
Assertion.addMethod("property", assertProperty);
|
|
2788
|
+
function assertOwnProperty(name, value, msg) {
|
|
2789
|
+
flag2(this, "own", true);
|
|
2790
|
+
assertProperty.apply(this, arguments);
|
|
2791
|
+
}
|
|
2792
|
+
__name(assertOwnProperty, "assertOwnProperty");
|
|
2793
|
+
Assertion.addMethod("ownProperty", assertOwnProperty);
|
|
2794
|
+
Assertion.addMethod("haveOwnProperty", assertOwnProperty);
|
|
2795
|
+
function assertOwnPropertyDescriptor(name, descriptor, msg) {
|
|
2796
|
+
if (typeof descriptor === "string") {
|
|
2797
|
+
msg = descriptor;
|
|
2798
|
+
descriptor = null;
|
|
2799
|
+
}
|
|
2800
|
+
if (msg)
|
|
2801
|
+
flag2(this, "message", msg);
|
|
2802
|
+
var obj = flag2(this, "object");
|
|
2803
|
+
var actualDescriptor = Object.getOwnPropertyDescriptor(Object(obj), name);
|
|
2804
|
+
if (actualDescriptor && descriptor) {
|
|
2805
|
+
this.assert(
|
|
2806
|
+
import_deep_eql.default(descriptor, actualDescriptor),
|
|
2807
|
+
"expected the own property descriptor for " + inspect(name) + " on #{this} to match " + inspect(descriptor) + ", got " + inspect(actualDescriptor),
|
|
2808
|
+
"expected the own property descriptor for " + inspect(name) + " on #{this} to not match " + inspect(descriptor),
|
|
2809
|
+
descriptor,
|
|
2810
|
+
actualDescriptor,
|
|
2811
|
+
true
|
|
2812
|
+
);
|
|
2813
|
+
} else {
|
|
2814
|
+
this.assert(
|
|
2815
|
+
actualDescriptor,
|
|
2816
|
+
"expected #{this} to have an own property descriptor for " + inspect(name),
|
|
2817
|
+
"expected #{this} to not have an own property descriptor for " + inspect(name)
|
|
2818
|
+
);
|
|
2819
|
+
}
|
|
2820
|
+
flag2(this, "object", actualDescriptor);
|
|
2821
|
+
}
|
|
2822
|
+
__name(assertOwnPropertyDescriptor, "assertOwnPropertyDescriptor");
|
|
2823
|
+
Assertion.addMethod("ownPropertyDescriptor", assertOwnPropertyDescriptor);
|
|
2824
|
+
Assertion.addMethod("haveOwnPropertyDescriptor", assertOwnPropertyDescriptor);
|
|
2825
|
+
function assertLengthChain() {
|
|
2826
|
+
flag2(this, "doLength", true);
|
|
2827
|
+
}
|
|
2828
|
+
__name(assertLengthChain, "assertLengthChain");
|
|
2829
|
+
function assertLength(n, msg) {
|
|
2830
|
+
if (msg)
|
|
2831
|
+
flag2(this, "message", msg);
|
|
2832
|
+
var obj = flag2(this, "object"), objType = import_type_detect3.default(obj).toLowerCase(), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi"), descriptor = "length", itemsCount;
|
|
2833
|
+
switch (objType) {
|
|
2834
|
+
case "map":
|
|
2835
|
+
case "set":
|
|
2836
|
+
descriptor = "size";
|
|
2837
|
+
itemsCount = obj.size;
|
|
2838
|
+
break;
|
|
2839
|
+
default:
|
|
2840
|
+
new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
|
|
2841
|
+
itemsCount = obj.length;
|
|
2842
|
+
}
|
|
2843
|
+
this.assert(
|
|
2844
|
+
itemsCount == n,
|
|
2845
|
+
"expected #{this} to have a " + descriptor + " of #{exp} but got #{act}",
|
|
2846
|
+
"expected #{this} to not have a " + descriptor + " of #{act}",
|
|
2847
|
+
n,
|
|
2848
|
+
itemsCount
|
|
2849
|
+
);
|
|
2850
|
+
}
|
|
2851
|
+
__name(assertLength, "assertLength");
|
|
2852
|
+
Assertion.addChainableMethod("length", assertLength, assertLengthChain);
|
|
2853
|
+
Assertion.addChainableMethod("lengthOf", assertLength, assertLengthChain);
|
|
2854
|
+
function assertMatch(re, msg) {
|
|
2855
|
+
if (msg)
|
|
2856
|
+
flag2(this, "message", msg);
|
|
2857
|
+
var obj = flag2(this, "object");
|
|
2858
|
+
this.assert(
|
|
2859
|
+
re.exec(obj),
|
|
2860
|
+
"expected #{this} to match " + re,
|
|
2861
|
+
"expected #{this} not to match " + re
|
|
2862
|
+
);
|
|
2863
|
+
}
|
|
2864
|
+
__name(assertMatch, "assertMatch");
|
|
2865
|
+
Assertion.addMethod("match", assertMatch);
|
|
2866
|
+
Assertion.addMethod("matches", assertMatch);
|
|
2867
|
+
Assertion.addMethod("string", function(str, msg) {
|
|
2868
|
+
if (msg)
|
|
2869
|
+
flag2(this, "message", msg);
|
|
2870
|
+
var obj = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
|
|
2871
|
+
new Assertion(obj, flagMsg, ssfi, true).is.a("string");
|
|
2872
|
+
this.assert(
|
|
2873
|
+
~obj.indexOf(str),
|
|
2874
|
+
"expected #{this} to contain " + inspect(str),
|
|
2875
|
+
"expected #{this} to not contain " + inspect(str)
|
|
2876
|
+
);
|
|
2877
|
+
});
|
|
2878
|
+
function assertKeys(keys) {
|
|
2879
|
+
var obj = flag2(this, "object"), objType = import_type_detect3.default(obj), keysType = import_type_detect3.default(keys), ssfi = flag2(this, "ssfi"), isDeep = flag2(this, "deep"), str, deepStr = "", actual, ok = true, flagMsg = flag2(this, "message");
|
|
2880
|
+
flagMsg = flagMsg ? flagMsg + ": " : "";
|
|
2881
|
+
var mixedArgsMsg = flagMsg + "when testing keys against an object or an array you must give a single Array|Object|String argument or multiple String arguments";
|
|
2882
|
+
if (objType === "Map" || objType === "Set") {
|
|
2883
|
+
deepStr = isDeep ? "deeply " : "";
|
|
2884
|
+
actual = [];
|
|
2885
|
+
obj.forEach(function(val, key) {
|
|
2886
|
+
actual.push(key);
|
|
2887
|
+
});
|
|
2888
|
+
if (keysType !== "Array") {
|
|
2889
|
+
keys = Array.prototype.slice.call(arguments);
|
|
2890
|
+
}
|
|
2891
|
+
} else {
|
|
2892
|
+
actual = getOwnEnumerableProperties(obj);
|
|
2893
|
+
switch (keysType) {
|
|
2894
|
+
case "Array":
|
|
2895
|
+
if (arguments.length > 1) {
|
|
2896
|
+
throw new import_assertion_error3.default(mixedArgsMsg, void 0, ssfi);
|
|
2897
|
+
}
|
|
2898
|
+
break;
|
|
2899
|
+
case "Object":
|
|
2900
|
+
if (arguments.length > 1) {
|
|
2901
|
+
throw new import_assertion_error3.default(mixedArgsMsg, void 0, ssfi);
|
|
2902
|
+
}
|
|
2903
|
+
keys = Object.keys(keys);
|
|
2904
|
+
break;
|
|
2905
|
+
default:
|
|
2906
|
+
keys = Array.prototype.slice.call(arguments);
|
|
2907
|
+
}
|
|
2908
|
+
keys = keys.map(function(val) {
|
|
2909
|
+
return typeof val === "symbol" ? val : String(val);
|
|
2910
|
+
});
|
|
2911
|
+
}
|
|
2912
|
+
if (!keys.length) {
|
|
2913
|
+
throw new import_assertion_error3.default(flagMsg + "keys required", void 0, ssfi);
|
|
2914
|
+
}
|
|
2915
|
+
var len = keys.length, any = flag2(this, "any"), all = flag2(this, "all"), expected = keys;
|
|
2916
|
+
if (!any && !all) {
|
|
2917
|
+
all = true;
|
|
2918
|
+
}
|
|
2919
|
+
if (any) {
|
|
2920
|
+
ok = expected.some(function(expectedKey) {
|
|
2921
|
+
return actual.some(function(actualKey) {
|
|
2922
|
+
if (isDeep) {
|
|
2923
|
+
return import_deep_eql.default(expectedKey, actualKey);
|
|
2924
|
+
} else {
|
|
2925
|
+
return expectedKey === actualKey;
|
|
2926
|
+
}
|
|
2927
|
+
});
|
|
2928
|
+
});
|
|
2929
|
+
}
|
|
2930
|
+
if (all) {
|
|
2931
|
+
ok = expected.every(function(expectedKey) {
|
|
2932
|
+
return actual.some(function(actualKey) {
|
|
2933
|
+
if (isDeep) {
|
|
2934
|
+
return import_deep_eql.default(expectedKey, actualKey);
|
|
2935
|
+
} else {
|
|
2936
|
+
return expectedKey === actualKey;
|
|
2937
|
+
}
|
|
2938
|
+
});
|
|
2939
|
+
});
|
|
2940
|
+
if (!flag2(this, "contains")) {
|
|
2941
|
+
ok = ok && keys.length == actual.length;
|
|
2942
|
+
}
|
|
2943
|
+
}
|
|
2944
|
+
if (len > 1) {
|
|
2945
|
+
keys = keys.map(function(key) {
|
|
2946
|
+
return inspect(key);
|
|
2947
|
+
});
|
|
2948
|
+
var last = keys.pop();
|
|
2949
|
+
if (all) {
|
|
2950
|
+
str = keys.join(", ") + ", and " + last;
|
|
2951
|
+
}
|
|
2952
|
+
if (any) {
|
|
2953
|
+
str = keys.join(", ") + ", or " + last;
|
|
2954
|
+
}
|
|
2955
|
+
} else {
|
|
2956
|
+
str = inspect(keys[0]);
|
|
2957
|
+
}
|
|
2958
|
+
str = (len > 1 ? "keys " : "key ") + str;
|
|
2959
|
+
str = (flag2(this, "contains") ? "contain " : "have ") + str;
|
|
2960
|
+
this.assert(
|
|
2961
|
+
ok,
|
|
2962
|
+
"expected #{this} to " + deepStr + str,
|
|
2963
|
+
"expected #{this} to not " + deepStr + str,
|
|
2964
|
+
expected.slice(0).sort(compareByInspect),
|
|
2965
|
+
actual.sort(compareByInspect),
|
|
2966
|
+
true
|
|
2967
|
+
);
|
|
2968
|
+
}
|
|
2969
|
+
__name(assertKeys, "assertKeys");
|
|
2970
|
+
Assertion.addMethod("keys", assertKeys);
|
|
2971
|
+
Assertion.addMethod("key", assertKeys);
|
|
2972
|
+
function assertThrows(errorLike, errMsgMatcher, msg) {
|
|
2973
|
+
if (msg)
|
|
2974
|
+
flag2(this, "message", msg);
|
|
2975
|
+
var obj = flag2(this, "object"), ssfi = flag2(this, "ssfi"), flagMsg = flag2(this, "message"), negate = flag2(this, "negate") || false;
|
|
2976
|
+
new Assertion(obj, flagMsg, ssfi, true).is.a("function");
|
|
2977
|
+
if (errorLike instanceof RegExp || typeof errorLike === "string") {
|
|
2978
|
+
errMsgMatcher = errorLike;
|
|
2979
|
+
errorLike = null;
|
|
2980
|
+
}
|
|
2981
|
+
var caughtErr;
|
|
2982
|
+
try {
|
|
2983
|
+
obj();
|
|
2984
|
+
} catch (err) {
|
|
2985
|
+
caughtErr = err;
|
|
2986
|
+
}
|
|
2987
|
+
var everyArgIsUndefined = errorLike === void 0 && errMsgMatcher === void 0;
|
|
2988
|
+
var everyArgIsDefined = Boolean(errorLike && errMsgMatcher);
|
|
2989
|
+
var errorLikeFail = false;
|
|
2990
|
+
var errMsgMatcherFail = false;
|
|
2991
|
+
if (everyArgIsUndefined || !everyArgIsUndefined && !negate) {
|
|
2992
|
+
var errorLikeString = "an error";
|
|
2993
|
+
if (errorLike instanceof Error) {
|
|
2994
|
+
errorLikeString = "#{exp}";
|
|
2995
|
+
} else if (errorLike) {
|
|
2996
|
+
errorLikeString = checkError.getConstructorName(errorLike);
|
|
2997
|
+
}
|
|
2998
|
+
this.assert(
|
|
2999
|
+
caughtErr,
|
|
3000
|
+
"expected #{this} to throw " + errorLikeString,
|
|
3001
|
+
"expected #{this} to not throw an error but #{act} was thrown",
|
|
3002
|
+
errorLike && errorLike.toString(),
|
|
3003
|
+
caughtErr instanceof Error ? caughtErr.toString() : typeof caughtErr === "string" ? caughtErr : caughtErr && checkError.getConstructorName(caughtErr)
|
|
3004
|
+
);
|
|
3005
|
+
}
|
|
3006
|
+
if (errorLike && caughtErr) {
|
|
3007
|
+
if (errorLike instanceof Error) {
|
|
3008
|
+
var isCompatibleInstance = checkError.compatibleInstance(caughtErr, errorLike);
|
|
3009
|
+
if (isCompatibleInstance === negate) {
|
|
3010
|
+
if (everyArgIsDefined && negate) {
|
|
3011
|
+
errorLikeFail = true;
|
|
3012
|
+
} else {
|
|
3013
|
+
this.assert(
|
|
3014
|
+
negate,
|
|
3015
|
+
"expected #{this} to throw #{exp} but #{act} was thrown",
|
|
3016
|
+
"expected #{this} to not throw #{exp}" + (caughtErr && !negate ? " but #{act} was thrown" : ""),
|
|
3017
|
+
errorLike.toString(),
|
|
3018
|
+
caughtErr.toString()
|
|
3019
|
+
);
|
|
3020
|
+
}
|
|
3021
|
+
}
|
|
3022
|
+
}
|
|
3023
|
+
var isCompatibleConstructor = checkError.compatibleConstructor(caughtErr, errorLike);
|
|
3024
|
+
if (isCompatibleConstructor === negate) {
|
|
3025
|
+
if (everyArgIsDefined && negate) {
|
|
3026
|
+
errorLikeFail = true;
|
|
3027
|
+
} else {
|
|
3028
|
+
this.assert(
|
|
3029
|
+
negate,
|
|
3030
|
+
"expected #{this} to throw #{exp} but #{act} was thrown",
|
|
3031
|
+
"expected #{this} to not throw #{exp}" + (caughtErr ? " but #{act} was thrown" : ""),
|
|
3032
|
+
errorLike instanceof Error ? errorLike.toString() : errorLike && checkError.getConstructorName(errorLike),
|
|
3033
|
+
caughtErr instanceof Error ? caughtErr.toString() : caughtErr && checkError.getConstructorName(caughtErr)
|
|
3034
|
+
);
|
|
3035
|
+
}
|
|
3036
|
+
}
|
|
3037
|
+
}
|
|
3038
|
+
if (caughtErr && errMsgMatcher !== void 0 && errMsgMatcher !== null) {
|
|
3039
|
+
var placeholder = "including";
|
|
3040
|
+
if (errMsgMatcher instanceof RegExp) {
|
|
3041
|
+
placeholder = "matching";
|
|
3042
|
+
}
|
|
3043
|
+
var isCompatibleMessage = checkError.compatibleMessage(caughtErr, errMsgMatcher);
|
|
3044
|
+
if (isCompatibleMessage === negate) {
|
|
3045
|
+
if (everyArgIsDefined && negate) {
|
|
3046
|
+
errMsgMatcherFail = true;
|
|
3047
|
+
} else {
|
|
3048
|
+
this.assert(
|
|
3049
|
+
negate,
|
|
3050
|
+
"expected #{this} to throw error " + placeholder + " #{exp} but got #{act}",
|
|
3051
|
+
"expected #{this} to throw error not " + placeholder + " #{exp}",
|
|
3052
|
+
errMsgMatcher,
|
|
3053
|
+
checkError.getMessage(caughtErr)
|
|
3054
|
+
);
|
|
3055
|
+
}
|
|
3056
|
+
}
|
|
3057
|
+
}
|
|
3058
|
+
if (errorLikeFail && errMsgMatcherFail) {
|
|
3059
|
+
this.assert(
|
|
3060
|
+
negate,
|
|
3061
|
+
"expected #{this} to throw #{exp} but #{act} was thrown",
|
|
3062
|
+
"expected #{this} to not throw #{exp}" + (caughtErr ? " but #{act} was thrown" : ""),
|
|
3063
|
+
errorLike instanceof Error ? errorLike.toString() : errorLike && checkError.getConstructorName(errorLike),
|
|
3064
|
+
caughtErr instanceof Error ? caughtErr.toString() : caughtErr && checkError.getConstructorName(caughtErr)
|
|
3065
|
+
);
|
|
3066
|
+
}
|
|
3067
|
+
flag2(this, "object", caughtErr);
|
|
3068
|
+
}
|
|
3069
|
+
__name(assertThrows, "assertThrows");
|
|
3070
|
+
Assertion.addMethod("throw", assertThrows);
|
|
3071
|
+
Assertion.addMethod("throws", assertThrows);
|
|
3072
|
+
Assertion.addMethod("Throw", assertThrows);
|
|
3073
|
+
function respondTo(method, msg) {
|
|
3074
|
+
if (msg)
|
|
3075
|
+
flag2(this, "message", msg);
|
|
3076
|
+
var obj = flag2(this, "object"), itself = flag2(this, "itself"), context = "function" === typeof obj && !itself ? obj.prototype[method] : obj[method];
|
|
3077
|
+
this.assert(
|
|
3078
|
+
"function" === typeof context,
|
|
3079
|
+
"expected #{this} to respond to " + inspect(method),
|
|
3080
|
+
"expected #{this} to not respond to " + inspect(method)
|
|
3081
|
+
);
|
|
3082
|
+
}
|
|
3083
|
+
__name(respondTo, "respondTo");
|
|
3084
|
+
Assertion.addMethod("respondTo", respondTo);
|
|
3085
|
+
Assertion.addMethod("respondsTo", respondTo);
|
|
3086
|
+
Assertion.addProperty("itself", function() {
|
|
3087
|
+
flag2(this, "itself", true);
|
|
3088
|
+
});
|
|
3089
|
+
function satisfy(matcher, msg) {
|
|
3090
|
+
if (msg)
|
|
3091
|
+
flag2(this, "message", msg);
|
|
3092
|
+
var obj = flag2(this, "object");
|
|
3093
|
+
var result = matcher(obj);
|
|
3094
|
+
this.assert(
|
|
3095
|
+
result,
|
|
3096
|
+
"expected #{this} to satisfy " + objDisplay(matcher),
|
|
3097
|
+
"expected #{this} to not satisfy" + objDisplay(matcher),
|
|
3098
|
+
flag2(this, "negate") ? false : true,
|
|
3099
|
+
result
|
|
3100
|
+
);
|
|
3101
|
+
}
|
|
3102
|
+
__name(satisfy, "satisfy");
|
|
3103
|
+
Assertion.addMethod("satisfy", satisfy);
|
|
3104
|
+
Assertion.addMethod("satisfies", satisfy);
|
|
3105
|
+
function closeTo(expected, delta, msg) {
|
|
3106
|
+
if (msg)
|
|
3107
|
+
flag2(this, "message", msg);
|
|
3108
|
+
var obj = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
|
|
3109
|
+
new Assertion(obj, flagMsg, ssfi, true).is.a("number");
|
|
3110
|
+
if (typeof expected !== "number" || typeof delta !== "number") {
|
|
3111
|
+
flagMsg = flagMsg ? flagMsg + ": " : "";
|
|
3112
|
+
var deltaMessage = delta === void 0 ? ", and a delta is required" : "";
|
|
3113
|
+
throw new import_assertion_error3.default(
|
|
3114
|
+
flagMsg + "the arguments to closeTo or approximately must be numbers" + deltaMessage,
|
|
3115
|
+
void 0,
|
|
3116
|
+
ssfi
|
|
3117
|
+
);
|
|
3118
|
+
}
|
|
3119
|
+
this.assert(
|
|
3120
|
+
Math.abs(obj - expected) <= delta,
|
|
3121
|
+
"expected #{this} to be close to " + expected + " +/- " + delta,
|
|
3122
|
+
"expected #{this} not to be close to " + expected + " +/- " + delta
|
|
3123
|
+
);
|
|
3124
|
+
}
|
|
3125
|
+
__name(closeTo, "closeTo");
|
|
3126
|
+
Assertion.addMethod("closeTo", closeTo);
|
|
3127
|
+
Assertion.addMethod("approximately", closeTo);
|
|
3128
|
+
function isSubsetOf(subset, superset, cmp, contains, ordered) {
|
|
3129
|
+
if (!contains) {
|
|
3130
|
+
if (subset.length !== superset.length)
|
|
3131
|
+
return false;
|
|
3132
|
+
superset = superset.slice();
|
|
3133
|
+
}
|
|
3134
|
+
return subset.every(function(elem, idx) {
|
|
3135
|
+
if (ordered)
|
|
3136
|
+
return cmp ? cmp(elem, superset[idx]) : elem === superset[idx];
|
|
3137
|
+
if (!cmp) {
|
|
3138
|
+
var matchIdx = superset.indexOf(elem);
|
|
3139
|
+
if (matchIdx === -1)
|
|
3140
|
+
return false;
|
|
3141
|
+
if (!contains)
|
|
3142
|
+
superset.splice(matchIdx, 1);
|
|
3143
|
+
return true;
|
|
3144
|
+
}
|
|
3145
|
+
return superset.some(function(elem2, matchIdx2) {
|
|
3146
|
+
if (!cmp(elem, elem2))
|
|
3147
|
+
return false;
|
|
3148
|
+
if (!contains)
|
|
3149
|
+
superset.splice(matchIdx2, 1);
|
|
3150
|
+
return true;
|
|
3151
|
+
});
|
|
3152
|
+
});
|
|
3153
|
+
}
|
|
3154
|
+
__name(isSubsetOf, "isSubsetOf");
|
|
3155
|
+
Assertion.addMethod("members", function(subset, msg) {
|
|
3156
|
+
if (msg)
|
|
3157
|
+
flag2(this, "message", msg);
|
|
3158
|
+
var obj = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
|
|
3159
|
+
new Assertion(obj, flagMsg, ssfi, true).to.be.an("array");
|
|
3160
|
+
new Assertion(subset, flagMsg, ssfi, true).to.be.an("array");
|
|
3161
|
+
var contains = flag2(this, "contains");
|
|
3162
|
+
var ordered = flag2(this, "ordered");
|
|
3163
|
+
var subject, failMsg, failNegateMsg;
|
|
3164
|
+
if (contains) {
|
|
3165
|
+
subject = ordered ? "an ordered superset" : "a superset";
|
|
3166
|
+
failMsg = "expected #{this} to be " + subject + " of #{exp}";
|
|
3167
|
+
failNegateMsg = "expected #{this} to not be " + subject + " of #{exp}";
|
|
3168
|
+
} else {
|
|
3169
|
+
subject = ordered ? "ordered members" : "members";
|
|
3170
|
+
failMsg = "expected #{this} to have the same " + subject + " as #{exp}";
|
|
3171
|
+
failNegateMsg = "expected #{this} to not have the same " + subject + " as #{exp}";
|
|
3172
|
+
}
|
|
3173
|
+
var cmp = flag2(this, "deep") ? import_deep_eql.default : void 0;
|
|
3174
|
+
this.assert(
|
|
3175
|
+
isSubsetOf(subset, obj, cmp, contains, ordered),
|
|
3176
|
+
failMsg,
|
|
3177
|
+
failNegateMsg,
|
|
3178
|
+
subset,
|
|
3179
|
+
obj,
|
|
3180
|
+
true
|
|
3181
|
+
);
|
|
3182
|
+
});
|
|
3183
|
+
function oneOf(list, msg) {
|
|
3184
|
+
if (msg)
|
|
3185
|
+
flag2(this, "message", msg);
|
|
3186
|
+
var expected = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi"), contains = flag2(this, "contains"), isDeep = flag2(this, "deep");
|
|
3187
|
+
new Assertion(list, flagMsg, ssfi, true).to.be.an("array");
|
|
3188
|
+
if (contains) {
|
|
3189
|
+
this.assert(
|
|
3190
|
+
list.some(function(possibility) {
|
|
3191
|
+
return expected.indexOf(possibility) > -1;
|
|
3192
|
+
}),
|
|
3193
|
+
"expected #{this} to contain one of #{exp}",
|
|
3194
|
+
"expected #{this} to not contain one of #{exp}",
|
|
3195
|
+
list,
|
|
3196
|
+
expected
|
|
3197
|
+
);
|
|
3198
|
+
} else {
|
|
3199
|
+
if (isDeep) {
|
|
3200
|
+
this.assert(
|
|
3201
|
+
list.some(function(possibility) {
|
|
3202
|
+
return import_deep_eql.default(expected, possibility);
|
|
3203
|
+
}),
|
|
3204
|
+
"expected #{this} to deeply equal one of #{exp}",
|
|
3205
|
+
"expected #{this} to deeply equal one of #{exp}",
|
|
3206
|
+
list,
|
|
3207
|
+
expected
|
|
3208
|
+
);
|
|
3209
|
+
} else {
|
|
3210
|
+
this.assert(
|
|
3211
|
+
list.indexOf(expected) > -1,
|
|
3212
|
+
"expected #{this} to be one of #{exp}",
|
|
3213
|
+
"expected #{this} to not be one of #{exp}",
|
|
3214
|
+
list,
|
|
3215
|
+
expected
|
|
3216
|
+
);
|
|
3217
|
+
}
|
|
3218
|
+
}
|
|
3219
|
+
}
|
|
3220
|
+
__name(oneOf, "oneOf");
|
|
3221
|
+
Assertion.addMethod("oneOf", oneOf);
|
|
3222
|
+
function assertChanges(subject, prop, msg) {
|
|
3223
|
+
if (msg)
|
|
3224
|
+
flag2(this, "message", msg);
|
|
3225
|
+
var fn = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
|
|
3226
|
+
new Assertion(fn, flagMsg, ssfi, true).is.a("function");
|
|
3227
|
+
var initial;
|
|
3228
|
+
if (!prop) {
|
|
3229
|
+
new Assertion(subject, flagMsg, ssfi, true).is.a("function");
|
|
3230
|
+
initial = subject();
|
|
3231
|
+
} else {
|
|
3232
|
+
new Assertion(subject, flagMsg, ssfi, true).to.have.property(prop);
|
|
3233
|
+
initial = subject[prop];
|
|
3234
|
+
}
|
|
3235
|
+
fn();
|
|
3236
|
+
var final = prop === void 0 || prop === null ? subject() : subject[prop];
|
|
3237
|
+
var msgObj = prop === void 0 || prop === null ? initial : "." + prop;
|
|
3238
|
+
flag2(this, "deltaMsgObj", msgObj);
|
|
3239
|
+
flag2(this, "initialDeltaValue", initial);
|
|
3240
|
+
flag2(this, "finalDeltaValue", final);
|
|
3241
|
+
flag2(this, "deltaBehavior", "change");
|
|
3242
|
+
flag2(this, "realDelta", final !== initial);
|
|
3243
|
+
this.assert(
|
|
3244
|
+
initial !== final,
|
|
3245
|
+
"expected " + msgObj + " to change",
|
|
3246
|
+
"expected " + msgObj + " to not change"
|
|
3247
|
+
);
|
|
3248
|
+
}
|
|
3249
|
+
__name(assertChanges, "assertChanges");
|
|
3250
|
+
Assertion.addMethod("change", assertChanges);
|
|
3251
|
+
Assertion.addMethod("changes", assertChanges);
|
|
3252
|
+
function assertIncreases(subject, prop, msg) {
|
|
3253
|
+
if (msg)
|
|
3254
|
+
flag2(this, "message", msg);
|
|
3255
|
+
var fn = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
|
|
3256
|
+
new Assertion(fn, flagMsg, ssfi, true).is.a("function");
|
|
3257
|
+
var initial;
|
|
3258
|
+
if (!prop) {
|
|
3259
|
+
new Assertion(subject, flagMsg, ssfi, true).is.a("function");
|
|
3260
|
+
initial = subject();
|
|
3261
|
+
} else {
|
|
3262
|
+
new Assertion(subject, flagMsg, ssfi, true).to.have.property(prop);
|
|
3263
|
+
initial = subject[prop];
|
|
3264
|
+
}
|
|
3265
|
+
new Assertion(initial, flagMsg, ssfi, true).is.a("number");
|
|
3266
|
+
fn();
|
|
3267
|
+
var final = prop === void 0 || prop === null ? subject() : subject[prop];
|
|
3268
|
+
var msgObj = prop === void 0 || prop === null ? initial : "." + prop;
|
|
3269
|
+
flag2(this, "deltaMsgObj", msgObj);
|
|
3270
|
+
flag2(this, "initialDeltaValue", initial);
|
|
3271
|
+
flag2(this, "finalDeltaValue", final);
|
|
3272
|
+
flag2(this, "deltaBehavior", "increase");
|
|
3273
|
+
flag2(this, "realDelta", final - initial);
|
|
3274
|
+
this.assert(
|
|
3275
|
+
final - initial > 0,
|
|
3276
|
+
"expected " + msgObj + " to increase",
|
|
3277
|
+
"expected " + msgObj + " to not increase"
|
|
3278
|
+
);
|
|
3279
|
+
}
|
|
3280
|
+
__name(assertIncreases, "assertIncreases");
|
|
3281
|
+
Assertion.addMethod("increase", assertIncreases);
|
|
3282
|
+
Assertion.addMethod("increases", assertIncreases);
|
|
3283
|
+
function assertDecreases(subject, prop, msg) {
|
|
3284
|
+
if (msg)
|
|
3285
|
+
flag2(this, "message", msg);
|
|
3286
|
+
var fn = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
|
|
3287
|
+
new Assertion(fn, flagMsg, ssfi, true).is.a("function");
|
|
3288
|
+
var initial;
|
|
3289
|
+
if (!prop) {
|
|
3290
|
+
new Assertion(subject, flagMsg, ssfi, true).is.a("function");
|
|
3291
|
+
initial = subject();
|
|
3292
|
+
} else {
|
|
3293
|
+
new Assertion(subject, flagMsg, ssfi, true).to.have.property(prop);
|
|
3294
|
+
initial = subject[prop];
|
|
3295
|
+
}
|
|
3296
|
+
new Assertion(initial, flagMsg, ssfi, true).is.a("number");
|
|
3297
|
+
fn();
|
|
3298
|
+
var final = prop === void 0 || prop === null ? subject() : subject[prop];
|
|
3299
|
+
var msgObj = prop === void 0 || prop === null ? initial : "." + prop;
|
|
3300
|
+
flag2(this, "deltaMsgObj", msgObj);
|
|
3301
|
+
flag2(this, "initialDeltaValue", initial);
|
|
3302
|
+
flag2(this, "finalDeltaValue", final);
|
|
3303
|
+
flag2(this, "deltaBehavior", "decrease");
|
|
3304
|
+
flag2(this, "realDelta", initial - final);
|
|
3305
|
+
this.assert(
|
|
3306
|
+
final - initial < 0,
|
|
3307
|
+
"expected " + msgObj + " to decrease",
|
|
3308
|
+
"expected " + msgObj + " to not decrease"
|
|
3309
|
+
);
|
|
3310
|
+
}
|
|
3311
|
+
__name(assertDecreases, "assertDecreases");
|
|
3312
|
+
Assertion.addMethod("decrease", assertDecreases);
|
|
3313
|
+
Assertion.addMethod("decreases", assertDecreases);
|
|
3314
|
+
function assertDelta(delta, msg) {
|
|
3315
|
+
if (msg)
|
|
3316
|
+
flag2(this, "message", msg);
|
|
3317
|
+
var msgObj = flag2(this, "deltaMsgObj");
|
|
3318
|
+
var initial = flag2(this, "initialDeltaValue");
|
|
3319
|
+
var final = flag2(this, "finalDeltaValue");
|
|
3320
|
+
var behavior = flag2(this, "deltaBehavior");
|
|
3321
|
+
var realDelta = flag2(this, "realDelta");
|
|
3322
|
+
var expression;
|
|
3323
|
+
if (behavior === "change") {
|
|
3324
|
+
expression = Math.abs(final - initial) === Math.abs(delta);
|
|
3325
|
+
} else {
|
|
3326
|
+
expression = realDelta === Math.abs(delta);
|
|
3327
|
+
}
|
|
3328
|
+
this.assert(
|
|
3329
|
+
expression,
|
|
3330
|
+
"expected " + msgObj + " to " + behavior + " by " + delta,
|
|
3331
|
+
"expected " + msgObj + " to not " + behavior + " by " + delta
|
|
3332
|
+
);
|
|
3333
|
+
}
|
|
3334
|
+
__name(assertDelta, "assertDelta");
|
|
3335
|
+
Assertion.addMethod("by", assertDelta);
|
|
3336
|
+
Assertion.addProperty("extensible", function() {
|
|
3337
|
+
var obj = flag2(this, "object");
|
|
3338
|
+
var isExtensible = obj === Object(obj) && Object.isExtensible(obj);
|
|
3339
|
+
this.assert(
|
|
3340
|
+
isExtensible,
|
|
3341
|
+
"expected #{this} to be extensible",
|
|
3342
|
+
"expected #{this} to not be extensible"
|
|
3343
|
+
);
|
|
3344
|
+
});
|
|
3345
|
+
Assertion.addProperty("sealed", function() {
|
|
3346
|
+
var obj = flag2(this, "object");
|
|
3347
|
+
var isSealed = obj === Object(obj) ? Object.isSealed(obj) : true;
|
|
3348
|
+
this.assert(
|
|
3349
|
+
isSealed,
|
|
3350
|
+
"expected #{this} to be sealed",
|
|
3351
|
+
"expected #{this} to not be sealed"
|
|
3352
|
+
);
|
|
3353
|
+
});
|
|
3354
|
+
Assertion.addProperty("frozen", function() {
|
|
3355
|
+
var obj = flag2(this, "object");
|
|
3356
|
+
var isFrozen = obj === Object(obj) ? Object.isFrozen(obj) : true;
|
|
3357
|
+
this.assert(
|
|
3358
|
+
isFrozen,
|
|
3359
|
+
"expected #{this} to be frozen",
|
|
3360
|
+
"expected #{this} to not be frozen"
|
|
3361
|
+
);
|
|
3362
|
+
});
|
|
3363
|
+
Assertion.addProperty("finite", function(msg) {
|
|
3364
|
+
var obj = flag2(this, "object");
|
|
3365
|
+
this.assert(
|
|
3366
|
+
typeof obj === "number" && isFinite(obj),
|
|
3367
|
+
"expected #{this} to be a finite number",
|
|
3368
|
+
"expected #{this} to not be a finite number"
|
|
3369
|
+
);
|
|
3370
|
+
});
|
|
3371
|
+
|
|
3372
|
+
// lib/chai/interface/expect.js
|
|
3373
|
+
var import_assertion_error4 = __toESM(require_assertion_error(), 1);
|
|
3374
|
+
function expect(val, message) {
|
|
3375
|
+
return new Assertion(val, message);
|
|
3376
|
+
}
|
|
3377
|
+
__name(expect, "expect");
|
|
3378
|
+
expect.fail = function(actual, expected, message, operator) {
|
|
3379
|
+
if (arguments.length < 2) {
|
|
3380
|
+
message = actual;
|
|
3381
|
+
actual = void 0;
|
|
3382
|
+
}
|
|
3383
|
+
message = message || "expect.fail()";
|
|
3384
|
+
throw new import_assertion_error4.default(message, {
|
|
3385
|
+
actual,
|
|
3386
|
+
expected,
|
|
3387
|
+
operator
|
|
3388
|
+
}, chai.expect.fail);
|
|
3389
|
+
};
|
|
3390
|
+
|
|
3391
|
+
// lib/chai/interface/should.js
|
|
3392
|
+
var should_exports = {};
|
|
3393
|
+
__export(should_exports, {
|
|
3394
|
+
Should: () => Should,
|
|
3395
|
+
should: () => should
|
|
3396
|
+
});
|
|
3397
|
+
var import_assertion_error5 = __toESM(require_assertion_error(), 1);
|
|
3398
|
+
function loadShould() {
|
|
3399
|
+
function shouldGetter() {
|
|
3400
|
+
if (this instanceof String || this instanceof Number || this instanceof Boolean || typeof Symbol === "function" && this instanceof Symbol || typeof BigInt === "function" && this instanceof BigInt) {
|
|
3401
|
+
return new Assertion(this.valueOf(), null, shouldGetter);
|
|
3402
|
+
}
|
|
3403
|
+
return new Assertion(this, null, shouldGetter);
|
|
3404
|
+
}
|
|
3405
|
+
__name(shouldGetter, "shouldGetter");
|
|
3406
|
+
function shouldSetter(value) {
|
|
3407
|
+
Object.defineProperty(this, "should", {
|
|
3408
|
+
value,
|
|
3409
|
+
enumerable: true,
|
|
3410
|
+
configurable: true,
|
|
3411
|
+
writable: true
|
|
3412
|
+
});
|
|
3413
|
+
}
|
|
3414
|
+
__name(shouldSetter, "shouldSetter");
|
|
3415
|
+
Object.defineProperty(Object.prototype, "should", {
|
|
3416
|
+
set: shouldSetter,
|
|
3417
|
+
get: shouldGetter,
|
|
3418
|
+
configurable: true
|
|
3419
|
+
});
|
|
3420
|
+
var should2 = {};
|
|
3421
|
+
should2.fail = function(actual, expected, message, operator) {
|
|
3422
|
+
if (arguments.length < 2) {
|
|
3423
|
+
message = actual;
|
|
3424
|
+
actual = void 0;
|
|
3425
|
+
}
|
|
3426
|
+
message = message || "should.fail()";
|
|
3427
|
+
throw new import_assertion_error5.default(message, {
|
|
3428
|
+
actual,
|
|
3429
|
+
expected,
|
|
3430
|
+
operator
|
|
3431
|
+
}, should2.fail);
|
|
3432
|
+
};
|
|
3433
|
+
should2.equal = function(val1, val2, msg) {
|
|
3434
|
+
new Assertion(val1, msg).to.equal(val2);
|
|
3435
|
+
};
|
|
3436
|
+
should2.Throw = function(fn, errt, errs, msg) {
|
|
3437
|
+
new Assertion(fn, msg).to.Throw(errt, errs);
|
|
3438
|
+
};
|
|
3439
|
+
should2.exist = function(val, msg) {
|
|
3440
|
+
new Assertion(val, msg).to.exist;
|
|
3441
|
+
};
|
|
3442
|
+
should2.not = {};
|
|
3443
|
+
should2.not.equal = function(val1, val2, msg) {
|
|
3444
|
+
new Assertion(val1, msg).to.not.equal(val2);
|
|
3445
|
+
};
|
|
3446
|
+
should2.not.Throw = function(fn, errt, errs, msg) {
|
|
3447
|
+
new Assertion(fn, msg).to.not.Throw(errt, errs);
|
|
3448
|
+
};
|
|
3449
|
+
should2.not.exist = function(val, msg) {
|
|
3450
|
+
new Assertion(val, msg).to.not.exist;
|
|
3451
|
+
};
|
|
3452
|
+
should2["throw"] = should2["Throw"];
|
|
3453
|
+
should2.not["throw"] = should2.not["Throw"];
|
|
3454
|
+
return should2;
|
|
3455
|
+
}
|
|
3456
|
+
__name(loadShould, "loadShould");
|
|
3457
|
+
var should = loadShould;
|
|
3458
|
+
var Should = loadShould;
|
|
3459
|
+
|
|
3460
|
+
// lib/chai/interface/assert.js
|
|
3461
|
+
var import_assertion_error6 = __toESM(require_assertion_error(), 1);
|
|
3462
|
+
function assert(express, errmsg) {
|
|
3463
|
+
var test2 = new Assertion(null, null, chai.assert, true);
|
|
3464
|
+
test2.assert(
|
|
3465
|
+
express,
|
|
3466
|
+
errmsg,
|
|
3467
|
+
"[ negation message unavailable ]"
|
|
3468
|
+
);
|
|
3469
|
+
}
|
|
3470
|
+
__name(assert, "assert");
|
|
3471
|
+
assert.fail = function(actual, expected, message, operator) {
|
|
3472
|
+
if (arguments.length < 2) {
|
|
3473
|
+
message = actual;
|
|
3474
|
+
actual = void 0;
|
|
3475
|
+
}
|
|
3476
|
+
message = message || "assert.fail()";
|
|
3477
|
+
throw new import_assertion_error6.default(message, {
|
|
3478
|
+
actual,
|
|
3479
|
+
expected,
|
|
3480
|
+
operator
|
|
3481
|
+
}, assert.fail);
|
|
3482
|
+
};
|
|
3483
|
+
assert.isOk = function(val, msg) {
|
|
3484
|
+
new Assertion(val, msg, assert.isOk, true).is.ok;
|
|
3485
|
+
};
|
|
3486
|
+
assert.isNotOk = function(val, msg) {
|
|
3487
|
+
new Assertion(val, msg, assert.isNotOk, true).is.not.ok;
|
|
3488
|
+
};
|
|
3489
|
+
assert.equal = function(act, exp, msg) {
|
|
3490
|
+
var test2 = new Assertion(act, msg, assert.equal, true);
|
|
3491
|
+
test2.assert(
|
|
3492
|
+
exp == flag(test2, "object"),
|
|
3493
|
+
"expected #{this} to equal #{exp}",
|
|
3494
|
+
"expected #{this} to not equal #{act}",
|
|
3495
|
+
exp,
|
|
3496
|
+
act,
|
|
3497
|
+
true
|
|
3498
|
+
);
|
|
3499
|
+
};
|
|
3500
|
+
assert.notEqual = function(act, exp, msg) {
|
|
3501
|
+
var test2 = new Assertion(act, msg, assert.notEqual, true);
|
|
3502
|
+
test2.assert(
|
|
3503
|
+
exp != flag(test2, "object"),
|
|
3504
|
+
"expected #{this} to not equal #{exp}",
|
|
3505
|
+
"expected #{this} to equal #{act}",
|
|
3506
|
+
exp,
|
|
3507
|
+
act,
|
|
3508
|
+
true
|
|
3509
|
+
);
|
|
3510
|
+
};
|
|
3511
|
+
assert.strictEqual = function(act, exp, msg) {
|
|
3512
|
+
new Assertion(act, msg, assert.strictEqual, true).to.equal(exp);
|
|
3513
|
+
};
|
|
3514
|
+
assert.notStrictEqual = function(act, exp, msg) {
|
|
3515
|
+
new Assertion(act, msg, assert.notStrictEqual, true).to.not.equal(exp);
|
|
3516
|
+
};
|
|
3517
|
+
assert.deepEqual = assert.deepStrictEqual = function(act, exp, msg) {
|
|
3518
|
+
new Assertion(act, msg, assert.deepEqual, true).to.eql(exp);
|
|
3519
|
+
};
|
|
3520
|
+
assert.notDeepEqual = function(act, exp, msg) {
|
|
3521
|
+
new Assertion(act, msg, assert.notDeepEqual, true).to.not.eql(exp);
|
|
3522
|
+
};
|
|
3523
|
+
assert.isAbove = function(val, abv, msg) {
|
|
3524
|
+
new Assertion(val, msg, assert.isAbove, true).to.be.above(abv);
|
|
3525
|
+
};
|
|
3526
|
+
assert.isAtLeast = function(val, atlst, msg) {
|
|
3527
|
+
new Assertion(val, msg, assert.isAtLeast, true).to.be.least(atlst);
|
|
3528
|
+
};
|
|
3529
|
+
assert.isBelow = function(val, blw, msg) {
|
|
3530
|
+
new Assertion(val, msg, assert.isBelow, true).to.be.below(blw);
|
|
3531
|
+
};
|
|
3532
|
+
assert.isAtMost = function(val, atmst, msg) {
|
|
3533
|
+
new Assertion(val, msg, assert.isAtMost, true).to.be.most(atmst);
|
|
3534
|
+
};
|
|
3535
|
+
assert.isTrue = function(val, msg) {
|
|
3536
|
+
new Assertion(val, msg, assert.isTrue, true).is["true"];
|
|
3537
|
+
};
|
|
3538
|
+
assert.isNotTrue = function(val, msg) {
|
|
3539
|
+
new Assertion(val, msg, assert.isNotTrue, true).to.not.equal(true);
|
|
3540
|
+
};
|
|
3541
|
+
assert.isFalse = function(val, msg) {
|
|
3542
|
+
new Assertion(val, msg, assert.isFalse, true).is["false"];
|
|
3543
|
+
};
|
|
3544
|
+
assert.isNotFalse = function(val, msg) {
|
|
3545
|
+
new Assertion(val, msg, assert.isNotFalse, true).to.not.equal(false);
|
|
3546
|
+
};
|
|
3547
|
+
assert.isNull = function(val, msg) {
|
|
3548
|
+
new Assertion(val, msg, assert.isNull, true).to.equal(null);
|
|
3549
|
+
};
|
|
3550
|
+
assert.isNotNull = function(val, msg) {
|
|
3551
|
+
new Assertion(val, msg, assert.isNotNull, true).to.not.equal(null);
|
|
3552
|
+
};
|
|
3553
|
+
assert.isNaN = function(val, msg) {
|
|
3554
|
+
new Assertion(val, msg, assert.isNaN, true).to.be.NaN;
|
|
3555
|
+
};
|
|
3556
|
+
assert.isNotNaN = function(val, msg) {
|
|
3557
|
+
new Assertion(val, msg, assert.isNotNaN, true).not.to.be.NaN;
|
|
3558
|
+
};
|
|
3559
|
+
assert.exists = function(val, msg) {
|
|
3560
|
+
new Assertion(val, msg, assert.exists, true).to.exist;
|
|
3561
|
+
};
|
|
3562
|
+
assert.notExists = function(val, msg) {
|
|
3563
|
+
new Assertion(val, msg, assert.notExists, true).to.not.exist;
|
|
3564
|
+
};
|
|
3565
|
+
assert.isUndefined = function(val, msg) {
|
|
3566
|
+
new Assertion(val, msg, assert.isUndefined, true).to.equal(void 0);
|
|
3567
|
+
};
|
|
3568
|
+
assert.isDefined = function(val, msg) {
|
|
3569
|
+
new Assertion(val, msg, assert.isDefined, true).to.not.equal(void 0);
|
|
3570
|
+
};
|
|
3571
|
+
assert.isFunction = function(val, msg) {
|
|
3572
|
+
new Assertion(val, msg, assert.isFunction, true).to.be.a("function");
|
|
3573
|
+
};
|
|
3574
|
+
assert.isNotFunction = function(val, msg) {
|
|
3575
|
+
new Assertion(val, msg, assert.isNotFunction, true).to.not.be.a("function");
|
|
3576
|
+
};
|
|
3577
|
+
assert.isObject = function(val, msg) {
|
|
3578
|
+
new Assertion(val, msg, assert.isObject, true).to.be.a("object");
|
|
3579
|
+
};
|
|
3580
|
+
assert.isNotObject = function(val, msg) {
|
|
3581
|
+
new Assertion(val, msg, assert.isNotObject, true).to.not.be.a("object");
|
|
3582
|
+
};
|
|
3583
|
+
assert.isArray = function(val, msg) {
|
|
3584
|
+
new Assertion(val, msg, assert.isArray, true).to.be.an("array");
|
|
3585
|
+
};
|
|
3586
|
+
assert.isNotArray = function(val, msg) {
|
|
3587
|
+
new Assertion(val, msg, assert.isNotArray, true).to.not.be.an("array");
|
|
3588
|
+
};
|
|
3589
|
+
assert.isString = function(val, msg) {
|
|
3590
|
+
new Assertion(val, msg, assert.isString, true).to.be.a("string");
|
|
3591
|
+
};
|
|
3592
|
+
assert.isNotString = function(val, msg) {
|
|
3593
|
+
new Assertion(val, msg, assert.isNotString, true).to.not.be.a("string");
|
|
3594
|
+
};
|
|
3595
|
+
assert.isNumber = function(val, msg) {
|
|
3596
|
+
new Assertion(val, msg, assert.isNumber, true).to.be.a("number");
|
|
3597
|
+
};
|
|
3598
|
+
assert.isNotNumber = function(val, msg) {
|
|
3599
|
+
new Assertion(val, msg, assert.isNotNumber, true).to.not.be.a("number");
|
|
3600
|
+
};
|
|
3601
|
+
assert.isFinite = function(val, msg) {
|
|
3602
|
+
new Assertion(val, msg, assert.isFinite, true).to.be.finite;
|
|
3603
|
+
};
|
|
3604
|
+
assert.isBoolean = function(val, msg) {
|
|
3605
|
+
new Assertion(val, msg, assert.isBoolean, true).to.be.a("boolean");
|
|
3606
|
+
};
|
|
3607
|
+
assert.isNotBoolean = function(val, msg) {
|
|
3608
|
+
new Assertion(val, msg, assert.isNotBoolean, true).to.not.be.a("boolean");
|
|
3609
|
+
};
|
|
3610
|
+
assert.typeOf = function(val, type3, msg) {
|
|
3611
|
+
new Assertion(val, msg, assert.typeOf, true).to.be.a(type3);
|
|
3612
|
+
};
|
|
3613
|
+
assert.notTypeOf = function(val, type3, msg) {
|
|
3614
|
+
new Assertion(val, msg, assert.notTypeOf, true).to.not.be.a(type3);
|
|
3615
|
+
};
|
|
3616
|
+
assert.instanceOf = function(val, type3, msg) {
|
|
3617
|
+
new Assertion(val, msg, assert.instanceOf, true).to.be.instanceOf(type3);
|
|
3618
|
+
};
|
|
3619
|
+
assert.notInstanceOf = function(val, type3, msg) {
|
|
3620
|
+
new Assertion(val, msg, assert.notInstanceOf, true).to.not.be.instanceOf(type3);
|
|
3621
|
+
};
|
|
3622
|
+
assert.include = function(exp, inc, msg) {
|
|
3623
|
+
new Assertion(exp, msg, assert.include, true).include(inc);
|
|
3624
|
+
};
|
|
3625
|
+
assert.notInclude = function(exp, inc, msg) {
|
|
3626
|
+
new Assertion(exp, msg, assert.notInclude, true).not.include(inc);
|
|
3627
|
+
};
|
|
3628
|
+
assert.deepInclude = function(exp, inc, msg) {
|
|
3629
|
+
new Assertion(exp, msg, assert.deepInclude, true).deep.include(inc);
|
|
3630
|
+
};
|
|
3631
|
+
assert.notDeepInclude = function(exp, inc, msg) {
|
|
3632
|
+
new Assertion(exp, msg, assert.notDeepInclude, true).not.deep.include(inc);
|
|
3633
|
+
};
|
|
3634
|
+
assert.nestedInclude = function(exp, inc, msg) {
|
|
3635
|
+
new Assertion(exp, msg, assert.nestedInclude, true).nested.include(inc);
|
|
3636
|
+
};
|
|
3637
|
+
assert.notNestedInclude = function(exp, inc, msg) {
|
|
3638
|
+
new Assertion(exp, msg, assert.notNestedInclude, true).not.nested.include(inc);
|
|
3639
|
+
};
|
|
3640
|
+
assert.deepNestedInclude = function(exp, inc, msg) {
|
|
3641
|
+
new Assertion(exp, msg, assert.deepNestedInclude, true).deep.nested.include(inc);
|
|
3642
|
+
};
|
|
3643
|
+
assert.notDeepNestedInclude = function(exp, inc, msg) {
|
|
3644
|
+
new Assertion(exp, msg, assert.notDeepNestedInclude, true).not.deep.nested.include(inc);
|
|
3645
|
+
};
|
|
3646
|
+
assert.ownInclude = function(exp, inc, msg) {
|
|
3647
|
+
new Assertion(exp, msg, assert.ownInclude, true).own.include(inc);
|
|
3648
|
+
};
|
|
3649
|
+
assert.notOwnInclude = function(exp, inc, msg) {
|
|
3650
|
+
new Assertion(exp, msg, assert.notOwnInclude, true).not.own.include(inc);
|
|
3651
|
+
};
|
|
3652
|
+
assert.deepOwnInclude = function(exp, inc, msg) {
|
|
3653
|
+
new Assertion(exp, msg, assert.deepOwnInclude, true).deep.own.include(inc);
|
|
3654
|
+
};
|
|
3655
|
+
assert.notDeepOwnInclude = function(exp, inc, msg) {
|
|
3656
|
+
new Assertion(exp, msg, assert.notDeepOwnInclude, true).not.deep.own.include(inc);
|
|
3657
|
+
};
|
|
3658
|
+
assert.match = function(exp, re, msg) {
|
|
3659
|
+
new Assertion(exp, msg, assert.match, true).to.match(re);
|
|
3660
|
+
};
|
|
3661
|
+
assert.notMatch = function(exp, re, msg) {
|
|
3662
|
+
new Assertion(exp, msg, assert.notMatch, true).to.not.match(re);
|
|
3663
|
+
};
|
|
3664
|
+
assert.property = function(obj, prop, msg) {
|
|
3665
|
+
new Assertion(obj, msg, assert.property, true).to.have.property(prop);
|
|
3666
|
+
};
|
|
3667
|
+
assert.notProperty = function(obj, prop, msg) {
|
|
3668
|
+
new Assertion(obj, msg, assert.notProperty, true).to.not.have.property(prop);
|
|
3669
|
+
};
|
|
3670
|
+
assert.propertyVal = function(obj, prop, val, msg) {
|
|
3671
|
+
new Assertion(obj, msg, assert.propertyVal, true).to.have.property(prop, val);
|
|
3672
|
+
};
|
|
3673
|
+
assert.notPropertyVal = function(obj, prop, val, msg) {
|
|
3674
|
+
new Assertion(obj, msg, assert.notPropertyVal, true).to.not.have.property(prop, val);
|
|
3675
|
+
};
|
|
3676
|
+
assert.deepPropertyVal = function(obj, prop, val, msg) {
|
|
3677
|
+
new Assertion(obj, msg, assert.deepPropertyVal, true).to.have.deep.property(prop, val);
|
|
3678
|
+
};
|
|
3679
|
+
assert.notDeepPropertyVal = function(obj, prop, val, msg) {
|
|
3680
|
+
new Assertion(obj, msg, assert.notDeepPropertyVal, true).to.not.have.deep.property(prop, val);
|
|
3681
|
+
};
|
|
3682
|
+
assert.ownProperty = function(obj, prop, msg) {
|
|
3683
|
+
new Assertion(obj, msg, assert.ownProperty, true).to.have.own.property(prop);
|
|
3684
|
+
};
|
|
3685
|
+
assert.notOwnProperty = function(obj, prop, msg) {
|
|
3686
|
+
new Assertion(obj, msg, assert.notOwnProperty, true).to.not.have.own.property(prop);
|
|
3687
|
+
};
|
|
3688
|
+
assert.ownPropertyVal = function(obj, prop, value, msg) {
|
|
3689
|
+
new Assertion(obj, msg, assert.ownPropertyVal, true).to.have.own.property(prop, value);
|
|
3690
|
+
};
|
|
3691
|
+
assert.notOwnPropertyVal = function(obj, prop, value, msg) {
|
|
3692
|
+
new Assertion(obj, msg, assert.notOwnPropertyVal, true).to.not.have.own.property(prop, value);
|
|
3693
|
+
};
|
|
3694
|
+
assert.deepOwnPropertyVal = function(obj, prop, value, msg) {
|
|
3695
|
+
new Assertion(obj, msg, assert.deepOwnPropertyVal, true).to.have.deep.own.property(prop, value);
|
|
3696
|
+
};
|
|
3697
|
+
assert.notDeepOwnPropertyVal = function(obj, prop, value, msg) {
|
|
3698
|
+
new Assertion(obj, msg, assert.notDeepOwnPropertyVal, true).to.not.have.deep.own.property(prop, value);
|
|
3699
|
+
};
|
|
3700
|
+
assert.nestedProperty = function(obj, prop, msg) {
|
|
3701
|
+
new Assertion(obj, msg, assert.nestedProperty, true).to.have.nested.property(prop);
|
|
3702
|
+
};
|
|
3703
|
+
assert.notNestedProperty = function(obj, prop, msg) {
|
|
3704
|
+
new Assertion(obj, msg, assert.notNestedProperty, true).to.not.have.nested.property(prop);
|
|
3705
|
+
};
|
|
3706
|
+
assert.nestedPropertyVal = function(obj, prop, val, msg) {
|
|
3707
|
+
new Assertion(obj, msg, assert.nestedPropertyVal, true).to.have.nested.property(prop, val);
|
|
3708
|
+
};
|
|
3709
|
+
assert.notNestedPropertyVal = function(obj, prop, val, msg) {
|
|
3710
|
+
new Assertion(obj, msg, assert.notNestedPropertyVal, true).to.not.have.nested.property(prop, val);
|
|
3711
|
+
};
|
|
3712
|
+
assert.deepNestedPropertyVal = function(obj, prop, val, msg) {
|
|
3713
|
+
new Assertion(obj, msg, assert.deepNestedPropertyVal, true).to.have.deep.nested.property(prop, val);
|
|
3714
|
+
};
|
|
3715
|
+
assert.notDeepNestedPropertyVal = function(obj, prop, val, msg) {
|
|
3716
|
+
new Assertion(obj, msg, assert.notDeepNestedPropertyVal, true).to.not.have.deep.nested.property(prop, val);
|
|
3717
|
+
};
|
|
3718
|
+
assert.lengthOf = function(exp, len, msg) {
|
|
3719
|
+
new Assertion(exp, msg, assert.lengthOf, true).to.have.lengthOf(len);
|
|
3720
|
+
};
|
|
3721
|
+
assert.hasAnyKeys = function(obj, keys, msg) {
|
|
3722
|
+
new Assertion(obj, msg, assert.hasAnyKeys, true).to.have.any.keys(keys);
|
|
3723
|
+
};
|
|
3724
|
+
assert.hasAllKeys = function(obj, keys, msg) {
|
|
3725
|
+
new Assertion(obj, msg, assert.hasAllKeys, true).to.have.all.keys(keys);
|
|
3726
|
+
};
|
|
3727
|
+
assert.containsAllKeys = function(obj, keys, msg) {
|
|
3728
|
+
new Assertion(obj, msg, assert.containsAllKeys, true).to.contain.all.keys(keys);
|
|
3729
|
+
};
|
|
3730
|
+
assert.doesNotHaveAnyKeys = function(obj, keys, msg) {
|
|
3731
|
+
new Assertion(obj, msg, assert.doesNotHaveAnyKeys, true).to.not.have.any.keys(keys);
|
|
3732
|
+
};
|
|
3733
|
+
assert.doesNotHaveAllKeys = function(obj, keys, msg) {
|
|
3734
|
+
new Assertion(obj, msg, assert.doesNotHaveAllKeys, true).to.not.have.all.keys(keys);
|
|
3735
|
+
};
|
|
3736
|
+
assert.hasAnyDeepKeys = function(obj, keys, msg) {
|
|
3737
|
+
new Assertion(obj, msg, assert.hasAnyDeepKeys, true).to.have.any.deep.keys(keys);
|
|
3738
|
+
};
|
|
3739
|
+
assert.hasAllDeepKeys = function(obj, keys, msg) {
|
|
3740
|
+
new Assertion(obj, msg, assert.hasAllDeepKeys, true).to.have.all.deep.keys(keys);
|
|
3741
|
+
};
|
|
3742
|
+
assert.containsAllDeepKeys = function(obj, keys, msg) {
|
|
3743
|
+
new Assertion(obj, msg, assert.containsAllDeepKeys, true).to.contain.all.deep.keys(keys);
|
|
3744
|
+
};
|
|
3745
|
+
assert.doesNotHaveAnyDeepKeys = function(obj, keys, msg) {
|
|
3746
|
+
new Assertion(obj, msg, assert.doesNotHaveAnyDeepKeys, true).to.not.have.any.deep.keys(keys);
|
|
3747
|
+
};
|
|
3748
|
+
assert.doesNotHaveAllDeepKeys = function(obj, keys, msg) {
|
|
3749
|
+
new Assertion(obj, msg, assert.doesNotHaveAllDeepKeys, true).to.not.have.all.deep.keys(keys);
|
|
3750
|
+
};
|
|
3751
|
+
assert.throws = function(fn, errorLike, errMsgMatcher, msg) {
|
|
3752
|
+
if ("string" === typeof errorLike || errorLike instanceof RegExp) {
|
|
3753
|
+
errMsgMatcher = errorLike;
|
|
3754
|
+
errorLike = null;
|
|
3755
|
+
}
|
|
3756
|
+
var assertErr = new Assertion(fn, msg, assert.throws, true).to.throw(errorLike, errMsgMatcher);
|
|
3757
|
+
return flag(assertErr, "object");
|
|
3758
|
+
};
|
|
3759
|
+
assert.doesNotThrow = function(fn, errorLike, errMsgMatcher, msg) {
|
|
3760
|
+
if ("string" === typeof errorLike || errorLike instanceof RegExp) {
|
|
3761
|
+
errMsgMatcher = errorLike;
|
|
3762
|
+
errorLike = null;
|
|
3763
|
+
}
|
|
3764
|
+
new Assertion(fn, msg, assert.doesNotThrow, true).to.not.throw(errorLike, errMsgMatcher);
|
|
3765
|
+
};
|
|
3766
|
+
assert.operator = function(val, operator, val2, msg) {
|
|
3767
|
+
var ok;
|
|
3768
|
+
switch (operator) {
|
|
3769
|
+
case "==":
|
|
3770
|
+
ok = val == val2;
|
|
3771
|
+
break;
|
|
3772
|
+
case "===":
|
|
3773
|
+
ok = val === val2;
|
|
3774
|
+
break;
|
|
3775
|
+
case ">":
|
|
3776
|
+
ok = val > val2;
|
|
3777
|
+
break;
|
|
3778
|
+
case ">=":
|
|
3779
|
+
ok = val >= val2;
|
|
3780
|
+
break;
|
|
3781
|
+
case "<":
|
|
3782
|
+
ok = val < val2;
|
|
3783
|
+
break;
|
|
3784
|
+
case "<=":
|
|
3785
|
+
ok = val <= val2;
|
|
3786
|
+
break;
|
|
3787
|
+
case "!=":
|
|
3788
|
+
ok = val != val2;
|
|
3789
|
+
break;
|
|
3790
|
+
case "!==":
|
|
3791
|
+
ok = val !== val2;
|
|
3792
|
+
break;
|
|
3793
|
+
default:
|
|
3794
|
+
msg = msg ? msg + ": " : msg;
|
|
3795
|
+
throw new import_assertion_error6.default(
|
|
3796
|
+
msg + 'Invalid operator "' + operator + '"',
|
|
3797
|
+
void 0,
|
|
3798
|
+
assert.operator
|
|
3799
|
+
);
|
|
3800
|
+
}
|
|
3801
|
+
var test2 = new Assertion(ok, msg, assert.operator, true);
|
|
3802
|
+
test2.assert(
|
|
3803
|
+
true === flag(test2, "object"),
|
|
3804
|
+
"expected " + inspect(val) + " to be " + operator + " " + inspect(val2),
|
|
3805
|
+
"expected " + inspect(val) + " to not be " + operator + " " + inspect(val2)
|
|
3806
|
+
);
|
|
3807
|
+
};
|
|
3808
|
+
assert.closeTo = function(act, exp, delta, msg) {
|
|
3809
|
+
new Assertion(act, msg, assert.closeTo, true).to.be.closeTo(exp, delta);
|
|
3810
|
+
};
|
|
3811
|
+
assert.approximately = function(act, exp, delta, msg) {
|
|
3812
|
+
new Assertion(act, msg, assert.approximately, true).to.be.approximately(exp, delta);
|
|
3813
|
+
};
|
|
3814
|
+
assert.sameMembers = function(set1, set2, msg) {
|
|
3815
|
+
new Assertion(set1, msg, assert.sameMembers, true).to.have.same.members(set2);
|
|
3816
|
+
};
|
|
3817
|
+
assert.notSameMembers = function(set1, set2, msg) {
|
|
3818
|
+
new Assertion(set1, msg, assert.notSameMembers, true).to.not.have.same.members(set2);
|
|
3819
|
+
};
|
|
3820
|
+
assert.sameDeepMembers = function(set1, set2, msg) {
|
|
3821
|
+
new Assertion(set1, msg, assert.sameDeepMembers, true).to.have.same.deep.members(set2);
|
|
3822
|
+
};
|
|
3823
|
+
assert.notSameDeepMembers = function(set1, set2, msg) {
|
|
3824
|
+
new Assertion(set1, msg, assert.notSameDeepMembers, true).to.not.have.same.deep.members(set2);
|
|
3825
|
+
};
|
|
3826
|
+
assert.sameOrderedMembers = function(set1, set2, msg) {
|
|
3827
|
+
new Assertion(set1, msg, assert.sameOrderedMembers, true).to.have.same.ordered.members(set2);
|
|
3828
|
+
};
|
|
3829
|
+
assert.notSameOrderedMembers = function(set1, set2, msg) {
|
|
3830
|
+
new Assertion(set1, msg, assert.notSameOrderedMembers, true).to.not.have.same.ordered.members(set2);
|
|
3831
|
+
};
|
|
3832
|
+
assert.sameDeepOrderedMembers = function(set1, set2, msg) {
|
|
3833
|
+
new Assertion(set1, msg, assert.sameDeepOrderedMembers, true).to.have.same.deep.ordered.members(set2);
|
|
3834
|
+
};
|
|
3835
|
+
assert.notSameDeepOrderedMembers = function(set1, set2, msg) {
|
|
3836
|
+
new Assertion(set1, msg, assert.notSameDeepOrderedMembers, true).to.not.have.same.deep.ordered.members(set2);
|
|
3837
|
+
};
|
|
3838
|
+
assert.includeMembers = function(superset, subset, msg) {
|
|
3839
|
+
new Assertion(superset, msg, assert.includeMembers, true).to.include.members(subset);
|
|
3840
|
+
};
|
|
3841
|
+
assert.notIncludeMembers = function(superset, subset, msg) {
|
|
3842
|
+
new Assertion(superset, msg, assert.notIncludeMembers, true).to.not.include.members(subset);
|
|
3843
|
+
};
|
|
3844
|
+
assert.includeDeepMembers = function(superset, subset, msg) {
|
|
3845
|
+
new Assertion(superset, msg, assert.includeDeepMembers, true).to.include.deep.members(subset);
|
|
3846
|
+
};
|
|
3847
|
+
assert.notIncludeDeepMembers = function(superset, subset, msg) {
|
|
3848
|
+
new Assertion(superset, msg, assert.notIncludeDeepMembers, true).to.not.include.deep.members(subset);
|
|
3849
|
+
};
|
|
3850
|
+
assert.includeOrderedMembers = function(superset, subset, msg) {
|
|
3851
|
+
new Assertion(superset, msg, assert.includeOrderedMembers, true).to.include.ordered.members(subset);
|
|
3852
|
+
};
|
|
3853
|
+
assert.notIncludeOrderedMembers = function(superset, subset, msg) {
|
|
3854
|
+
new Assertion(superset, msg, assert.notIncludeOrderedMembers, true).to.not.include.ordered.members(subset);
|
|
3855
|
+
};
|
|
3856
|
+
assert.includeDeepOrderedMembers = function(superset, subset, msg) {
|
|
3857
|
+
new Assertion(superset, msg, assert.includeDeepOrderedMembers, true).to.include.deep.ordered.members(subset);
|
|
3858
|
+
};
|
|
3859
|
+
assert.notIncludeDeepOrderedMembers = function(superset, subset, msg) {
|
|
3860
|
+
new Assertion(superset, msg, assert.notIncludeDeepOrderedMembers, true).to.not.include.deep.ordered.members(subset);
|
|
3861
|
+
};
|
|
3862
|
+
assert.oneOf = function(inList, list, msg) {
|
|
3863
|
+
new Assertion(inList, msg, assert.oneOf, true).to.be.oneOf(list);
|
|
3864
|
+
};
|
|
3865
|
+
assert.changes = function(fn, obj, prop, msg) {
|
|
3866
|
+
if (arguments.length === 3 && typeof obj === "function") {
|
|
3867
|
+
msg = prop;
|
|
3868
|
+
prop = null;
|
|
3869
|
+
}
|
|
3870
|
+
new Assertion(fn, msg, assert.changes, true).to.change(obj, prop);
|
|
3871
|
+
};
|
|
3872
|
+
assert.changesBy = function(fn, obj, prop, delta, msg) {
|
|
3873
|
+
if (arguments.length === 4 && typeof obj === "function") {
|
|
3874
|
+
var tmpMsg = delta;
|
|
3875
|
+
delta = prop;
|
|
3876
|
+
msg = tmpMsg;
|
|
3877
|
+
} else if (arguments.length === 3) {
|
|
3878
|
+
delta = prop;
|
|
3879
|
+
prop = null;
|
|
3880
|
+
}
|
|
3881
|
+
new Assertion(fn, msg, assert.changesBy, true).to.change(obj, prop).by(delta);
|
|
3882
|
+
};
|
|
3883
|
+
assert.doesNotChange = function(fn, obj, prop, msg) {
|
|
3884
|
+
if (arguments.length === 3 && typeof obj === "function") {
|
|
3885
|
+
msg = prop;
|
|
3886
|
+
prop = null;
|
|
3887
|
+
}
|
|
3888
|
+
return new Assertion(fn, msg, assert.doesNotChange, true).to.not.change(obj, prop);
|
|
3889
|
+
};
|
|
3890
|
+
assert.changesButNotBy = function(fn, obj, prop, delta, msg) {
|
|
3891
|
+
if (arguments.length === 4 && typeof obj === "function") {
|
|
3892
|
+
var tmpMsg = delta;
|
|
3893
|
+
delta = prop;
|
|
3894
|
+
msg = tmpMsg;
|
|
3895
|
+
} else if (arguments.length === 3) {
|
|
3896
|
+
delta = prop;
|
|
3897
|
+
prop = null;
|
|
3898
|
+
}
|
|
3899
|
+
new Assertion(fn, msg, assert.changesButNotBy, true).to.change(obj, prop).but.not.by(delta);
|
|
3900
|
+
};
|
|
3901
|
+
assert.increases = function(fn, obj, prop, msg) {
|
|
3902
|
+
if (arguments.length === 3 && typeof obj === "function") {
|
|
3903
|
+
msg = prop;
|
|
3904
|
+
prop = null;
|
|
3905
|
+
}
|
|
3906
|
+
return new Assertion(fn, msg, assert.increases, true).to.increase(obj, prop);
|
|
3907
|
+
};
|
|
3908
|
+
assert.increasesBy = function(fn, obj, prop, delta, msg) {
|
|
3909
|
+
if (arguments.length === 4 && typeof obj === "function") {
|
|
3910
|
+
var tmpMsg = delta;
|
|
3911
|
+
delta = prop;
|
|
3912
|
+
msg = tmpMsg;
|
|
3913
|
+
} else if (arguments.length === 3) {
|
|
3914
|
+
delta = prop;
|
|
3915
|
+
prop = null;
|
|
3916
|
+
}
|
|
3917
|
+
new Assertion(fn, msg, assert.increasesBy, true).to.increase(obj, prop).by(delta);
|
|
3918
|
+
};
|
|
3919
|
+
assert.doesNotIncrease = function(fn, obj, prop, msg) {
|
|
3920
|
+
if (arguments.length === 3 && typeof obj === "function") {
|
|
3921
|
+
msg = prop;
|
|
3922
|
+
prop = null;
|
|
3923
|
+
}
|
|
3924
|
+
return new Assertion(fn, msg, assert.doesNotIncrease, true).to.not.increase(obj, prop);
|
|
3925
|
+
};
|
|
3926
|
+
assert.increasesButNotBy = function(fn, obj, prop, delta, msg) {
|
|
3927
|
+
if (arguments.length === 4 && typeof obj === "function") {
|
|
3928
|
+
var tmpMsg = delta;
|
|
3929
|
+
delta = prop;
|
|
3930
|
+
msg = tmpMsg;
|
|
3931
|
+
} else if (arguments.length === 3) {
|
|
3932
|
+
delta = prop;
|
|
3933
|
+
prop = null;
|
|
3934
|
+
}
|
|
3935
|
+
new Assertion(fn, msg, assert.increasesButNotBy, true).to.increase(obj, prop).but.not.by(delta);
|
|
3936
|
+
};
|
|
3937
|
+
assert.decreases = function(fn, obj, prop, msg) {
|
|
3938
|
+
if (arguments.length === 3 && typeof obj === "function") {
|
|
3939
|
+
msg = prop;
|
|
3940
|
+
prop = null;
|
|
3941
|
+
}
|
|
3942
|
+
return new Assertion(fn, msg, assert.decreases, true).to.decrease(obj, prop);
|
|
3943
|
+
};
|
|
3944
|
+
assert.decreasesBy = function(fn, obj, prop, delta, msg) {
|
|
3945
|
+
if (arguments.length === 4 && typeof obj === "function") {
|
|
3946
|
+
var tmpMsg = delta;
|
|
3947
|
+
delta = prop;
|
|
3948
|
+
msg = tmpMsg;
|
|
3949
|
+
} else if (arguments.length === 3) {
|
|
3950
|
+
delta = prop;
|
|
3951
|
+
prop = null;
|
|
3952
|
+
}
|
|
3953
|
+
new Assertion(fn, msg, assert.decreasesBy, true).to.decrease(obj, prop).by(delta);
|
|
3954
|
+
};
|
|
3955
|
+
assert.doesNotDecrease = function(fn, obj, prop, msg) {
|
|
3956
|
+
if (arguments.length === 3 && typeof obj === "function") {
|
|
3957
|
+
msg = prop;
|
|
3958
|
+
prop = null;
|
|
3959
|
+
}
|
|
3960
|
+
return new Assertion(fn, msg, assert.doesNotDecrease, true).to.not.decrease(obj, prop);
|
|
3961
|
+
};
|
|
3962
|
+
assert.doesNotDecreaseBy = function(fn, obj, prop, delta, msg) {
|
|
3963
|
+
if (arguments.length === 4 && typeof obj === "function") {
|
|
3964
|
+
var tmpMsg = delta;
|
|
3965
|
+
delta = prop;
|
|
3966
|
+
msg = tmpMsg;
|
|
3967
|
+
} else if (arguments.length === 3) {
|
|
3968
|
+
delta = prop;
|
|
3969
|
+
prop = null;
|
|
3970
|
+
}
|
|
3971
|
+
return new Assertion(fn, msg, assert.doesNotDecreaseBy, true).to.not.decrease(obj, prop).by(delta);
|
|
3972
|
+
};
|
|
3973
|
+
assert.decreasesButNotBy = function(fn, obj, prop, delta, msg) {
|
|
3974
|
+
if (arguments.length === 4 && typeof obj === "function") {
|
|
3975
|
+
var tmpMsg = delta;
|
|
3976
|
+
delta = prop;
|
|
3977
|
+
msg = tmpMsg;
|
|
3978
|
+
} else if (arguments.length === 3) {
|
|
3979
|
+
delta = prop;
|
|
3980
|
+
prop = null;
|
|
3981
|
+
}
|
|
3982
|
+
new Assertion(fn, msg, assert.decreasesButNotBy, true).to.decrease(obj, prop).but.not.by(delta);
|
|
3983
|
+
};
|
|
3984
|
+
assert.ifError = function(val) {
|
|
3985
|
+
if (val) {
|
|
3986
|
+
throw val;
|
|
3987
|
+
}
|
|
3988
|
+
};
|
|
3989
|
+
assert.isExtensible = function(obj, msg) {
|
|
3990
|
+
new Assertion(obj, msg, assert.isExtensible, true).to.be.extensible;
|
|
3991
|
+
};
|
|
3992
|
+
assert.isNotExtensible = function(obj, msg) {
|
|
3993
|
+
new Assertion(obj, msg, assert.isNotExtensible, true).to.not.be.extensible;
|
|
3994
|
+
};
|
|
3995
|
+
assert.isSealed = function(obj, msg) {
|
|
3996
|
+
new Assertion(obj, msg, assert.isSealed, true).to.be.sealed;
|
|
3997
|
+
};
|
|
3998
|
+
assert.isNotSealed = function(obj, msg) {
|
|
3999
|
+
new Assertion(obj, msg, assert.isNotSealed, true).to.not.be.sealed;
|
|
4000
|
+
};
|
|
4001
|
+
assert.isFrozen = function(obj, msg) {
|
|
4002
|
+
new Assertion(obj, msg, assert.isFrozen, true).to.be.frozen;
|
|
4003
|
+
};
|
|
4004
|
+
assert.isNotFrozen = function(obj, msg) {
|
|
4005
|
+
new Assertion(obj, msg, assert.isNotFrozen, true).to.not.be.frozen;
|
|
4006
|
+
};
|
|
4007
|
+
assert.isEmpty = function(val, msg) {
|
|
4008
|
+
new Assertion(val, msg, assert.isEmpty, true).to.be.empty;
|
|
4009
|
+
};
|
|
4010
|
+
assert.isNotEmpty = function(val, msg) {
|
|
4011
|
+
new Assertion(val, msg, assert.isNotEmpty, true).to.not.be.empty;
|
|
4012
|
+
};
|
|
4013
|
+
(/* @__PURE__ */ __name(function alias(name, as) {
|
|
4014
|
+
assert[as] = assert[name];
|
|
4015
|
+
return alias;
|
|
4016
|
+
}, "alias"))("isOk", "ok")("isNotOk", "notOk")("throws", "throw")("throws", "Throw")("isExtensible", "extensible")("isNotExtensible", "notExtensible")("isSealed", "sealed")("isNotSealed", "notSealed")("isFrozen", "frozen")("isNotFrozen", "notFrozen")("isEmpty", "empty")("isNotEmpty", "notEmpty");
|
|
4017
|
+
|
|
4018
|
+
// lib/chai.js
|
|
4019
|
+
var used = [];
|
|
4020
|
+
var version = "4.3.3";
|
|
4021
|
+
function use(fn) {
|
|
4022
|
+
const exports = {
|
|
4023
|
+
AssertionError: import_assertion_error7.default,
|
|
4024
|
+
util: utils_exports,
|
|
4025
|
+
config,
|
|
4026
|
+
expect,
|
|
4027
|
+
assert,
|
|
4028
|
+
Assertion,
|
|
4029
|
+
...should_exports
|
|
4030
|
+
};
|
|
4031
|
+
if (!~used.indexOf(fn)) {
|
|
4032
|
+
fn(exports, utils_exports);
|
|
4033
|
+
used.push(fn);
|
|
4034
|
+
}
|
|
4035
|
+
return exports;
|
|
4036
|
+
}
|
|
4037
|
+
__name(use, "use");
|
|
4038
|
+
/*!
|
|
4039
|
+
* Chai - flag utility
|
|
4040
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
4041
|
+
* MIT Licensed
|
|
4042
|
+
*/
|
|
4043
|
+
/*!
|
|
4044
|
+
* Chai - test utility
|
|
4045
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
4046
|
+
* MIT Licensed
|
|
4047
|
+
*/
|
|
4048
|
+
/*!
|
|
4049
|
+
* Module dependencies
|
|
4050
|
+
*/
|
|
4051
|
+
/*!
|
|
4052
|
+
* Chai - expectTypes utility
|
|
4053
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
4054
|
+
* MIT Licensed
|
|
4055
|
+
*/
|
|
4056
|
+
/*!
|
|
4057
|
+
* Chai - getActual utility
|
|
4058
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
4059
|
+
* MIT Licensed
|
|
4060
|
+
*/
|
|
4061
|
+
/*!
|
|
4062
|
+
* Chai - message composition utility
|
|
4063
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
4064
|
+
* MIT Licensed
|
|
4065
|
+
*/
|
|
4066
|
+
/*!
|
|
4067
|
+
* Chai - transferFlags utility
|
|
4068
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
4069
|
+
* MIT Licensed
|
|
4070
|
+
*/
|
|
4071
|
+
/*!
|
|
4072
|
+
* chai
|
|
4073
|
+
* http://chaijs.com
|
|
4074
|
+
* Copyright(c) 2011-2014 Jake Luer <jake@alogicalparadox.com>
|
|
4075
|
+
* MIT Licensed
|
|
4076
|
+
*/
|
|
4077
|
+
/*!
|
|
4078
|
+
* Assertion Constructor
|
|
4079
|
+
*
|
|
4080
|
+
* Creates object for chaining.
|
|
4081
|
+
*
|
|
4082
|
+
* `Assertion` objects contain metadata in the form of flags. Three flags can
|
|
4083
|
+
* be assigned during instantiation by passing arguments to this constructor:
|
|
4084
|
+
*
|
|
4085
|
+
* - `object`: This flag contains the target of the assertion. For example, in
|
|
4086
|
+
* the assertion `expect(numKittens).to.equal(7);`, the `object` flag will
|
|
4087
|
+
* contain `numKittens` so that the `equal` assertion can reference it when
|
|
4088
|
+
* needed.
|
|
4089
|
+
*
|
|
4090
|
+
* - `message`: This flag contains an optional custom error message to be
|
|
4091
|
+
* prepended to the error message that's generated by the assertion when it
|
|
4092
|
+
* fails.
|
|
4093
|
+
*
|
|
4094
|
+
* - `ssfi`: This flag stands for "start stack function indicator". It
|
|
4095
|
+
* contains a function reference that serves as the starting point for
|
|
4096
|
+
* removing frames from the stack trace of the error that's created by the
|
|
4097
|
+
* assertion when it fails. The goal is to provide a cleaner stack trace to
|
|
4098
|
+
* end users by removing Chai's internal functions. Note that it only works
|
|
4099
|
+
* in environments that support `Error.captureStackTrace`, and only when
|
|
4100
|
+
* `Chai.config.includeStack` hasn't been set to `false`.
|
|
4101
|
+
*
|
|
4102
|
+
* - `lockSsfi`: This flag controls whether or not the given `ssfi` flag
|
|
4103
|
+
* should retain its current value, even as assertions are chained off of
|
|
4104
|
+
* this object. This is usually set to `true` when creating a new assertion
|
|
4105
|
+
* from within another assertion. It's also temporarily set to `true` before
|
|
4106
|
+
* an overwritten assertion gets called by the overwriting assertion.
|
|
4107
|
+
*
|
|
4108
|
+
* @param {Mixed} obj target of the assertion
|
|
4109
|
+
* @param {String} msg (optional) custom error message
|
|
4110
|
+
* @param {Function} ssfi (optional) starting point for removing stack frames
|
|
4111
|
+
* @param {Boolean} lockSsfi (optional) whether or not the ssfi flag is locked
|
|
4112
|
+
* @api private
|
|
4113
|
+
*/
|
|
4114
|
+
/*!
|
|
4115
|
+
* ### ._obj
|
|
4116
|
+
*
|
|
4117
|
+
* Quick reference to stored `actual` value for plugin developers.
|
|
4118
|
+
*
|
|
4119
|
+
* @api private
|
|
4120
|
+
*/
|
|
4121
|
+
/*!
|
|
4122
|
+
* Chai - isProxyEnabled helper
|
|
4123
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
4124
|
+
* MIT Licensed
|
|
4125
|
+
*/
|
|
4126
|
+
/*!
|
|
4127
|
+
* Chai - addProperty utility
|
|
4128
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
4129
|
+
* MIT Licensed
|
|
4130
|
+
*/
|
|
4131
|
+
/*!
|
|
4132
|
+
* Chai - addLengthGuard utility
|
|
4133
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
4134
|
+
* MIT Licensed
|
|
4135
|
+
*/
|
|
4136
|
+
/*!
|
|
4137
|
+
* Chai - getProperties utility
|
|
4138
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
4139
|
+
* MIT Licensed
|
|
4140
|
+
*/
|
|
4141
|
+
/*!
|
|
4142
|
+
* Chai - proxify utility
|
|
4143
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
4144
|
+
* MIT Licensed
|
|
4145
|
+
*/
|
|
4146
|
+
/*!
|
|
4147
|
+
* Chai - addMethod utility
|
|
4148
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
4149
|
+
* MIT Licensed
|
|
4150
|
+
*/
|
|
4151
|
+
/*!
|
|
4152
|
+
* Chai - overwriteProperty utility
|
|
4153
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
4154
|
+
* MIT Licensed
|
|
4155
|
+
*/
|
|
4156
|
+
/*!
|
|
4157
|
+
* Chai - overwriteMethod utility
|
|
4158
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
4159
|
+
* MIT Licensed
|
|
4160
|
+
*/
|
|
4161
|
+
/*!
|
|
4162
|
+
* Chai - addChainingMethod utility
|
|
4163
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
4164
|
+
* MIT Licensed
|
|
4165
|
+
*/
|
|
4166
|
+
/*!
|
|
4167
|
+
* Module variables
|
|
4168
|
+
*/
|
|
4169
|
+
/*!
|
|
4170
|
+
* Chai - overwriteChainableMethod utility
|
|
4171
|
+
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
|
4172
|
+
* MIT Licensed
|
|
4173
|
+
*/
|
|
4174
|
+
/*!
|
|
4175
|
+
* Chai - compareByInspect utility
|
|
4176
|
+
* Copyright(c) 2011-2016 Jake Luer <jake@alogicalparadox.com>
|
|
4177
|
+
* MIT Licensed
|
|
4178
|
+
*/
|
|
4179
|
+
/*!
|
|
4180
|
+
* Chai - getOwnEnumerablePropertySymbols utility
|
|
4181
|
+
* Copyright(c) 2011-2016 Jake Luer <jake@alogicalparadox.com>
|
|
4182
|
+
* MIT Licensed
|
|
4183
|
+
*/
|
|
4184
|
+
/*!
|
|
4185
|
+
* Chai - getOwnEnumerableProperties utility
|
|
4186
|
+
* Copyright(c) 2011-2016 Jake Luer <jake@alogicalparadox.com>
|
|
4187
|
+
* MIT Licensed
|
|
4188
|
+
*/
|
|
4189
|
+
/*!
|
|
4190
|
+
* Chai - isNaN utility
|
|
4191
|
+
* Copyright(c) 2012-2015 Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
|
|
4192
|
+
* MIT Licensed
|
|
4193
|
+
*/
|
|
4194
|
+
/*!
|
|
4195
|
+
* chai
|
|
4196
|
+
* Copyright(c) 2011 Jake Luer <jake@alogicalparadox.com>
|
|
4197
|
+
* MIT Licensed
|
|
4198
|
+
*/
|
|
4199
|
+
/*!
|
|
4200
|
+
* Dependencies that are used for multiple exports are required here only once
|
|
4201
|
+
*/
|
|
4202
|
+
/*!
|
|
4203
|
+
* test utility
|
|
4204
|
+
*/
|
|
4205
|
+
/*!
|
|
4206
|
+
* type utility
|
|
4207
|
+
*/
|
|
4208
|
+
/*!
|
|
4209
|
+
* expectTypes utility
|
|
4210
|
+
*/
|
|
4211
|
+
/*!
|
|
4212
|
+
* message utility
|
|
4213
|
+
*/
|
|
4214
|
+
/*!
|
|
4215
|
+
* actual utility
|
|
4216
|
+
*/
|
|
4217
|
+
/*!
|
|
4218
|
+
* Inspect util
|
|
4219
|
+
*/
|
|
4220
|
+
/*!
|
|
4221
|
+
* Object Display util
|
|
4222
|
+
*/
|
|
4223
|
+
/*!
|
|
4224
|
+
* Flag utility
|
|
4225
|
+
*/
|
|
4226
|
+
/*!
|
|
4227
|
+
* Flag transferring utility
|
|
4228
|
+
*/
|
|
4229
|
+
/*!
|
|
4230
|
+
* Deep equal utility
|
|
4231
|
+
*/
|
|
4232
|
+
/*!
|
|
4233
|
+
* Deep path info
|
|
4234
|
+
*/
|
|
4235
|
+
/*!
|
|
4236
|
+
* Function name
|
|
4237
|
+
*/
|
|
4238
|
+
/*!
|
|
4239
|
+
* add Property
|
|
4240
|
+
*/
|
|
4241
|
+
/*!
|
|
4242
|
+
* add Method
|
|
4243
|
+
*/
|
|
4244
|
+
/*!
|
|
4245
|
+
* overwrite Property
|
|
4246
|
+
*/
|
|
4247
|
+
/*!
|
|
4248
|
+
* overwrite Method
|
|
4249
|
+
*/
|
|
4250
|
+
/*!
|
|
4251
|
+
* Add a chainable method
|
|
4252
|
+
*/
|
|
4253
|
+
/*!
|
|
4254
|
+
* Overwrite chainable method
|
|
4255
|
+
*/
|
|
4256
|
+
/*!
|
|
4257
|
+
* Compare by inspect method
|
|
4258
|
+
*/
|
|
4259
|
+
/*!
|
|
4260
|
+
* Get own enumerable property symbols method
|
|
4261
|
+
*/
|
|
4262
|
+
/*!
|
|
4263
|
+
* Get own enumerable properties method
|
|
4264
|
+
*/
|
|
4265
|
+
/*!
|
|
4266
|
+
* Checks error against a given set of criteria
|
|
4267
|
+
*/
|
|
4268
|
+
/*!
|
|
4269
|
+
* Proxify util
|
|
4270
|
+
*/
|
|
4271
|
+
/*!
|
|
4272
|
+
* addLengthGuard util
|
|
4273
|
+
*/
|
|
4274
|
+
/*!
|
|
4275
|
+
* isProxyEnabled helper
|
|
4276
|
+
*/
|
|
4277
|
+
/*!
|
|
4278
|
+
* isNaN method
|
|
4279
|
+
*/
|
|
4280
|
+
/*!
|
|
4281
|
+
* getOperator method
|
|
4282
|
+
*/
|
|
4283
|
+
/*!
|
|
4284
|
+
* chai
|
|
4285
|
+
* Copyright(c) 2011-2014 Jake Luer <jake@alogicalparadox.com>
|
|
4286
|
+
* MIT Licensed
|
|
4287
|
+
*/
|
|
4288
|
+
/*!
|
|
4289
|
+
* ### .ifError(object)
|
|
4290
|
+
*
|
|
4291
|
+
* Asserts if value is not a false value, and throws if it is a true value.
|
|
4292
|
+
* This is added to allow for chai to be a drop-in replacement for Node's
|
|
4293
|
+
* assert class.
|
|
4294
|
+
*
|
|
4295
|
+
* var err = new Error('I am a custom error');
|
|
4296
|
+
* assert.ifError(err); // Rethrows err!
|
|
4297
|
+
*
|
|
4298
|
+
* @name ifError
|
|
4299
|
+
* @param {Object} object
|
|
4300
|
+
* @namespace Assert
|
|
4301
|
+
* @api public
|
|
4302
|
+
*/
|
|
4303
|
+
/*!
|
|
4304
|
+
* Aliases.
|
|
4305
|
+
*/
|
|
4306
|
+
/*!
|
|
4307
|
+
* Chai version
|
|
4308
|
+
*/
|
|
4309
|
+
/*!
|
|
4310
|
+
* Assertion Error
|
|
4311
|
+
*/
|
|
4312
|
+
/*!
|
|
4313
|
+
* Utility Functions
|
|
4314
|
+
*/
|
|
4315
|
+
/*!
|
|
4316
|
+
* Configuration
|
|
4317
|
+
*/
|
|
4318
|
+
/*!
|
|
4319
|
+
* Primary `Assertion` prototype
|
|
4320
|
+
*/
|
|
4321
|
+
/*!
|
|
4322
|
+
* Expect interface
|
|
4323
|
+
*/
|
|
4324
|
+
/*!
|
|
4325
|
+
* Should interface
|
|
4326
|
+
*/
|
|
4327
|
+
/*!
|
|
4328
|
+
* Assert interface
|
|
4329
|
+
*/
|
|
4330
|
+
/*! Bundled license information:
|
|
4331
|
+
|
|
4332
|
+
assertion-error/index.js:
|
|
4333
|
+
(*!
|
|
4334
|
+
* assertion-error
|
|
4335
|
+
* Copyright(c) 2013 Jake Luer <jake@qualiancy.com>
|
|
4336
|
+
* MIT Licensed
|
|
4337
|
+
*)
|
|
4338
|
+
(*!
|
|
4339
|
+
* Return a function that will copy properties from
|
|
4340
|
+
* one object to another excluding any originally
|
|
4341
|
+
* listed. Returned function will create a new `{}`.
|
|
4342
|
+
*
|
|
4343
|
+
* @param {String} excluded properties ...
|
|
4344
|
+
* @return {Function}
|
|
4345
|
+
*)
|
|
4346
|
+
(*!
|
|
4347
|
+
* Primary Exports
|
|
4348
|
+
*)
|
|
4349
|
+
(*!
|
|
4350
|
+
* Inherit from Error.prototype
|
|
4351
|
+
*)
|
|
4352
|
+
(*!
|
|
4353
|
+
* Statically set name
|
|
4354
|
+
*)
|
|
4355
|
+
(*!
|
|
4356
|
+
* Ensure correct constructor
|
|
4357
|
+
*)
|
|
4358
|
+
|
|
4359
|
+
deep-eql/index.js:
|
|
4360
|
+
(*!
|
|
4361
|
+
* deep-eql
|
|
4362
|
+
* Copyright(c) 2013 Jake Luer <jake@alogicalparadox.com>
|
|
4363
|
+
* MIT Licensed
|
|
4364
|
+
*)
|
|
4365
|
+
(*!
|
|
4366
|
+
* Check to see if the MemoizeMap has recorded a result of the two operands
|
|
4367
|
+
*
|
|
4368
|
+
* @param {Mixed} leftHandOperand
|
|
4369
|
+
* @param {Mixed} rightHandOperand
|
|
4370
|
+
* @param {MemoizeMap} memoizeMap
|
|
4371
|
+
* @returns {Boolean|null} result
|
|
4372
|
+
*)
|
|
4373
|
+
(*!
|
|
4374
|
+
* Set the result of the equality into the MemoizeMap
|
|
4375
|
+
*
|
|
4376
|
+
* @param {Mixed} leftHandOperand
|
|
4377
|
+
* @param {Mixed} rightHandOperand
|
|
4378
|
+
* @param {MemoizeMap} memoizeMap
|
|
4379
|
+
* @param {Boolean} result
|
|
4380
|
+
*)
|
|
4381
|
+
(*!
|
|
4382
|
+
* Primary Export
|
|
4383
|
+
*)
|
|
4384
|
+
(*!
|
|
4385
|
+
* The main logic of the `deepEqual` function.
|
|
4386
|
+
*
|
|
4387
|
+
* @param {Mixed} leftHandOperand
|
|
4388
|
+
* @param {Mixed} rightHandOperand
|
|
4389
|
+
* @param {Object} [options] (optional) Additional options
|
|
4390
|
+
* @param {Array} [options.comparator] (optional) Override default algorithm, determining custom equality.
|
|
4391
|
+
* @param {Array} [options.memoize] (optional) Provide a custom memoization object which will cache the results of
|
|
4392
|
+
complex objects for a speed boost. By passing `false` you can disable memoization, but this will cause circular
|
|
4393
|
+
references to blow the stack.
|
|
4394
|
+
* @return {Boolean} equal match
|
|
4395
|
+
*)
|
|
4396
|
+
(*!
|
|
4397
|
+
* Compare two Regular Expressions for equality.
|
|
4398
|
+
*
|
|
4399
|
+
* @param {RegExp} leftHandOperand
|
|
4400
|
+
* @param {RegExp} rightHandOperand
|
|
4401
|
+
* @return {Boolean} result
|
|
4402
|
+
*)
|
|
4403
|
+
(*!
|
|
4404
|
+
* Compare two Sets/Maps for equality. Faster than other equality functions.
|
|
4405
|
+
*
|
|
4406
|
+
* @param {Set} leftHandOperand
|
|
4407
|
+
* @param {Set} rightHandOperand
|
|
4408
|
+
* @param {Object} [options] (Optional)
|
|
4409
|
+
* @return {Boolean} result
|
|
4410
|
+
*)
|
|
4411
|
+
(*!
|
|
4412
|
+
* Simple equality for flat iterable objects such as Arrays, TypedArrays or Node.js buffers.
|
|
4413
|
+
*
|
|
4414
|
+
* @param {Iterable} leftHandOperand
|
|
4415
|
+
* @param {Iterable} rightHandOperand
|
|
4416
|
+
* @param {Object} [options] (Optional)
|
|
4417
|
+
* @return {Boolean} result
|
|
4418
|
+
*)
|
|
4419
|
+
(*!
|
|
4420
|
+
* Simple equality for generator objects such as those returned by generator functions.
|
|
4421
|
+
*
|
|
4422
|
+
* @param {Iterable} leftHandOperand
|
|
4423
|
+
* @param {Iterable} rightHandOperand
|
|
4424
|
+
* @param {Object} [options] (Optional)
|
|
4425
|
+
* @return {Boolean} result
|
|
4426
|
+
*)
|
|
4427
|
+
(*!
|
|
4428
|
+
* Determine if the given object has an @@iterator function.
|
|
4429
|
+
*
|
|
4430
|
+
* @param {Object} target
|
|
4431
|
+
* @return {Boolean} `true` if the object has an @@iterator function.
|
|
4432
|
+
*)
|
|
4433
|
+
(*!
|
|
4434
|
+
* Gets all iterator entries from the given Object. If the Object has no @@iterator function, returns an empty array.
|
|
4435
|
+
* This will consume the iterator - which could have side effects depending on the @@iterator implementation.
|
|
4436
|
+
*
|
|
4437
|
+
* @param {Object} target
|
|
4438
|
+
* @returns {Array} an array of entries from the @@iterator function
|
|
4439
|
+
*)
|
|
4440
|
+
(*!
|
|
4441
|
+
* Gets all entries from a Generator. This will consume the generator - which could have side effects.
|
|
4442
|
+
*
|
|
4443
|
+
* @param {Generator} target
|
|
4444
|
+
* @returns {Array} an array of entries from the Generator.
|
|
4445
|
+
*)
|
|
4446
|
+
(*!
|
|
4447
|
+
* Gets all own and inherited enumerable keys from a target.
|
|
4448
|
+
*
|
|
4449
|
+
* @param {Object} target
|
|
4450
|
+
* @returns {Array} an array of own and inherited enumerable keys from the target.
|
|
4451
|
+
*)
|
|
4452
|
+
(*!
|
|
4453
|
+
* Determines if two objects have matching values, given a set of keys. Defers to deepEqual for the equality check of
|
|
4454
|
+
* each key. If any value of the given key is not equal, the function will return false (early).
|
|
4455
|
+
*
|
|
4456
|
+
* @param {Mixed} leftHandOperand
|
|
4457
|
+
* @param {Mixed} rightHandOperand
|
|
4458
|
+
* @param {Array} keys An array of keys to compare the values of leftHandOperand and rightHandOperand against
|
|
4459
|
+
* @param {Object} [options] (Optional)
|
|
4460
|
+
* @return {Boolean} result
|
|
4461
|
+
*)
|
|
4462
|
+
(*!
|
|
4463
|
+
* Recursively check the equality of two Objects. Once basic sameness has been established it will defer to `deepEqual`
|
|
4464
|
+
* for each enumerable key in the object.
|
|
4465
|
+
*
|
|
4466
|
+
* @param {Mixed} leftHandOperand
|
|
4467
|
+
* @param {Mixed} rightHandOperand
|
|
4468
|
+
* @param {Object} [options] (Optional)
|
|
4469
|
+
* @return {Boolean} result
|
|
4470
|
+
*)
|
|
4471
|
+
(*!
|
|
4472
|
+
* Returns true if the argument is a primitive.
|
|
4473
|
+
*
|
|
4474
|
+
* This intentionally returns true for all objects that can be compared by reference,
|
|
4475
|
+
* including functions and symbols.
|
|
4476
|
+
*
|
|
4477
|
+
* @param {Mixed} value
|
|
4478
|
+
* @return {Boolean} result
|
|
4479
|
+
*)
|
|
4480
|
+
*/
|