@noma.to/qwik-mock 1.0.2 → 1.1.1

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