chai 5.3.0 → 5.3.2

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