@noma.to/qwik-testing-library 1.3.1 → 1.4.0

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