@powerlines/plugin-open-feature 0.1.196 → 0.1.197

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 (96) hide show
  1. package/dist/_virtual/_rolldown/runtime.cjs +0 -14
  2. package/dist/components/features-builtin.cjs +3 -10
  3. package/dist/components/features-builtin.mjs +2 -4
  4. package/dist/components/features-builtin.mjs.map +1 -1
  5. package/dist/helpers/automd-generator.cjs +0 -8
  6. package/dist/helpers/automd-generator.mjs +1 -3
  7. package/dist/helpers/automd-generator.mjs.map +1 -1
  8. package/dist/index.cjs +3 -3
  9. package/dist/index.mjs +2 -2
  10. package/package.json +8 -63
  11. package/dist/_virtual/_rolldown/runtime.mjs +0 -18
  12. package/dist/components/features-builtin.test.cjs +0 -16
  13. package/dist/components/features-builtin.test.d.cts +0 -1
  14. package/dist/components/features-builtin.test.d.mts +0 -1
  15. package/dist/components/features-builtin.test.mjs +0 -18
  16. package/dist/components/features-builtin.test.mjs.map +0 -1
  17. package/dist/helpers/automd-generator.test.cjs +0 -16
  18. package/dist/helpers/automd-generator.test.d.cts +0 -1
  19. package/dist/helpers/automd-generator.test.d.mts +0 -1
  20. package/dist/helpers/automd-generator.test.mjs +0 -18
  21. package/dist/helpers/automd-generator.test.mjs.map +0 -1
  22. package/dist/index.test.cjs +0 -30
  23. package/dist/index.test.d.cts +0 -1
  24. package/dist/index.test.d.mts +0 -1
  25. package/dist/index.test.mjs +0 -32
  26. package/dist/index.test.mjs.map +0 -1
  27. package/dist/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.cjs +0 -78
  28. package/dist/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs +0 -78
  29. package/dist/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs.map +0 -1
  30. package/dist/node_modules/.pnpm/@vitest_expect@4.1.7/node_modules/@vitest/expect/dist/index.cjs +0 -1487
  31. package/dist/node_modules/.pnpm/@vitest_expect@4.1.7/node_modules/@vitest/expect/dist/index.mjs +0 -1473
  32. package/dist/node_modules/.pnpm/@vitest_expect@4.1.7/node_modules/@vitest/expect/dist/index.mjs.map +0 -1
  33. package/dist/node_modules/.pnpm/@vitest_pretty-format@4.1.7/node_modules/@vitest/pretty-format/dist/index.cjs +0 -889
  34. package/dist/node_modules/.pnpm/@vitest_pretty-format@4.1.7/node_modules/@vitest/pretty-format/dist/index.mjs +0 -888
  35. package/dist/node_modules/.pnpm/@vitest_pretty-format@4.1.7/node_modules/@vitest/pretty-format/dist/index.mjs.map +0 -1
  36. package/dist/node_modules/.pnpm/@vitest_runner@4.1.7/node_modules/@vitest/runner/dist/chunk-artifact.cjs +0 -1614
  37. package/dist/node_modules/.pnpm/@vitest_runner@4.1.7/node_modules/@vitest/runner/dist/chunk-artifact.mjs +0 -1594
  38. package/dist/node_modules/.pnpm/@vitest_runner@4.1.7/node_modules/@vitest/runner/dist/chunk-artifact.mjs.map +0 -1
  39. package/dist/node_modules/.pnpm/@vitest_runner@4.1.7/node_modules/@vitest/runner/dist/index.cjs +0 -1
  40. package/dist/node_modules/.pnpm/@vitest_runner@4.1.7/node_modules/@vitest/runner/dist/index.mjs +0 -3
  41. package/dist/node_modules/.pnpm/@vitest_runner@4.1.7/node_modules/@vitest/runner/dist/utils.cjs +0 -1
  42. package/dist/node_modules/.pnpm/@vitest_runner@4.1.7/node_modules/@vitest/runner/dist/utils.mjs +0 -3
  43. package/dist/node_modules/.pnpm/@vitest_snapshot@4.1.7/node_modules/@vitest/snapshot/dist/index.cjs +0 -923
  44. package/dist/node_modules/.pnpm/@vitest_snapshot@4.1.7/node_modules/@vitest/snapshot/dist/index.mjs +0 -922
  45. package/dist/node_modules/.pnpm/@vitest_snapshot@4.1.7/node_modules/@vitest/snapshot/dist/index.mjs.map +0 -1
  46. package/dist/node_modules/.pnpm/@vitest_spy@4.1.7/node_modules/@vitest/spy/dist/index.cjs +0 -391
  47. package/dist/node_modules/.pnpm/@vitest_spy@4.1.7/node_modules/@vitest/spy/dist/index.mjs +0 -386
  48. package/dist/node_modules/.pnpm/@vitest_spy@4.1.7/node_modules/@vitest/spy/dist/index.mjs.map +0 -1
  49. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.cjs +0 -82
  50. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.mjs +0 -82
  51. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.mjs.map +0 -1
  52. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/diff.cjs +0 -1358
  53. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/diff.mjs +0 -1357
  54. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/diff.mjs.map +0 -1
  55. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/display.cjs +0 -561
  56. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/display.mjs +0 -559
  57. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/display.mjs.map +0 -1
  58. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/error.cjs +0 -37
  59. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/error.mjs +0 -38
  60. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/error.mjs.map +0 -1
  61. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/helpers.cjs +0 -197
  62. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/helpers.mjs +0 -181
  63. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/helpers.mjs.map +0 -1
  64. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/offset.cjs +0 -29
  65. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/offset.mjs +0 -27
  66. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/offset.mjs.map +0 -1
  67. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/serialize.cjs +0 -77
  68. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/serialize.mjs +0 -77
  69. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/serialize.mjs.map +0 -1
  70. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/source-map.cjs +0 -374
  71. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/source-map.mjs +0 -374
  72. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/source-map.mjs.map +0 -1
  73. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/timers.cjs +0 -38
  74. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/timers.mjs +0 -37
  75. package/dist/node_modules/.pnpm/@vitest_utils@4.1.7/node_modules/@vitest/utils/dist/timers.mjs.map +0 -1
  76. package/dist/node_modules/.pnpm/chai@6.2.2/node_modules/chai/index.cjs +0 -2978
  77. package/dist/node_modules/.pnpm/chai@6.2.2/node_modules/chai/index.mjs +0 -2973
  78. package/dist/node_modules/.pnpm/chai@6.2.2/node_modules/chai/index.mjs.map +0 -1
  79. package/dist/node_modules/.pnpm/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.cjs +0 -939
  80. package/dist/node_modules/.pnpm/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.mjs +0 -940
  81. package/dist/node_modules/.pnpm/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.mjs.map +0 -1
  82. package/dist/node_modules/.pnpm/tinyrainbow@3.1.0/node_modules/tinyrainbow/dist/index.cjs +0 -87
  83. package/dist/node_modules/.pnpm/tinyrainbow@3.1.0/node_modules/tinyrainbow/dist/index.mjs +0 -87
  84. package/dist/node_modules/.pnpm/tinyrainbow@3.1.0/node_modules/tinyrainbow/dist/index.mjs.map +0 -1
  85. package/dist/node_modules/.pnpm/vitest@4.1.7_@opentelemetry_api@1.9.1_@types_node@25.9.1_@vitest_coverage-v8@4.1.7_vite_34dd47607c0af5e5ae7f1b2f95fc48c3/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.cjs +0 -6
  86. package/dist/node_modules/.pnpm/vitest@4.1.7_@opentelemetry_api@1.9.1_@types_node@25.9.1_@vitest_coverage-v8@4.1.7_vite_34dd47607c0af5e5ae7f1b2f95fc48c3/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.mjs +0 -6
  87. package/dist/node_modules/.pnpm/vitest@4.1.7_@opentelemetry_api@1.9.1_@types_node@25.9.1_@vitest_coverage-v8@4.1.7_vite_34dd47607c0af5e5ae7f1b2f95fc48c3/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.mjs.map +0 -1
  88. package/dist/node_modules/.pnpm/vitest@4.1.7_@opentelemetry_api@1.9.1_@types_node@25.9.1_@vitest_coverage-v8@4.1.7_vite_34dd47607c0af5e5ae7f1b2f95fc48c3/node_modules/vitest/dist/chunks/rpc.MzXet3jl.cjs +0 -54
  89. package/dist/node_modules/.pnpm/vitest@4.1.7_@opentelemetry_api@1.9.1_@types_node@25.9.1_@vitest_coverage-v8@4.1.7_vite_34dd47607c0af5e5ae7f1b2f95fc48c3/node_modules/vitest/dist/chunks/rpc.MzXet3jl.mjs +0 -52
  90. package/dist/node_modules/.pnpm/vitest@4.1.7_@opentelemetry_api@1.9.1_@types_node@25.9.1_@vitest_coverage-v8@4.1.7_vite_34dd47607c0af5e5ae7f1b2f95fc48c3/node_modules/vitest/dist/chunks/rpc.MzXet3jl.mjs.map +0 -1
  91. package/dist/node_modules/.pnpm/vitest@4.1.7_@opentelemetry_api@1.9.1_@types_node@25.9.1_@vitest_coverage-v8@4.1.7_vite_34dd47607c0af5e5ae7f1b2f95fc48c3/node_modules/vitest/dist/chunks/test.DNmyFkvJ.cjs +0 -2696
  92. package/dist/node_modules/.pnpm/vitest@4.1.7_@opentelemetry_api@1.9.1_@types_node@25.9.1_@vitest_coverage-v8@4.1.7_vite_34dd47607c0af5e5ae7f1b2f95fc48c3/node_modules/vitest/dist/chunks/test.DNmyFkvJ.mjs +0 -2697
  93. package/dist/node_modules/.pnpm/vitest@4.1.7_@opentelemetry_api@1.9.1_@types_node@25.9.1_@vitest_coverage-v8@4.1.7_vite_34dd47607c0af5e5ae7f1b2f95fc48c3/node_modules/vitest/dist/chunks/test.DNmyFkvJ.mjs.map +0 -1
  94. package/dist/node_modules/.pnpm/vitest@4.1.7_@opentelemetry_api@1.9.1_@types_node@25.9.1_@vitest_coverage-v8@4.1.7_vite_34dd47607c0af5e5ae7f1b2f95fc48c3/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.cjs +0 -47
  95. package/dist/node_modules/.pnpm/vitest@4.1.7_@opentelemetry_api@1.9.1_@types_node@25.9.1_@vitest_coverage-v8@4.1.7_vite_34dd47607c0af5e5ae7f1b2f95fc48c3/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.mjs +0 -45
  96. package/dist/node_modules/.pnpm/vitest@4.1.7_@opentelemetry_api@1.9.1_@types_node@25.9.1_@vitest_coverage-v8@4.1.7_vite_34dd47607c0af5e5ae7f1b2f95fc48c3/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.mjs.map +0 -1
@@ -1,2978 +0,0 @@
1
-
2
- //#region ../../../node_modules/.pnpm/chai@6.2.2/node_modules/chai/index.js
3
- var __defProp = Object.defineProperty;
4
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
5
- enumerable: true,
6
- configurable: true,
7
- writable: true,
8
- value
9
- }) : obj[key] = value;
10
- var __name = (target, value) => __defProp(target, "name", {
11
- value,
12
- configurable: true
13
- });
14
- var __export = (target, all) => {
15
- for (var name in all) __defProp(target, name, {
16
- get: all[name],
17
- enumerable: true
18
- });
19
- };
20
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
21
- var utils_exports = {};
22
- __export(utils_exports, {
23
- addChainableMethod: () => addChainableMethod,
24
- addLengthGuard: () => addLengthGuard,
25
- addMethod: () => addMethod,
26
- addProperty: () => addProperty,
27
- checkError: () => check_error_exports,
28
- compareByInspect: () => compareByInspect,
29
- eql: () => deep_eql_default,
30
- events: () => events,
31
- expectTypes: () => expectTypes,
32
- flag: () => flag,
33
- getActual: () => getActual,
34
- getMessage: () => getMessage2,
35
- getName: () => getName,
36
- getOperator: () => getOperator,
37
- getOwnEnumerableProperties: () => getOwnEnumerableProperties,
38
- getOwnEnumerablePropertySymbols: () => getOwnEnumerablePropertySymbols,
39
- getPathInfo: () => getPathInfo,
40
- hasProperty: () => hasProperty,
41
- inspect: () => inspect2,
42
- isNaN: () => isNaN2,
43
- isNumeric: () => isNumeric,
44
- isProxyEnabled: () => isProxyEnabled,
45
- isRegExp: () => isRegExp2,
46
- objDisplay: () => objDisplay,
47
- overwriteChainableMethod: () => overwriteChainableMethod,
48
- overwriteMethod: () => overwriteMethod,
49
- overwriteProperty: () => overwriteProperty,
50
- proxify: () => proxify,
51
- test: () => test,
52
- transferFlags: () => transferFlags,
53
- type: () => type
54
- });
55
- var check_error_exports = {};
56
- __export(check_error_exports, {
57
- compatibleConstructor: () => compatibleConstructor,
58
- compatibleInstance: () => compatibleInstance,
59
- compatibleMessage: () => compatibleMessage,
60
- getConstructorName: () => getConstructorName,
61
- getMessage: () => getMessage
62
- });
63
- function isErrorInstance(obj) {
64
- return obj instanceof Error || Object.prototype.toString.call(obj) === "[object Error]";
65
- }
66
- __name(isErrorInstance, "isErrorInstance");
67
- function isRegExp(obj) {
68
- return Object.prototype.toString.call(obj) === "[object RegExp]";
69
- }
70
- __name(isRegExp, "isRegExp");
71
- function compatibleInstance(thrown, errorLike) {
72
- return isErrorInstance(errorLike) && thrown === errorLike;
73
- }
74
- __name(compatibleInstance, "compatibleInstance");
75
- function compatibleConstructor(thrown, errorLike) {
76
- if (isErrorInstance(errorLike)) return thrown.constructor === errorLike.constructor || thrown instanceof errorLike.constructor;
77
- else if ((typeof errorLike === "object" || typeof errorLike === "function") && errorLike.prototype) return thrown.constructor === errorLike || thrown instanceof errorLike;
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)) return errMatcher.test(comparisonString);
84
- else if (typeof errMatcher === "string") return comparisonString.indexOf(errMatcher) !== -1;
85
- return false;
86
- }
87
- __name(compatibleMessage, "compatibleMessage");
88
- function getConstructorName(errorLike) {
89
- let constructorName = errorLike;
90
- if (isErrorInstance(errorLike)) constructorName = errorLike.constructor.name;
91
- else if (typeof errorLike === "function") {
92
- constructorName = errorLike.name;
93
- if (constructorName === "") constructorName = new errorLike().name || constructorName;
94
- }
95
- return constructorName;
96
- }
97
- __name(getConstructorName, "getConstructorName");
98
- function getMessage(errorLike) {
99
- let msg = "";
100
- if (errorLike && errorLike.message) msg = errorLike.message;
101
- else if (typeof errorLike === "string") msg = errorLike;
102
- return msg;
103
- }
104
- __name(getMessage, "getMessage");
105
- function flag(obj, key, value) {
106
- let flags = obj.__flags || (obj.__flags = /* @__PURE__ */ Object.create(null));
107
- if (arguments.length === 3) flags[key] = value;
108
- else return flags[key];
109
- }
110
- __name(flag, "flag");
111
- function test(obj, args) {
112
- let negate = flag(obj, "negate"), expr = args[0];
113
- return negate ? !expr : expr;
114
- }
115
- __name(test, "test");
116
- function type(obj) {
117
- if (typeof obj === "undefined") return "undefined";
118
- if (obj === null) return "null";
119
- const stringTag = obj[Symbol.toStringTag];
120
- if (typeof stringTag === "string") return stringTag;
121
- return Object.prototype.toString.call(obj).slice(8, -1);
122
- }
123
- __name(type, "type");
124
- var canElideFrames = "captureStackTrace" in Error;
125
- var _AssertionError = class _AssertionError extends Error {
126
- constructor(message = "Unspecified AssertionError", props, ssf) {
127
- super(message);
128
- __publicField(this, "message");
129
- this.message = message;
130
- if (canElideFrames) Error.captureStackTrace(this, ssf || _AssertionError);
131
- for (const key in props) if (!(key in this)) this[key] = props[key];
132
- }
133
- get name() {
134
- return "AssertionError";
135
- }
136
- get ok() {
137
- return false;
138
- }
139
- toJSON(stack) {
140
- return {
141
- ...this,
142
- name: this.name,
143
- message: this.message,
144
- ok: false,
145
- stack: stack !== false ? this.stack : void 0
146
- };
147
- }
148
- };
149
- __name(_AssertionError, "AssertionError");
150
- var AssertionError = _AssertionError;
151
- function expectTypes(obj, types) {
152
- let flagMsg = flag(obj, "message");
153
- let ssfi = flag(obj, "ssfi");
154
- flagMsg = flagMsg ? flagMsg + ": " : "";
155
- obj = flag(obj, "object");
156
- types = types.map(function(t) {
157
- return t.toLowerCase();
158
- });
159
- types.sort();
160
- let str = types.map(function(t, index) {
161
- let art = ~[
162
- "a",
163
- "e",
164
- "i",
165
- "o",
166
- "u"
167
- ].indexOf(t.charAt(0)) ? "an" : "a";
168
- return (types.length > 1 && index === types.length - 1 ? "or " : "") + art + " " + t;
169
- }).join(", ");
170
- let objType = type(obj).toLowerCase();
171
- if (!types.some(function(expected) {
172
- return objType === expected;
173
- })) throw new AssertionError(flagMsg + "object tested must be " + str + ", but " + objType + " given", void 0, ssfi);
174
- }
175
- __name(expectTypes, "expectTypes");
176
- function getActual(obj, args) {
177
- return args.length > 4 ? args[4] : obj._obj;
178
- }
179
- __name(getActual, "getActual");
180
- var ansiColors = {
181
- bold: ["1", "22"],
182
- dim: ["2", "22"],
183
- italic: ["3", "23"],
184
- underline: ["4", "24"],
185
- inverse: ["7", "27"],
186
- hidden: ["8", "28"],
187
- strike: ["9", "29"],
188
- black: ["30", "39"],
189
- red: ["31", "39"],
190
- green: ["32", "39"],
191
- yellow: ["33", "39"],
192
- blue: ["34", "39"],
193
- magenta: ["35", "39"],
194
- cyan: ["36", "39"],
195
- white: ["37", "39"],
196
- brightblack: ["30;1", "39"],
197
- brightred: ["31;1", "39"],
198
- brightgreen: ["32;1", "39"],
199
- brightyellow: ["33;1", "39"],
200
- brightblue: ["34;1", "39"],
201
- brightmagenta: ["35;1", "39"],
202
- brightcyan: ["36;1", "39"],
203
- brightwhite: ["37;1", "39"],
204
- grey: ["90", "39"]
205
- };
206
- var styles = {
207
- special: "cyan",
208
- number: "yellow",
209
- bigint: "yellow",
210
- boolean: "yellow",
211
- undefined: "grey",
212
- null: "bold",
213
- string: "green",
214
- symbol: "green",
215
- date: "magenta",
216
- regexp: "red"
217
- };
218
- var truncator = "…";
219
- function colorise(value, styleType) {
220
- const color = ansiColors[styles[styleType]] || ansiColors[styleType] || "";
221
- if (!color) return String(value);
222
- return `\x1B[${color[0]}m${String(value)}\x1B[${color[1]}m`;
223
- }
224
- __name(colorise, "colorise");
225
- function normaliseOptions({ showHidden = false, depth = 2, colors = false, customInspect = true, showProxy = false, maxArrayLength = Infinity, breakLength = Infinity, seen = [], truncate: truncate2 = Infinity, stylize = String } = {}, inspect3) {
226
- const options = {
227
- showHidden: Boolean(showHidden),
228
- depth: Number(depth),
229
- colors: Boolean(colors),
230
- customInspect: Boolean(customInspect),
231
- showProxy: Boolean(showProxy),
232
- maxArrayLength: Number(maxArrayLength),
233
- breakLength: Number(breakLength),
234
- truncate: Number(truncate2),
235
- seen,
236
- inspect: inspect3,
237
- stylize
238
- };
239
- if (options.colors) options.stylize = colorise;
240
- return options;
241
- }
242
- __name(normaliseOptions, "normaliseOptions");
243
- function isHighSurrogate(char) {
244
- return char >= "\ud800" && char <= "\udbff";
245
- }
246
- __name(isHighSurrogate, "isHighSurrogate");
247
- function truncate(string, length, tail = truncator) {
248
- string = String(string);
249
- const tailLength = tail.length;
250
- const stringLength = string.length;
251
- if (tailLength > length && stringLength > tailLength) return tail;
252
- if (stringLength > length && stringLength > tailLength) {
253
- let end = length - tailLength;
254
- if (end > 0 && isHighSurrogate(string[end - 1])) end = end - 1;
255
- return `${string.slice(0, end)}${tail}`;
256
- }
257
- return string;
258
- }
259
- __name(truncate, "truncate");
260
- function inspectList(list, options, inspectItem, separator = ", ") {
261
- inspectItem = inspectItem || options.inspect;
262
- const size = list.length;
263
- if (size === 0) return "";
264
- const originalLength = options.truncate;
265
- let output = "";
266
- let peek = "";
267
- let truncated = "";
268
- for (let i = 0; i < size; i += 1) {
269
- const last = i + 1 === list.length;
270
- const secondToLast = i + 2 === list.length;
271
- truncated = `${truncator}(${list.length - i})`;
272
- const value = list[i];
273
- options.truncate = originalLength - output.length - (last ? 0 : separator.length);
274
- const string = peek || inspectItem(value, options) + (last ? "" : separator);
275
- const nextLength = output.length + string.length;
276
- const truncatedLength = nextLength + truncated.length;
277
- if (last && nextLength > originalLength && output.length + truncated.length <= originalLength) break;
278
- if (!last && !secondToLast && truncatedLength > originalLength) break;
279
- peek = last ? "" : inspectItem(list[i + 1], options) + (secondToLast ? "" : separator);
280
- if (!last && secondToLast && truncatedLength > originalLength && nextLength + peek.length > originalLength) break;
281
- output += string;
282
- if (!last && !secondToLast && nextLength + peek.length >= originalLength) {
283
- truncated = `${truncator}(${list.length - i - 1})`;
284
- break;
285
- }
286
- truncated = "";
287
- }
288
- return `${output}${truncated}`;
289
- }
290
- __name(inspectList, "inspectList");
291
- function quoteComplexKey(key) {
292
- if (key.match(/^[a-zA-Z_][a-zA-Z_0-9]*$/)) return key;
293
- return JSON.stringify(key).replace(/'/g, "\\'").replace(/\\"/g, "\"").replace(/(^"|"$)/g, "'");
294
- }
295
- __name(quoteComplexKey, "quoteComplexKey");
296
- function inspectProperty([key, value], options) {
297
- options.truncate -= 2;
298
- if (typeof key === "string") key = quoteComplexKey(key);
299
- else if (typeof key !== "number") key = `[${options.inspect(key, options)}]`;
300
- options.truncate -= key.length;
301
- value = options.inspect(value, options);
302
- return `${key}: ${value}`;
303
- }
304
- __name(inspectProperty, "inspectProperty");
305
- function inspectArray(array, options) {
306
- const nonIndexProperties = Object.keys(array).slice(array.length);
307
- if (!array.length && !nonIndexProperties.length) return "[]";
308
- options.truncate -= 4;
309
- const listContents = inspectList(array, options);
310
- options.truncate -= listContents.length;
311
- let propertyContents = "";
312
- if (nonIndexProperties.length) propertyContents = inspectList(nonIndexProperties.map((key) => [key, array[key]]), options, inspectProperty);
313
- return `[ ${listContents}${propertyContents ? `, ${propertyContents}` : ""} ]`;
314
- }
315
- __name(inspectArray, "inspectArray");
316
- var getArrayName = /* @__PURE__ */ __name((array) => {
317
- if (typeof Buffer === "function" && array instanceof Buffer) return "Buffer";
318
- if (array[Symbol.toStringTag]) return array[Symbol.toStringTag];
319
- return array.constructor.name;
320
- }, "getArrayName");
321
- function inspectTypedArray(array, options) {
322
- const name = getArrayName(array);
323
- options.truncate -= name.length + 4;
324
- const nonIndexProperties = Object.keys(array).slice(array.length);
325
- if (!array.length && !nonIndexProperties.length) return `${name}[]`;
326
- let output = "";
327
- for (let i = 0; i < array.length; i++) {
328
- const string = `${options.stylize(truncate(array[i], options.truncate), "number")}${i === array.length - 1 ? "" : ", "}`;
329
- options.truncate -= string.length;
330
- if (array[i] !== array.length && options.truncate <= 3) {
331
- output += `${truncator}(${array.length - array[i] + 1})`;
332
- break;
333
- }
334
- output += string;
335
- }
336
- let propertyContents = "";
337
- if (nonIndexProperties.length) propertyContents = inspectList(nonIndexProperties.map((key) => [key, array[key]]), options, inspectProperty);
338
- return `${name}[ ${output}${propertyContents ? `, ${propertyContents}` : ""} ]`;
339
- }
340
- __name(inspectTypedArray, "inspectTypedArray");
341
- function inspectDate(dateObject, options) {
342
- const stringRepresentation = dateObject.toJSON();
343
- if (stringRepresentation === null) return "Invalid Date";
344
- const split = stringRepresentation.split("T");
345
- const date = split[0];
346
- return options.stylize(`${date}T${truncate(split[1], options.truncate - date.length - 1)}`, "date");
347
- }
348
- __name(inspectDate, "inspectDate");
349
- function inspectFunction(func, options) {
350
- const functionType = func[Symbol.toStringTag] || "Function";
351
- const name = func.name;
352
- if (!name) return options.stylize(`[${functionType}]`, "special");
353
- return options.stylize(`[${functionType} ${truncate(name, options.truncate - 11)}]`, "special");
354
- }
355
- __name(inspectFunction, "inspectFunction");
356
- function inspectMapEntry([key, value], options) {
357
- options.truncate -= 4;
358
- key = options.inspect(key, options);
359
- options.truncate -= key.length;
360
- value = options.inspect(value, options);
361
- return `${key} => ${value}`;
362
- }
363
- __name(inspectMapEntry, "inspectMapEntry");
364
- function mapToEntries(map) {
365
- const entries = [];
366
- map.forEach((value, key) => {
367
- entries.push([key, value]);
368
- });
369
- return entries;
370
- }
371
- __name(mapToEntries, "mapToEntries");
372
- function inspectMap(map, options) {
373
- if (map.size === 0) return "Map{}";
374
- options.truncate -= 7;
375
- return `Map{ ${inspectList(mapToEntries(map), options, inspectMapEntry)} }`;
376
- }
377
- __name(inspectMap, "inspectMap");
378
- var isNaN = Number.isNaN || ((i) => i !== i);
379
- function inspectNumber(number, options) {
380
- if (isNaN(number)) return options.stylize("NaN", "number");
381
- if (number === Infinity) return options.stylize("Infinity", "number");
382
- if (number === -Infinity) return options.stylize("-Infinity", "number");
383
- if (number === 0) return options.stylize(1 / number === Infinity ? "+0" : "-0", "number");
384
- return options.stylize(truncate(String(number), options.truncate), "number");
385
- }
386
- __name(inspectNumber, "inspectNumber");
387
- function inspectBigInt(number, options) {
388
- let nums = truncate(number.toString(), options.truncate - 1);
389
- if (nums !== truncator) nums += "n";
390
- return options.stylize(nums, "bigint");
391
- }
392
- __name(inspectBigInt, "inspectBigInt");
393
- function inspectRegExp(value, options) {
394
- const flags = value.toString().split("/")[2];
395
- const sourceLength = options.truncate - (2 + flags.length);
396
- const source = value.source;
397
- return options.stylize(`/${truncate(source, sourceLength)}/${flags}`, "regexp");
398
- }
399
- __name(inspectRegExp, "inspectRegExp");
400
- function arrayFromSet(set2) {
401
- const values = [];
402
- set2.forEach((value) => {
403
- values.push(value);
404
- });
405
- return values;
406
- }
407
- __name(arrayFromSet, "arrayFromSet");
408
- function inspectSet(set2, options) {
409
- if (set2.size === 0) return "Set{}";
410
- options.truncate -= 7;
411
- return `Set{ ${inspectList(arrayFromSet(set2), options)} }`;
412
- }
413
- __name(inspectSet, "inspectSet");
414
- var stringEscapeChars = /* @__PURE__ */ new RegExp("['\\u0000-\\u001f\\u007f-\\u009f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]", "g");
415
- var escapeCharacters = {
416
- "\b": "\\b",
417
- " ": "\\t",
418
- "\n": "\\n",
419
- "\f": "\\f",
420
- "\r": "\\r",
421
- "'": "\\'",
422
- "\\": "\\\\"
423
- };
424
- var hex = 16;
425
- var unicodeLength = 4;
426
- function escape(char) {
427
- return escapeCharacters[char] || `\\u${`0000${char.charCodeAt(0).toString(hex)}`.slice(-unicodeLength)}`;
428
- }
429
- __name(escape, "escape");
430
- function inspectString(string, options) {
431
- if (stringEscapeChars.test(string)) string = string.replace(stringEscapeChars, escape);
432
- return options.stylize(`'${truncate(string, options.truncate - 2)}'`, "string");
433
- }
434
- __name(inspectString, "inspectString");
435
- function inspectSymbol(value) {
436
- if ("description" in Symbol.prototype) return value.description ? `Symbol(${value.description})` : "Symbol()";
437
- return value.toString();
438
- }
439
- __name(inspectSymbol, "inspectSymbol");
440
- var promise_default = /* @__PURE__ */ __name(() => "Promise{…}", "getPromiseValue");
441
- function inspectObject(object, options) {
442
- const properties = Object.getOwnPropertyNames(object);
443
- const symbols = Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(object) : [];
444
- if (properties.length === 0 && symbols.length === 0) return "{}";
445
- options.truncate -= 4;
446
- options.seen = options.seen || [];
447
- if (options.seen.includes(object)) return "[Circular]";
448
- options.seen.push(object);
449
- const propertyContents = inspectList(properties.map((key) => [key, object[key]]), options, inspectProperty);
450
- const symbolContents = inspectList(symbols.map((key) => [key, object[key]]), options, inspectProperty);
451
- options.seen.pop();
452
- let sep = "";
453
- if (propertyContents && symbolContents) sep = ", ";
454
- return `{ ${propertyContents}${sep}${symbolContents} }`;
455
- }
456
- __name(inspectObject, "inspectObject");
457
- var toStringTag = typeof Symbol !== "undefined" && Symbol.toStringTag ? Symbol.toStringTag : false;
458
- function inspectClass(value, options) {
459
- let name = "";
460
- if (toStringTag && toStringTag in value) name = value[toStringTag];
461
- name = name || value.constructor.name;
462
- if (!name || name === "_class") name = "<Anonymous Class>";
463
- options.truncate -= name.length;
464
- return `${name}${inspectObject(value, options)}`;
465
- }
466
- __name(inspectClass, "inspectClass");
467
- function inspectArguments(args, options) {
468
- if (args.length === 0) return "Arguments[]";
469
- options.truncate -= 13;
470
- return `Arguments[ ${inspectList(args, options)} ]`;
471
- }
472
- __name(inspectArguments, "inspectArguments");
473
- var errorKeys = [
474
- "stack",
475
- "line",
476
- "column",
477
- "name",
478
- "message",
479
- "fileName",
480
- "lineNumber",
481
- "columnNumber",
482
- "number",
483
- "description",
484
- "cause"
485
- ];
486
- function inspectObject2(error, options) {
487
- const properties = Object.getOwnPropertyNames(error).filter((key) => errorKeys.indexOf(key) === -1);
488
- const name = error.name;
489
- options.truncate -= name.length;
490
- let message = "";
491
- if (typeof error.message === "string") message = truncate(error.message, options.truncate);
492
- else properties.unshift("message");
493
- message = message ? `: ${message}` : "";
494
- options.truncate -= message.length + 5;
495
- options.seen = options.seen || [];
496
- if (options.seen.includes(error)) return "[Circular]";
497
- options.seen.push(error);
498
- const propertyContents = inspectList(properties.map((key) => [key, error[key]]), options, inspectProperty);
499
- return `${name}${message}${propertyContents ? ` { ${propertyContents} }` : ""}`;
500
- }
501
- __name(inspectObject2, "inspectObject");
502
- function inspectAttribute([key, value], options) {
503
- options.truncate -= 3;
504
- if (!value) return `${options.stylize(String(key), "yellow")}`;
505
- return `${options.stylize(String(key), "yellow")}=${options.stylize(`"${value}"`, "string")}`;
506
- }
507
- __name(inspectAttribute, "inspectAttribute");
508
- function inspectNodeCollection(collection, options) {
509
- return inspectList(collection, options, inspectNode, "\n");
510
- }
511
- __name(inspectNodeCollection, "inspectNodeCollection");
512
- function inspectNode(node, options) {
513
- switch (node.nodeType) {
514
- case 1: return inspectHTML(node, options);
515
- case 3: return options.inspect(node.data, options);
516
- default: return options.inspect(node, options);
517
- }
518
- }
519
- __name(inspectNode, "inspectNode");
520
- function inspectHTML(element, options) {
521
- const properties = element.getAttributeNames();
522
- const name = element.tagName.toLowerCase();
523
- const head = options.stylize(`<${name}`, "special");
524
- const headClose = options.stylize(`>`, "special");
525
- const tail = options.stylize(`</${name}>`, "special");
526
- options.truncate -= name.length * 2 + 5;
527
- let propertyContents = "";
528
- if (properties.length > 0) {
529
- propertyContents += " ";
530
- propertyContents += inspectList(properties.map((key) => [key, element.getAttribute(key)]), options, inspectAttribute, " ");
531
- }
532
- options.truncate -= propertyContents.length;
533
- const truncate2 = options.truncate;
534
- let children = inspectNodeCollection(element.children, options);
535
- if (children && children.length > truncate2) children = `${truncator}(${element.children.length})`;
536
- return `${head}${propertyContents}${headClose}${children}${tail}`;
537
- }
538
- __name(inspectHTML, "inspectHTML");
539
- var chaiInspect = typeof Symbol === "function" && typeof Symbol.for === "function" ? /* @__PURE__ */ Symbol.for("chai/inspect") : "@@chai/inspect";
540
- var nodeInspect = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
541
- var constructorMap = /* @__PURE__ */ new WeakMap();
542
- var stringTagMap = {};
543
- var baseTypesMap = {
544
- undefined: /* @__PURE__ */ __name((value, options) => options.stylize("undefined", "undefined"), "undefined"),
545
- null: /* @__PURE__ */ __name((value, options) => options.stylize("null", "null"), "null"),
546
- boolean: /* @__PURE__ */ __name((value, options) => options.stylize(String(value), "boolean"), "boolean"),
547
- Boolean: /* @__PURE__ */ __name((value, options) => options.stylize(String(value), "boolean"), "Boolean"),
548
- number: inspectNumber,
549
- Number: inspectNumber,
550
- bigint: inspectBigInt,
551
- BigInt: inspectBigInt,
552
- string: inspectString,
553
- String: inspectString,
554
- function: inspectFunction,
555
- Function: inspectFunction,
556
- symbol: inspectSymbol,
557
- Symbol: inspectSymbol,
558
- Array: inspectArray,
559
- Date: inspectDate,
560
- Map: inspectMap,
561
- Set: inspectSet,
562
- RegExp: inspectRegExp,
563
- Promise: promise_default,
564
- WeakSet: /* @__PURE__ */ __name((value, options) => options.stylize("WeakSet{…}", "special"), "WeakSet"),
565
- WeakMap: /* @__PURE__ */ __name((value, options) => options.stylize("WeakMap{…}", "special"), "WeakMap"),
566
- Arguments: inspectArguments,
567
- Int8Array: inspectTypedArray,
568
- Uint8Array: inspectTypedArray,
569
- Uint8ClampedArray: inspectTypedArray,
570
- Int16Array: inspectTypedArray,
571
- Uint16Array: inspectTypedArray,
572
- Int32Array: inspectTypedArray,
573
- Uint32Array: inspectTypedArray,
574
- Float32Array: inspectTypedArray,
575
- Float64Array: inspectTypedArray,
576
- Generator: /* @__PURE__ */ __name(() => "", "Generator"),
577
- DataView: /* @__PURE__ */ __name(() => "", "DataView"),
578
- ArrayBuffer: /* @__PURE__ */ __name(() => "", "ArrayBuffer"),
579
- Error: inspectObject2,
580
- HTMLCollection: inspectNodeCollection,
581
- NodeList: inspectNodeCollection
582
- };
583
- var inspectCustom = /* @__PURE__ */ __name((value, options, type3, inspectFn) => {
584
- if (chaiInspect in value && typeof value[chaiInspect] === "function") return value[chaiInspect](options);
585
- if (nodeInspect in value && typeof value[nodeInspect] === "function") return value[nodeInspect](options.depth, options, inspectFn);
586
- if ("inspect" in value && typeof value.inspect === "function") return value.inspect(options.depth, options);
587
- if ("constructor" in value && constructorMap.has(value.constructor)) return constructorMap.get(value.constructor)(value, options);
588
- if (stringTagMap[type3]) return stringTagMap[type3](value, options);
589
- return "";
590
- }, "inspectCustom");
591
- var toString = Object.prototype.toString;
592
- function inspect(value, opts = {}) {
593
- const options = normaliseOptions(opts, inspect);
594
- const { customInspect } = options;
595
- let type3 = value === null ? "null" : typeof value;
596
- if (type3 === "object") type3 = toString.call(value).slice(8, -1);
597
- if (type3 in baseTypesMap) return baseTypesMap[type3](value, options);
598
- if (customInspect && value) {
599
- const output = inspectCustom(value, options, type3, inspect);
600
- if (output) {
601
- if (typeof output === "string") return output;
602
- return inspect(output, options);
603
- }
604
- }
605
- const proto = value ? Object.getPrototypeOf(value) : false;
606
- if (proto === Object.prototype || proto === null) return inspectObject(value, options);
607
- if (value && typeof HTMLElement === "function" && value instanceof HTMLElement) return inspectHTML(value, options);
608
- if ("constructor" in value) {
609
- if (value.constructor !== Object) return inspectClass(value, options);
610
- return inspectObject(value, options);
611
- }
612
- if (value === Object(value)) return inspectObject(value, options);
613
- return options.stylize(String(value), type3);
614
- }
615
- __name(inspect, "inspect");
616
- var config = {
617
- /**
618
- * ### config.includeStack
619
- *
620
- * User configurable property, influences whether stack trace
621
- * is included in Assertion error message. Default of false
622
- * suppresses stack trace in the error message.
623
- *
624
- * chai.config.includeStack = true; // enable stack on error
625
- *
626
- * @param {boolean}
627
- * @public
628
- */
629
- includeStack: false,
630
- /**
631
- * ### config.showDiff
632
- *
633
- * User configurable property, influences whether or not
634
- * the `showDiff` flag should be included in the thrown
635
- * AssertionErrors. `false` will always be `false`; `true`
636
- * will be true when the assertion has requested a diff
637
- * be shown.
638
- *
639
- * @param {boolean}
640
- * @public
641
- */
642
- showDiff: true,
643
- /**
644
- * ### config.truncateThreshold
645
- *
646
- * User configurable property, sets length threshold for actual and
647
- * expected values in assertion errors. If this threshold is exceeded, for
648
- * example for large data structures, the value is replaced with something
649
- * like `[ Array(3) ]` or `{ Object (prop1, prop2) }`.
650
- *
651
- * Set it to zero if you want to disable truncating altogether.
652
- *
653
- * This is especially userful when doing assertions on arrays: having this
654
- * set to a reasonable large value makes the failure messages readily
655
- * inspectable.
656
- *
657
- * chai.config.truncateThreshold = 0; // disable truncating
658
- *
659
- * @param {number}
660
- * @public
661
- */
662
- truncateThreshold: 40,
663
- /**
664
- * ### config.useProxy
665
- *
666
- * User configurable property, defines if chai will use a Proxy to throw
667
- * an error when a non-existent property is read, which protects users
668
- * from typos when using property-based assertions.
669
- *
670
- * Set it to false if you want to disable this feature.
671
- *
672
- * chai.config.useProxy = false; // disable use of Proxy
673
- *
674
- * This feature is automatically disabled regardless of this config value
675
- * in environments that don't support proxies.
676
- *
677
- * @param {boolean}
678
- * @public
679
- */
680
- useProxy: true,
681
- /**
682
- * ### config.proxyExcludedKeys
683
- *
684
- * User configurable property, defines which properties should be ignored
685
- * instead of throwing an error if they do not exist on the assertion.
686
- * This is only applied if the environment Chai is running in supports proxies and
687
- * if the `useProxy` configuration setting is enabled.
688
- * By default, `then` and `inspect` will not throw an error if they do not exist on the
689
- * assertion object because the `.inspect` property is read by `util.inspect` (for example, when
690
- * using `console.log` on the assertion object) and `.then` is necessary for promise type-checking.
691
- *
692
- * // By default these keys will not throw an error if they do not exist on the assertion object
693
- * chai.config.proxyExcludedKeys = ['then', 'inspect'];
694
- *
695
- * @param {Array}
696
- * @public
697
- */
698
- proxyExcludedKeys: [
699
- "then",
700
- "catch",
701
- "inspect",
702
- "toJSON"
703
- ],
704
- /**
705
- * ### config.deepEqual
706
- *
707
- * User configurable property, defines which a custom function to use for deepEqual
708
- * comparisons.
709
- * By default, the function used is the one from the `deep-eql` package without custom comparator.
710
- *
711
- * // use a custom comparator
712
- * chai.config.deepEqual = (expected, actual) => {
713
- * return chai.util.eql(expected, actual, {
714
- * comparator: (expected, actual) => {
715
- * // for non number comparison, use the default behavior
716
- * if(typeof expected !== 'number') return null;
717
- * // allow a difference of 10 between compared numbers
718
- * return typeof actual === 'number' && Math.abs(actual - expected) < 10
719
- * }
720
- * })
721
- * };
722
- *
723
- * @param {Function}
724
- * @public
725
- */
726
- deepEqual: null
727
- };
728
- function inspect2(obj, showHidden, depth, colors) {
729
- return inspect(obj, {
730
- colors,
731
- depth: typeof depth === "undefined" ? 2 : depth,
732
- showHidden,
733
- truncate: config.truncateThreshold ? config.truncateThreshold : Infinity
734
- });
735
- }
736
- __name(inspect2, "inspect");
737
- function objDisplay(obj) {
738
- let str = inspect2(obj), type3 = Object.prototype.toString.call(obj);
739
- if (config.truncateThreshold && str.length >= config.truncateThreshold) if (type3 === "[object Function]") return !obj.name || obj.name === "" ? "[Function]" : "[Function: " + obj.name + "]";
740
- else if (type3 === "[object Array]") return "[ Array(" + obj.length + ") ]";
741
- else if (type3 === "[object Object]") {
742
- let keys = Object.keys(obj);
743
- return "{ Object (" + (keys.length > 2 ? keys.splice(0, 2).join(", ") + ", ..." : keys.join(", ")) + ") }";
744
- } else return str;
745
- else return str;
746
- }
747
- __name(objDisplay, "objDisplay");
748
- function getMessage2(obj, args) {
749
- let negate = flag(obj, "negate");
750
- let val = flag(obj, "object");
751
- let expected = args[3];
752
- let actual = getActual(obj, args);
753
- let msg = negate ? args[2] : args[1];
754
- let flagMsg = flag(obj, "message");
755
- if (typeof msg === "function") msg = msg();
756
- msg = msg || "";
757
- msg = msg.replace(/#\{this\}/g, function() {
758
- return objDisplay(val);
759
- }).replace(/#\{act\}/g, function() {
760
- return objDisplay(actual);
761
- }).replace(/#\{exp\}/g, function() {
762
- return objDisplay(expected);
763
- });
764
- return flagMsg ? flagMsg + ": " + msg : msg;
765
- }
766
- __name(getMessage2, "getMessage");
767
- function transferFlags(assertion, object, includeAll) {
768
- let flags = assertion.__flags || (assertion.__flags = /* @__PURE__ */ Object.create(null));
769
- if (!object.__flags) object.__flags = /* @__PURE__ */ Object.create(null);
770
- includeAll = arguments.length === 3 ? includeAll : true;
771
- for (let flag3 in flags) if (includeAll || flag3 !== "object" && flag3 !== "ssfi" && flag3 !== "lockSsfi" && flag3 != "message") object.__flags[flag3] = flags[flag3];
772
- }
773
- __name(transferFlags, "transferFlags");
774
- function type2(obj) {
775
- if (typeof obj === "undefined") return "undefined";
776
- if (obj === null) return "null";
777
- const stringTag = obj[Symbol.toStringTag];
778
- if (typeof stringTag === "string") return stringTag;
779
- return Object.prototype.toString.call(obj).slice(8, -1);
780
- }
781
- __name(type2, "type");
782
- function FakeMap() {
783
- this._key = "chai/deep-eql__" + Math.random() + Date.now();
784
- }
785
- __name(FakeMap, "FakeMap");
786
- FakeMap.prototype = {
787
- get: /* @__PURE__ */ __name(function get(key) {
788
- return key[this._key];
789
- }, "get"),
790
- set: /* @__PURE__ */ __name(function set(key, value) {
791
- if (Object.isExtensible(key)) Object.defineProperty(key, this._key, {
792
- value,
793
- configurable: true
794
- });
795
- }, "set")
796
- };
797
- var MemoizeMap = typeof WeakMap === "function" ? WeakMap : FakeMap;
798
- function memoizeCompare(leftHandOperand, rightHandOperand, memoizeMap) {
799
- if (!memoizeMap || isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand)) return null;
800
- var leftHandMap = memoizeMap.get(leftHandOperand);
801
- if (leftHandMap) {
802
- var result = leftHandMap.get(rightHandOperand);
803
- if (typeof result === "boolean") return result;
804
- }
805
- return null;
806
- }
807
- __name(memoizeCompare, "memoizeCompare");
808
- function memoizeSet(leftHandOperand, rightHandOperand, memoizeMap, result) {
809
- if (!memoizeMap || isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand)) return;
810
- var leftHandMap = memoizeMap.get(leftHandOperand);
811
- if (leftHandMap) leftHandMap.set(rightHandOperand, result);
812
- else {
813
- leftHandMap = new MemoizeMap();
814
- leftHandMap.set(rightHandOperand, result);
815
- memoizeMap.set(leftHandOperand, leftHandMap);
816
- }
817
- }
818
- __name(memoizeSet, "memoizeSet");
819
- var deep_eql_default = deepEqual;
820
- function deepEqual(leftHandOperand, rightHandOperand, options) {
821
- if (options && options.comparator) return extensiveDeepEqual(leftHandOperand, rightHandOperand, options);
822
- var simpleResult = simpleEqual(leftHandOperand, rightHandOperand);
823
- if (simpleResult !== null) return simpleResult;
824
- return extensiveDeepEqual(leftHandOperand, rightHandOperand, options);
825
- }
826
- __name(deepEqual, "deepEqual");
827
- function simpleEqual(leftHandOperand, rightHandOperand) {
828
- if (leftHandOperand === rightHandOperand) return leftHandOperand !== 0 || 1 / leftHandOperand === 1 / rightHandOperand;
829
- if (leftHandOperand !== leftHandOperand && rightHandOperand !== rightHandOperand) return true;
830
- if (isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand)) return false;
831
- return null;
832
- }
833
- __name(simpleEqual, "simpleEqual");
834
- function extensiveDeepEqual(leftHandOperand, rightHandOperand, options) {
835
- options = options || {};
836
- options.memoize = options.memoize === false ? false : options.memoize || new MemoizeMap();
837
- var comparator = options && options.comparator;
838
- var memoizeResultLeft = memoizeCompare(leftHandOperand, rightHandOperand, options.memoize);
839
- if (memoizeResultLeft !== null) return memoizeResultLeft;
840
- var memoizeResultRight = memoizeCompare(rightHandOperand, leftHandOperand, options.memoize);
841
- if (memoizeResultRight !== null) return memoizeResultRight;
842
- if (comparator) {
843
- var comparatorResult = comparator(leftHandOperand, rightHandOperand);
844
- if (comparatorResult === false || comparatorResult === true) {
845
- memoizeSet(leftHandOperand, rightHandOperand, options.memoize, comparatorResult);
846
- return comparatorResult;
847
- }
848
- var simpleResult = simpleEqual(leftHandOperand, rightHandOperand);
849
- if (simpleResult !== null) return simpleResult;
850
- }
851
- var leftHandType = type2(leftHandOperand);
852
- if (leftHandType !== type2(rightHandOperand)) {
853
- memoizeSet(leftHandOperand, rightHandOperand, options.memoize, false);
854
- return false;
855
- }
856
- memoizeSet(leftHandOperand, rightHandOperand, options.memoize, true);
857
- var result = extensiveDeepEqualByType(leftHandOperand, rightHandOperand, leftHandType, options);
858
- memoizeSet(leftHandOperand, rightHandOperand, options.memoize, result);
859
- return result;
860
- }
861
- __name(extensiveDeepEqual, "extensiveDeepEqual");
862
- function extensiveDeepEqualByType(leftHandOperand, rightHandOperand, leftHandType, options) {
863
- switch (leftHandType) {
864
- case "String":
865
- case "Number":
866
- case "Boolean":
867
- case "Date": return deepEqual(leftHandOperand.valueOf(), rightHandOperand.valueOf());
868
- case "Promise":
869
- case "Symbol":
870
- case "function":
871
- case "WeakMap":
872
- case "WeakSet": return leftHandOperand === rightHandOperand;
873
- case "Error": return keysEqual(leftHandOperand, rightHandOperand, [
874
- "name",
875
- "message",
876
- "code"
877
- ], options);
878
- case "Arguments":
879
- case "Int8Array":
880
- case "Uint8Array":
881
- case "Uint8ClampedArray":
882
- case "Int16Array":
883
- case "Uint16Array":
884
- case "Int32Array":
885
- case "Uint32Array":
886
- case "Float32Array":
887
- case "Float64Array":
888
- case "Array": return iterableEqual(leftHandOperand, rightHandOperand, options);
889
- case "RegExp": return regexpEqual(leftHandOperand, rightHandOperand);
890
- case "Generator": return generatorEqual(leftHandOperand, rightHandOperand, options);
891
- case "DataView": return iterableEqual(new Uint8Array(leftHandOperand.buffer), new Uint8Array(rightHandOperand.buffer), options);
892
- case "ArrayBuffer": return iterableEqual(new Uint8Array(leftHandOperand), new Uint8Array(rightHandOperand), options);
893
- case "Set": return entriesEqual(leftHandOperand, rightHandOperand, options);
894
- case "Map": return entriesEqual(leftHandOperand, rightHandOperand, options);
895
- case "Temporal.PlainDate":
896
- case "Temporal.PlainTime":
897
- case "Temporal.PlainDateTime":
898
- case "Temporal.Instant":
899
- case "Temporal.ZonedDateTime":
900
- case "Temporal.PlainYearMonth":
901
- case "Temporal.PlainMonthDay": return leftHandOperand.equals(rightHandOperand);
902
- case "Temporal.Duration": return leftHandOperand.total("nanoseconds") === rightHandOperand.total("nanoseconds");
903
- case "Temporal.TimeZone":
904
- case "Temporal.Calendar": return leftHandOperand.toString() === rightHandOperand.toString();
905
- default: return objectEqual(leftHandOperand, rightHandOperand, options);
906
- }
907
- }
908
- __name(extensiveDeepEqualByType, "extensiveDeepEqualByType");
909
- function regexpEqual(leftHandOperand, rightHandOperand) {
910
- return leftHandOperand.toString() === rightHandOperand.toString();
911
- }
912
- __name(regexpEqual, "regexpEqual");
913
- function entriesEqual(leftHandOperand, rightHandOperand, options) {
914
- try {
915
- if (leftHandOperand.size !== rightHandOperand.size) return false;
916
- if (leftHandOperand.size === 0) return true;
917
- } catch (sizeError) {
918
- return false;
919
- }
920
- var leftHandItems = [];
921
- var rightHandItems = [];
922
- leftHandOperand.forEach(/* @__PURE__ */ __name(function gatherEntries(key, value) {
923
- leftHandItems.push([key, value]);
924
- }, "gatherEntries"));
925
- rightHandOperand.forEach(/* @__PURE__ */ __name(function gatherEntries(key, value) {
926
- rightHandItems.push([key, value]);
927
- }, "gatherEntries"));
928
- return iterableEqual(leftHandItems.sort(), rightHandItems.sort(), options);
929
- }
930
- __name(entriesEqual, "entriesEqual");
931
- function iterableEqual(leftHandOperand, rightHandOperand, options) {
932
- var length = leftHandOperand.length;
933
- if (length !== rightHandOperand.length) return false;
934
- if (length === 0) return true;
935
- var index = -1;
936
- while (++index < length) if (deepEqual(leftHandOperand[index], rightHandOperand[index], options) === false) return false;
937
- return true;
938
- }
939
- __name(iterableEqual, "iterableEqual");
940
- function generatorEqual(leftHandOperand, rightHandOperand, options) {
941
- return iterableEqual(getGeneratorEntries(leftHandOperand), getGeneratorEntries(rightHandOperand), options);
942
- }
943
- __name(generatorEqual, "generatorEqual");
944
- function hasIteratorFunction(target) {
945
- return typeof Symbol !== "undefined" && typeof target === "object" && typeof Symbol.iterator !== "undefined" && typeof target[Symbol.iterator] === "function";
946
- }
947
- __name(hasIteratorFunction, "hasIteratorFunction");
948
- function getIteratorEntries(target) {
949
- if (hasIteratorFunction(target)) try {
950
- return getGeneratorEntries(target[Symbol.iterator]());
951
- } catch (iteratorError) {
952
- return [];
953
- }
954
- return [];
955
- }
956
- __name(getIteratorEntries, "getIteratorEntries");
957
- function getGeneratorEntries(generator) {
958
- var generatorResult = generator.next();
959
- var accumulator = [generatorResult.value];
960
- while (generatorResult.done === false) {
961
- generatorResult = generator.next();
962
- accumulator.push(generatorResult.value);
963
- }
964
- return accumulator;
965
- }
966
- __name(getGeneratorEntries, "getGeneratorEntries");
967
- function getEnumerableKeys(target) {
968
- var keys = [];
969
- for (var key in target) keys.push(key);
970
- return keys;
971
- }
972
- __name(getEnumerableKeys, "getEnumerableKeys");
973
- function getEnumerableSymbols(target) {
974
- var keys = [];
975
- var allKeys = Object.getOwnPropertySymbols(target);
976
- for (var i = 0; i < allKeys.length; i += 1) {
977
- var key = allKeys[i];
978
- if (Object.getOwnPropertyDescriptor(target, key).enumerable) keys.push(key);
979
- }
980
- return keys;
981
- }
982
- __name(getEnumerableSymbols, "getEnumerableSymbols");
983
- function keysEqual(leftHandOperand, rightHandOperand, keys, options) {
984
- var length = keys.length;
985
- if (length === 0) return true;
986
- for (var i = 0; i < length; i += 1) if (deepEqual(leftHandOperand[keys[i]], rightHandOperand[keys[i]], options) === false) return false;
987
- return true;
988
- }
989
- __name(keysEqual, "keysEqual");
990
- function objectEqual(leftHandOperand, rightHandOperand, options) {
991
- var leftHandKeys = getEnumerableKeys(leftHandOperand);
992
- var rightHandKeys = getEnumerableKeys(rightHandOperand);
993
- var leftHandSymbols = getEnumerableSymbols(leftHandOperand);
994
- var rightHandSymbols = getEnumerableSymbols(rightHandOperand);
995
- leftHandKeys = leftHandKeys.concat(leftHandSymbols);
996
- rightHandKeys = rightHandKeys.concat(rightHandSymbols);
997
- if (leftHandKeys.length && leftHandKeys.length === rightHandKeys.length) {
998
- if (iterableEqual(mapSymbols(leftHandKeys).sort(), mapSymbols(rightHandKeys).sort()) === false) return false;
999
- return keysEqual(leftHandOperand, rightHandOperand, leftHandKeys, options);
1000
- }
1001
- var leftHandEntries = getIteratorEntries(leftHandOperand);
1002
- var rightHandEntries = getIteratorEntries(rightHandOperand);
1003
- if (leftHandEntries.length && leftHandEntries.length === rightHandEntries.length) {
1004
- leftHandEntries.sort();
1005
- rightHandEntries.sort();
1006
- return iterableEqual(leftHandEntries, rightHandEntries, options);
1007
- }
1008
- if (leftHandKeys.length === 0 && leftHandEntries.length === 0 && rightHandKeys.length === 0 && rightHandEntries.length === 0) return true;
1009
- return false;
1010
- }
1011
- __name(objectEqual, "objectEqual");
1012
- function isPrimitive(value) {
1013
- return value === null || typeof value !== "object";
1014
- }
1015
- __name(isPrimitive, "isPrimitive");
1016
- function mapSymbols(arr) {
1017
- return arr.map(/* @__PURE__ */ __name(function mapSymbol(entry) {
1018
- if (typeof entry === "symbol") return entry.toString();
1019
- return entry;
1020
- }, "mapSymbol"));
1021
- }
1022
- __name(mapSymbols, "mapSymbols");
1023
- function hasProperty(obj, name) {
1024
- if (typeof obj === "undefined" || obj === null) return false;
1025
- return name in Object(obj);
1026
- }
1027
- __name(hasProperty, "hasProperty");
1028
- function parsePath(path) {
1029
- return path.replace(/([^\\])\[/g, "$1.[").match(/(\\\.|[^.]+?)+/g).map((value) => {
1030
- if (value === "constructor" || value === "__proto__" || value === "prototype") return {};
1031
- const mArr = /^\[(\d+)\]$/.exec(value);
1032
- let parsed = null;
1033
- if (mArr) parsed = { i: parseFloat(mArr[1]) };
1034
- else parsed = { p: value.replace(/\\([.[\]])/g, "$1") };
1035
- return parsed;
1036
- });
1037
- }
1038
- __name(parsePath, "parsePath");
1039
- function internalGetPathValue(obj, parsed, pathDepth) {
1040
- let temporaryValue = obj;
1041
- let res = null;
1042
- pathDepth = typeof pathDepth === "undefined" ? parsed.length : pathDepth;
1043
- for (let i = 0; i < pathDepth; i++) {
1044
- const part = parsed[i];
1045
- if (temporaryValue) {
1046
- if (typeof part.p === "undefined") temporaryValue = temporaryValue[part.i];
1047
- else temporaryValue = temporaryValue[part.p];
1048
- if (i === pathDepth - 1) res = temporaryValue;
1049
- }
1050
- }
1051
- return res;
1052
- }
1053
- __name(internalGetPathValue, "internalGetPathValue");
1054
- function getPathInfo(obj, path) {
1055
- const parsed = parsePath(path);
1056
- const last = parsed[parsed.length - 1];
1057
- const info = {
1058
- parent: parsed.length > 1 ? internalGetPathValue(obj, parsed, parsed.length - 1) : obj,
1059
- name: last.p || last.i,
1060
- value: internalGetPathValue(obj, parsed)
1061
- };
1062
- info.exists = hasProperty(info.parent, info.name);
1063
- return info;
1064
- }
1065
- __name(getPathInfo, "getPathInfo");
1066
- var _Assertion = class _Assertion {
1067
- /**
1068
- * Creates object for chaining.
1069
- * `Assertion` objects contain metadata in the form of flags. Three flags can
1070
- * be assigned during instantiation by passing arguments to this constructor:
1071
- *
1072
- * - `object`: This flag contains the target of the assertion. For example, in
1073
- * the assertion `expect(numKittens).to.equal(7);`, the `object` flag will
1074
- * contain `numKittens` so that the `equal` assertion can reference it when
1075
- * needed.
1076
- *
1077
- * - `message`: This flag contains an optional custom error message to be
1078
- * prepended to the error message that's generated by the assertion when it
1079
- * fails.
1080
- *
1081
- * - `ssfi`: This flag stands for "start stack function indicator". It
1082
- * contains a function reference that serves as the starting point for
1083
- * removing frames from the stack trace of the error that's created by the
1084
- * assertion when it fails. The goal is to provide a cleaner stack trace to
1085
- * end users by removing Chai's internal functions. Note that it only works
1086
- * in environments that support `Error.captureStackTrace`, and only when
1087
- * `Chai.config.includeStack` hasn't been set to `false`.
1088
- *
1089
- * - `lockSsfi`: This flag controls whether or not the given `ssfi` flag
1090
- * should retain its current value, even as assertions are chained off of
1091
- * this object. This is usually set to `true` when creating a new assertion
1092
- * from within another assertion. It's also temporarily set to `true` before
1093
- * an overwritten assertion gets called by the overwriting assertion.
1094
- *
1095
- * - `eql`: This flag contains the deepEqual function to be used by the assertion.
1096
- *
1097
- * @param {unknown} obj target of the assertion
1098
- * @param {string} [msg] (optional) custom error message
1099
- * @param {Function} [ssfi] (optional) starting point for removing stack frames
1100
- * @param {boolean} [lockSsfi] (optional) whether or not the ssfi flag is locked
1101
- */
1102
- constructor(obj, msg, ssfi, lockSsfi) {
1103
- /** @type {{}} */
1104
- __publicField(this, "__flags", {});
1105
- flag(this, "ssfi", ssfi || _Assertion);
1106
- flag(this, "lockSsfi", lockSsfi);
1107
- flag(this, "object", obj);
1108
- flag(this, "message", msg);
1109
- flag(this, "eql", config.deepEqual || deep_eql_default);
1110
- return proxify(this);
1111
- }
1112
- /** @returns {boolean} */
1113
- static get includeStack() {
1114
- console.warn("Assertion.includeStack is deprecated, use chai.config.includeStack instead.");
1115
- return config.includeStack;
1116
- }
1117
- /** @param {boolean} value */
1118
- static set includeStack(value) {
1119
- console.warn("Assertion.includeStack is deprecated, use chai.config.includeStack instead.");
1120
- config.includeStack = value;
1121
- }
1122
- /** @returns {boolean} */
1123
- static get showDiff() {
1124
- console.warn("Assertion.showDiff is deprecated, use chai.config.showDiff instead.");
1125
- return config.showDiff;
1126
- }
1127
- /** @param {boolean} value */
1128
- static set showDiff(value) {
1129
- console.warn("Assertion.showDiff is deprecated, use chai.config.showDiff instead.");
1130
- config.showDiff = value;
1131
- }
1132
- /**
1133
- * @param {string} name
1134
- * @param {Function} fn
1135
- */
1136
- static addProperty(name, fn) {
1137
- addProperty(this.prototype, name, fn);
1138
- }
1139
- /**
1140
- * @param {string} name
1141
- * @param {Function} fn
1142
- */
1143
- static addMethod(name, fn) {
1144
- addMethod(this.prototype, name, fn);
1145
- }
1146
- /**
1147
- * @param {string} name
1148
- * @param {Function} fn
1149
- * @param {Function} chainingBehavior
1150
- */
1151
- static addChainableMethod(name, fn, chainingBehavior) {
1152
- addChainableMethod(this.prototype, name, fn, chainingBehavior);
1153
- }
1154
- /**
1155
- * @param {string} name
1156
- * @param {Function} fn
1157
- */
1158
- static overwriteProperty(name, fn) {
1159
- overwriteProperty(this.prototype, name, fn);
1160
- }
1161
- /**
1162
- * @param {string} name
1163
- * @param {Function} fn
1164
- */
1165
- static overwriteMethod(name, fn) {
1166
- overwriteMethod(this.prototype, name, fn);
1167
- }
1168
- /**
1169
- * @param {string} name
1170
- * @param {Function} fn
1171
- * @param {Function} chainingBehavior
1172
- */
1173
- static overwriteChainableMethod(name, fn, chainingBehavior) {
1174
- overwriteChainableMethod(this.prototype, name, fn, chainingBehavior);
1175
- }
1176
- /**
1177
- * ### .assert(expression, message, negateMessage, expected, actual, showDiff)
1178
- *
1179
- * Executes an expression and check expectations. Throws AssertionError for reporting if test doesn't pass.
1180
- *
1181
- * @name assert
1182
- * @param {unknown} _expr to be tested
1183
- * @param {string | Function} msg or function that returns message to display if expression fails
1184
- * @param {string | Function} _negateMsg or function that returns negatedMessage to display if negated expression fails
1185
- * @param {unknown} expected value (remember to check for negation)
1186
- * @param {unknown} _actual (optional) will default to `this.obj`
1187
- * @param {boolean} showDiff (optional) when set to `true`, assert will display a diff in addition to the message if expression fails
1188
- * @returns {void}
1189
- */
1190
- assert(_expr, msg, _negateMsg, expected, _actual, showDiff) {
1191
- const ok = test(this, arguments);
1192
- if (false !== showDiff) showDiff = true;
1193
- if (void 0 === expected && void 0 === _actual) showDiff = false;
1194
- if (true !== config.showDiff) showDiff = false;
1195
- if (!ok) {
1196
- msg = getMessage2(this, arguments);
1197
- const assertionErrorObjectProperties = {
1198
- actual: getActual(this, arguments),
1199
- expected,
1200
- showDiff
1201
- };
1202
- const operator = getOperator(this, arguments);
1203
- if (operator) assertionErrorObjectProperties.operator = operator;
1204
- throw new AssertionError(msg, assertionErrorObjectProperties, config.includeStack ? this.assert : flag(this, "ssfi"));
1205
- }
1206
- }
1207
- /**
1208
- * Quick reference to stored `actual` value for plugin developers.
1209
- *
1210
- * @returns {unknown}
1211
- */
1212
- get _obj() {
1213
- return flag(this, "object");
1214
- }
1215
- /**
1216
- * Quick reference to stored `actual` value for plugin developers.
1217
- *
1218
- * @param {unknown} val
1219
- */
1220
- set _obj(val) {
1221
- flag(this, "object", val);
1222
- }
1223
- };
1224
- __name(_Assertion, "Assertion");
1225
- var Assertion = _Assertion;
1226
- var events = new EventTarget();
1227
- var _PluginEvent = class _PluginEvent extends Event {
1228
- constructor(type3, name, fn) {
1229
- super(type3);
1230
- this.name = String(name);
1231
- this.fn = fn;
1232
- }
1233
- };
1234
- __name(_PluginEvent, "PluginEvent");
1235
- var PluginEvent = _PluginEvent;
1236
- function isProxyEnabled() {
1237
- return config.useProxy && typeof Proxy !== "undefined" && typeof Reflect !== "undefined";
1238
- }
1239
- __name(isProxyEnabled, "isProxyEnabled");
1240
- function addProperty(ctx, name, getter) {
1241
- getter = getter === void 0 ? function() {} : getter;
1242
- Object.defineProperty(ctx, name, {
1243
- get: /* @__PURE__ */ __name(function propertyGetter() {
1244
- if (!isProxyEnabled() && !flag(this, "lockSsfi")) flag(this, "ssfi", propertyGetter);
1245
- let result = getter.call(this);
1246
- if (result !== void 0) return result;
1247
- let newAssertion = new Assertion();
1248
- transferFlags(this, newAssertion);
1249
- return newAssertion;
1250
- }, "propertyGetter"),
1251
- configurable: true
1252
- });
1253
- events.dispatchEvent(new PluginEvent("addProperty", name, getter));
1254
- }
1255
- __name(addProperty, "addProperty");
1256
- var fnLengthDesc = Object.getOwnPropertyDescriptor(function() {}, "length");
1257
- function addLengthGuard(fn, assertionName, isChainable) {
1258
- if (!fnLengthDesc.configurable) return fn;
1259
- Object.defineProperty(fn, "length", { get: /* @__PURE__ */ __name(function() {
1260
- if (isChainable) throw Error("Invalid Chai property: " + assertionName + ".length. Due to a compatibility issue, \"length\" cannot directly follow \"" + assertionName + "\". Use \"" + assertionName + ".lengthOf\" instead.");
1261
- throw Error("Invalid Chai property: " + assertionName + ".length. See docs for proper usage of \"" + assertionName + "\".");
1262
- }, "get") });
1263
- return fn;
1264
- }
1265
- __name(addLengthGuard, "addLengthGuard");
1266
- function getProperties(object) {
1267
- let result = Object.getOwnPropertyNames(object);
1268
- function addProperty2(property) {
1269
- if (result.indexOf(property) === -1) result.push(property);
1270
- }
1271
- __name(addProperty2, "addProperty");
1272
- let proto = Object.getPrototypeOf(object);
1273
- while (proto !== null) {
1274
- Object.getOwnPropertyNames(proto).forEach(addProperty2);
1275
- proto = Object.getPrototypeOf(proto);
1276
- }
1277
- return result;
1278
- }
1279
- __name(getProperties, "getProperties");
1280
- var builtins = [
1281
- "__flags",
1282
- "__methods",
1283
- "_obj",
1284
- "assert"
1285
- ];
1286
- function proxify(obj, nonChainableMethodName) {
1287
- if (!isProxyEnabled()) return obj;
1288
- return new Proxy(obj, { get: /* @__PURE__ */ __name(function proxyGetter(target, property) {
1289
- if (typeof property === "string" && config.proxyExcludedKeys.indexOf(property) === -1 && !Reflect.has(target, property)) {
1290
- if (nonChainableMethodName) throw Error("Invalid Chai property: " + nonChainableMethodName + "." + property + ". See docs for proper usage of \"" + nonChainableMethodName + "\".");
1291
- let suggestion = null;
1292
- let suggestionDistance = 4;
1293
- getProperties(target).forEach(function(prop) {
1294
- if (!Object.prototype.hasOwnProperty(prop) && builtins.indexOf(prop) === -1) {
1295
- let dist = stringDistanceCapped(property, prop, suggestionDistance);
1296
- if (dist < suggestionDistance) {
1297
- suggestion = prop;
1298
- suggestionDistance = dist;
1299
- }
1300
- }
1301
- });
1302
- if (suggestion !== null) throw Error("Invalid Chai property: " + property + ". Did you mean \"" + suggestion + "\"?");
1303
- else throw Error("Invalid Chai property: " + property);
1304
- }
1305
- if (builtins.indexOf(property) === -1 && !flag(target, "lockSsfi")) flag(target, "ssfi", proxyGetter);
1306
- return Reflect.get(target, property);
1307
- }, "proxyGetter") });
1308
- }
1309
- __name(proxify, "proxify");
1310
- function stringDistanceCapped(strA, strB, cap) {
1311
- if (Math.abs(strA.length - strB.length) >= cap) return cap;
1312
- let memo = [];
1313
- for (let i = 0; i <= strA.length; i++) {
1314
- memo[i] = Array(strB.length + 1).fill(0);
1315
- memo[i][0] = i;
1316
- }
1317
- for (let j = 0; j < strB.length; j++) memo[0][j] = j;
1318
- for (let i = 1; i <= strA.length; i++) {
1319
- let ch = strA.charCodeAt(i - 1);
1320
- for (let j = 1; j <= strB.length; j++) {
1321
- if (Math.abs(i - j) >= cap) {
1322
- memo[i][j] = cap;
1323
- continue;
1324
- }
1325
- memo[i][j] = Math.min(memo[i - 1][j] + 1, memo[i][j - 1] + 1, memo[i - 1][j - 1] + (ch === strB.charCodeAt(j - 1) ? 0 : 1));
1326
- }
1327
- }
1328
- return memo[strA.length][strB.length];
1329
- }
1330
- __name(stringDistanceCapped, "stringDistanceCapped");
1331
- function addMethod(ctx, name, method) {
1332
- let methodWrapper = /* @__PURE__ */ __name(function() {
1333
- if (!flag(this, "lockSsfi")) flag(this, "ssfi", methodWrapper);
1334
- let result = method.apply(this, arguments);
1335
- if (result !== void 0) return result;
1336
- let newAssertion = new Assertion();
1337
- transferFlags(this, newAssertion);
1338
- return newAssertion;
1339
- }, "methodWrapper");
1340
- addLengthGuard(methodWrapper, name, false);
1341
- ctx[name] = proxify(methodWrapper, name);
1342
- events.dispatchEvent(new PluginEvent("addMethod", name, method));
1343
- }
1344
- __name(addMethod, "addMethod");
1345
- function overwriteProperty(ctx, name, getter) {
1346
- let _get = Object.getOwnPropertyDescriptor(ctx, name), _super = /* @__PURE__ */ __name(function() {}, "_super");
1347
- if (_get && "function" === typeof _get.get) _super = _get.get;
1348
- Object.defineProperty(ctx, name, {
1349
- get: /* @__PURE__ */ __name(function overwritingPropertyGetter() {
1350
- if (!isProxyEnabled() && !flag(this, "lockSsfi")) flag(this, "ssfi", overwritingPropertyGetter);
1351
- let origLockSsfi = flag(this, "lockSsfi");
1352
- flag(this, "lockSsfi", true);
1353
- let result = getter(_super).call(this);
1354
- flag(this, "lockSsfi", origLockSsfi);
1355
- if (result !== void 0) return result;
1356
- let newAssertion = new Assertion();
1357
- transferFlags(this, newAssertion);
1358
- return newAssertion;
1359
- }, "overwritingPropertyGetter"),
1360
- configurable: true
1361
- });
1362
- }
1363
- __name(overwriteProperty, "overwriteProperty");
1364
- function overwriteMethod(ctx, name, method) {
1365
- let _method = ctx[name], _super = /* @__PURE__ */ __name(function() {
1366
- throw new Error(name + " is not a function");
1367
- }, "_super");
1368
- if (_method && "function" === typeof _method) _super = _method;
1369
- let overwritingMethodWrapper = /* @__PURE__ */ __name(function() {
1370
- if (!flag(this, "lockSsfi")) flag(this, "ssfi", overwritingMethodWrapper);
1371
- let origLockSsfi = flag(this, "lockSsfi");
1372
- flag(this, "lockSsfi", true);
1373
- let result = method(_super).apply(this, arguments);
1374
- flag(this, "lockSsfi", origLockSsfi);
1375
- if (result !== void 0) return result;
1376
- let newAssertion = new Assertion();
1377
- transferFlags(this, newAssertion);
1378
- return newAssertion;
1379
- }, "overwritingMethodWrapper");
1380
- addLengthGuard(overwritingMethodWrapper, name, false);
1381
- ctx[name] = proxify(overwritingMethodWrapper, name);
1382
- }
1383
- __name(overwriteMethod, "overwriteMethod");
1384
- var canSetPrototype = typeof Object.setPrototypeOf === "function";
1385
- var testFn = /* @__PURE__ */ __name(function() {}, "testFn");
1386
- var excludeNames = Object.getOwnPropertyNames(testFn).filter(function(name) {
1387
- let propDesc = Object.getOwnPropertyDescriptor(testFn, name);
1388
- if (typeof propDesc !== "object") return true;
1389
- return !propDesc.configurable;
1390
- });
1391
- var call = Function.prototype.call;
1392
- var apply = Function.prototype.apply;
1393
- var _PluginAddChainableMethodEvent = class _PluginAddChainableMethodEvent extends PluginEvent {
1394
- constructor(type3, name, fn, chainingBehavior) {
1395
- super(type3, name, fn);
1396
- this.chainingBehavior = chainingBehavior;
1397
- }
1398
- };
1399
- __name(_PluginAddChainableMethodEvent, "PluginAddChainableMethodEvent");
1400
- var PluginAddChainableMethodEvent = _PluginAddChainableMethodEvent;
1401
- function addChainableMethod(ctx, name, method, chainingBehavior) {
1402
- if (typeof chainingBehavior !== "function") chainingBehavior = /* @__PURE__ */ __name(function() {}, "chainingBehavior");
1403
- let chainableBehavior = {
1404
- method,
1405
- chainingBehavior
1406
- };
1407
- if (!ctx.__methods) ctx.__methods = {};
1408
- ctx.__methods[name] = chainableBehavior;
1409
- Object.defineProperty(ctx, name, {
1410
- get: /* @__PURE__ */ __name(function chainableMethodGetter() {
1411
- chainableBehavior.chainingBehavior.call(this);
1412
- let chainableMethodWrapper = /* @__PURE__ */ __name(function() {
1413
- if (!flag(this, "lockSsfi")) flag(this, "ssfi", chainableMethodWrapper);
1414
- let result = chainableBehavior.method.apply(this, arguments);
1415
- if (result !== void 0) return result;
1416
- let newAssertion = new Assertion();
1417
- transferFlags(this, newAssertion);
1418
- return newAssertion;
1419
- }, "chainableMethodWrapper");
1420
- addLengthGuard(chainableMethodWrapper, name, true);
1421
- if (canSetPrototype) {
1422
- let prototype = Object.create(this);
1423
- prototype.call = call;
1424
- prototype.apply = apply;
1425
- Object.setPrototypeOf(chainableMethodWrapper, prototype);
1426
- } else Object.getOwnPropertyNames(ctx).forEach(function(asserterName) {
1427
- if (excludeNames.indexOf(asserterName) !== -1) return;
1428
- Object.defineProperty(chainableMethodWrapper, asserterName, Object.getOwnPropertyDescriptor(ctx, asserterName));
1429
- });
1430
- transferFlags(this, chainableMethodWrapper);
1431
- return proxify(chainableMethodWrapper);
1432
- }, "chainableMethodGetter"),
1433
- configurable: true
1434
- });
1435
- events.dispatchEvent(new PluginAddChainableMethodEvent("addChainableMethod", name, method, chainingBehavior));
1436
- }
1437
- __name(addChainableMethod, "addChainableMethod");
1438
- function overwriteChainableMethod(ctx, name, method, chainingBehavior) {
1439
- let chainableBehavior = ctx.__methods[name];
1440
- let _chainingBehavior = chainableBehavior.chainingBehavior;
1441
- chainableBehavior.chainingBehavior = /* @__PURE__ */ __name(function overwritingChainableMethodGetter() {
1442
- let result = chainingBehavior(_chainingBehavior).call(this);
1443
- if (result !== void 0) return result;
1444
- let newAssertion = new Assertion();
1445
- transferFlags(this, newAssertion);
1446
- return newAssertion;
1447
- }, "overwritingChainableMethodGetter");
1448
- let _method = chainableBehavior.method;
1449
- chainableBehavior.method = /* @__PURE__ */ __name(function overwritingChainableMethodWrapper() {
1450
- let result = method(_method).apply(this, arguments);
1451
- if (result !== void 0) return result;
1452
- let newAssertion = new Assertion();
1453
- transferFlags(this, newAssertion);
1454
- return newAssertion;
1455
- }, "overwritingChainableMethodWrapper");
1456
- }
1457
- __name(overwriteChainableMethod, "overwriteChainableMethod");
1458
- function compareByInspect(a, b) {
1459
- return inspect2(a) < inspect2(b) ? -1 : 1;
1460
- }
1461
- __name(compareByInspect, "compareByInspect");
1462
- function getOwnEnumerablePropertySymbols(obj) {
1463
- if (typeof Object.getOwnPropertySymbols !== "function") return [];
1464
- return Object.getOwnPropertySymbols(obj).filter(function(sym) {
1465
- return Object.getOwnPropertyDescriptor(obj, sym).enumerable;
1466
- });
1467
- }
1468
- __name(getOwnEnumerablePropertySymbols, "getOwnEnumerablePropertySymbols");
1469
- function getOwnEnumerableProperties(obj) {
1470
- return Object.keys(obj).concat(getOwnEnumerablePropertySymbols(obj));
1471
- }
1472
- __name(getOwnEnumerableProperties, "getOwnEnumerableProperties");
1473
- var isNaN2 = Number.isNaN;
1474
- function isObjectType(obj) {
1475
- let objectType = type(obj);
1476
- return [
1477
- "Array",
1478
- "Object",
1479
- "Function"
1480
- ].indexOf(objectType) !== -1;
1481
- }
1482
- __name(isObjectType, "isObjectType");
1483
- function getOperator(obj, args) {
1484
- let operator = flag(obj, "operator");
1485
- let negate = flag(obj, "negate");
1486
- let expected = args[3];
1487
- let msg = negate ? args[2] : args[1];
1488
- if (operator) return operator;
1489
- if (typeof msg === "function") msg = msg();
1490
- msg = msg || "";
1491
- if (!msg) return;
1492
- if (/\shave\s/.test(msg)) return;
1493
- let isObject = isObjectType(expected);
1494
- if (/\snot\s/.test(msg)) return isObject ? "notDeepStrictEqual" : "notStrictEqual";
1495
- return isObject ? "deepStrictEqual" : "strictEqual";
1496
- }
1497
- __name(getOperator, "getOperator");
1498
- function getName(fn) {
1499
- return fn.name;
1500
- }
1501
- __name(getName, "getName");
1502
- function isRegExp2(obj) {
1503
- return Object.prototype.toString.call(obj) === "[object RegExp]";
1504
- }
1505
- __name(isRegExp2, "isRegExp");
1506
- function isNumeric(obj) {
1507
- return ["Number", "BigInt"].includes(type(obj));
1508
- }
1509
- __name(isNumeric, "isNumeric");
1510
- var { flag: flag2 } = utils_exports;
1511
- [
1512
- "to",
1513
- "be",
1514
- "been",
1515
- "is",
1516
- "and",
1517
- "has",
1518
- "have",
1519
- "with",
1520
- "that",
1521
- "which",
1522
- "at",
1523
- "of",
1524
- "same",
1525
- "but",
1526
- "does",
1527
- "still",
1528
- "also"
1529
- ].forEach(function(chain) {
1530
- Assertion.addProperty(chain);
1531
- });
1532
- Assertion.addProperty("not", function() {
1533
- flag2(this, "negate", true);
1534
- });
1535
- Assertion.addProperty("deep", function() {
1536
- flag2(this, "deep", true);
1537
- });
1538
- Assertion.addProperty("nested", function() {
1539
- flag2(this, "nested", true);
1540
- });
1541
- Assertion.addProperty("own", function() {
1542
- flag2(this, "own", true);
1543
- });
1544
- Assertion.addProperty("ordered", function() {
1545
- flag2(this, "ordered", true);
1546
- });
1547
- Assertion.addProperty("any", function() {
1548
- flag2(this, "any", true);
1549
- flag2(this, "all", false);
1550
- });
1551
- Assertion.addProperty("all", function() {
1552
- flag2(this, "all", true);
1553
- flag2(this, "any", false);
1554
- });
1555
- var functionTypes = {
1556
- function: [
1557
- "function",
1558
- "asyncfunction",
1559
- "generatorfunction",
1560
- "asyncgeneratorfunction"
1561
- ],
1562
- asyncfunction: ["asyncfunction", "asyncgeneratorfunction"],
1563
- generatorfunction: ["generatorfunction", "asyncgeneratorfunction"],
1564
- asyncgeneratorfunction: ["asyncgeneratorfunction"]
1565
- };
1566
- function an(type3, msg) {
1567
- if (msg) flag2(this, "message", msg);
1568
- type3 = type3.toLowerCase();
1569
- let obj = flag2(this, "object"), article = ~[
1570
- "a",
1571
- "e",
1572
- "i",
1573
- "o",
1574
- "u"
1575
- ].indexOf(type3.charAt(0)) ? "an " : "a ";
1576
- const detectedType = type(obj).toLowerCase();
1577
- if (functionTypes["function"].includes(type3)) this.assert(functionTypes[type3].includes(detectedType), "expected #{this} to be " + article + type3, "expected #{this} not to be " + article + type3);
1578
- else this.assert(type3 === detectedType, "expected #{this} to be " + article + type3, "expected #{this} not to be " + article + type3);
1579
- }
1580
- __name(an, "an");
1581
- Assertion.addChainableMethod("an", an);
1582
- Assertion.addChainableMethod("a", an);
1583
- function SameValueZero(a, b) {
1584
- return isNaN2(a) && isNaN2(b) || a === b;
1585
- }
1586
- __name(SameValueZero, "SameValueZero");
1587
- function includeChainingBehavior() {
1588
- flag2(this, "contains", true);
1589
- }
1590
- __name(includeChainingBehavior, "includeChainingBehavior");
1591
- function include(val, msg) {
1592
- if (msg) flag2(this, "message", msg);
1593
- let obj = flag2(this, "object"), objType = type(obj).toLowerCase(), flagMsg = flag2(this, "message"), negate = flag2(this, "negate"), ssfi = flag2(this, "ssfi"), isDeep = flag2(this, "deep"), descriptor = isDeep ? "deep " : "", isEql = isDeep ? flag2(this, "eql") : SameValueZero;
1594
- flagMsg = flagMsg ? flagMsg + ": " : "";
1595
- let included = false;
1596
- switch (objType) {
1597
- case "string":
1598
- included = obj.indexOf(val) !== -1;
1599
- break;
1600
- case "weakset":
1601
- if (isDeep) throw new AssertionError(flagMsg + "unable to use .deep.include with WeakSet", void 0, ssfi);
1602
- included = obj.has(val);
1603
- break;
1604
- case "map":
1605
- obj.forEach(function(item) {
1606
- included = included || isEql(item, val);
1607
- });
1608
- break;
1609
- case "set":
1610
- if (isDeep) obj.forEach(function(item) {
1611
- included = included || isEql(item, val);
1612
- });
1613
- else included = obj.has(val);
1614
- break;
1615
- case "array":
1616
- if (isDeep) included = obj.some(function(item) {
1617
- return isEql(item, val);
1618
- });
1619
- else included = obj.indexOf(val) !== -1;
1620
- break;
1621
- default: {
1622
- if (val !== Object(val)) throw new AssertionError(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(), void 0, ssfi);
1623
- let props = Object.keys(val);
1624
- let firstErr = null;
1625
- let numErrs = 0;
1626
- props.forEach(function(prop) {
1627
- let propAssertion = new Assertion(obj);
1628
- transferFlags(this, propAssertion, true);
1629
- flag2(propAssertion, "lockSsfi", true);
1630
- if (!negate || props.length === 1) {
1631
- propAssertion.property(prop, val[prop]);
1632
- return;
1633
- }
1634
- try {
1635
- propAssertion.property(prop, val[prop]);
1636
- } catch (err) {
1637
- if (!check_error_exports.compatibleConstructor(err, AssertionError)) throw err;
1638
- if (firstErr === null) firstErr = err;
1639
- numErrs++;
1640
- }
1641
- }, this);
1642
- if (negate && props.length > 1 && numErrs === props.length) throw firstErr;
1643
- return;
1644
- }
1645
- }
1646
- this.assert(included, "expected #{this} to " + descriptor + "include " + inspect2(val), "expected #{this} to not " + descriptor + "include " + inspect2(val));
1647
- }
1648
- __name(include, "include");
1649
- Assertion.addChainableMethod("include", include, includeChainingBehavior);
1650
- Assertion.addChainableMethod("contain", include, includeChainingBehavior);
1651
- Assertion.addChainableMethod("contains", include, includeChainingBehavior);
1652
- Assertion.addChainableMethod("includes", include, includeChainingBehavior);
1653
- Assertion.addProperty("ok", function() {
1654
- this.assert(flag2(this, "object"), "expected #{this} to be truthy", "expected #{this} to be falsy");
1655
- });
1656
- Assertion.addProperty("true", function() {
1657
- this.assert(true === flag2(this, "object"), "expected #{this} to be true", "expected #{this} to be false", flag2(this, "negate") ? false : true);
1658
- });
1659
- Assertion.addProperty("numeric", function() {
1660
- const object = flag2(this, "object");
1661
- this.assert(["Number", "BigInt"].includes(type(object)), "expected #{this} to be numeric", "expected #{this} to not be numeric", flag2(this, "negate") ? false : true);
1662
- });
1663
- Assertion.addProperty("callable", function() {
1664
- const val = flag2(this, "object");
1665
- const ssfi = flag2(this, "ssfi");
1666
- const message = flag2(this, "message");
1667
- const msg = message ? `${message}: ` : "";
1668
- const negate = flag2(this, "negate");
1669
- const assertionMessage = negate ? `${msg}expected ${inspect2(val)} not to be a callable function` : `${msg}expected ${inspect2(val)} to be a callable function`;
1670
- const isCallable = [
1671
- "Function",
1672
- "AsyncFunction",
1673
- "GeneratorFunction",
1674
- "AsyncGeneratorFunction"
1675
- ].includes(type(val));
1676
- if (isCallable && negate || !isCallable && !negate) throw new AssertionError(assertionMessage, void 0, ssfi);
1677
- });
1678
- Assertion.addProperty("false", function() {
1679
- this.assert(false === flag2(this, "object"), "expected #{this} to be false", "expected #{this} to be true", flag2(this, "negate") ? true : false);
1680
- });
1681
- Assertion.addProperty("null", function() {
1682
- this.assert(null === flag2(this, "object"), "expected #{this} to be null", "expected #{this} not to be null");
1683
- });
1684
- Assertion.addProperty("undefined", function() {
1685
- this.assert(void 0 === flag2(this, "object"), "expected #{this} to be undefined", "expected #{this} not to be undefined");
1686
- });
1687
- Assertion.addProperty("NaN", function() {
1688
- this.assert(isNaN2(flag2(this, "object")), "expected #{this} to be NaN", "expected #{this} not to be NaN");
1689
- });
1690
- function assertExist() {
1691
- let val = flag2(this, "object");
1692
- this.assert(val !== null && val !== void 0, "expected #{this} to exist", "expected #{this} to not exist");
1693
- }
1694
- __name(assertExist, "assertExist");
1695
- Assertion.addProperty("exist", assertExist);
1696
- Assertion.addProperty("exists", assertExist);
1697
- Assertion.addProperty("empty", function() {
1698
- let val = flag2(this, "object"), ssfi = flag2(this, "ssfi"), flagMsg = flag2(this, "message"), itemsCount;
1699
- flagMsg = flagMsg ? flagMsg + ": " : "";
1700
- switch (type(val).toLowerCase()) {
1701
- case "array":
1702
- case "string":
1703
- itemsCount = val.length;
1704
- break;
1705
- case "map":
1706
- case "set":
1707
- itemsCount = val.size;
1708
- break;
1709
- case "weakmap":
1710
- case "weakset": throw new AssertionError(flagMsg + ".empty was passed a weak collection", void 0, ssfi);
1711
- case "function": throw new AssertionError((flagMsg + ".empty was passed a function " + getName(val)).trim(), void 0, ssfi);
1712
- default:
1713
- if (val !== Object(val)) throw new AssertionError(flagMsg + ".empty was passed non-string primitive " + inspect2(val), void 0, ssfi);
1714
- itemsCount = Object.keys(val).length;
1715
- }
1716
- this.assert(0 === itemsCount, "expected #{this} to be empty", "expected #{this} not to be empty");
1717
- });
1718
- function checkArguments() {
1719
- let type3 = type(flag2(this, "object"));
1720
- this.assert("Arguments" === type3, "expected #{this} to be arguments but got " + type3, "expected #{this} to not be arguments");
1721
- }
1722
- __name(checkArguments, "checkArguments");
1723
- Assertion.addProperty("arguments", checkArguments);
1724
- Assertion.addProperty("Arguments", checkArguments);
1725
- function assertEqual(val, msg) {
1726
- if (msg) flag2(this, "message", msg);
1727
- let obj = flag2(this, "object");
1728
- if (flag2(this, "deep")) {
1729
- let prevLockSsfi = flag2(this, "lockSsfi");
1730
- flag2(this, "lockSsfi", true);
1731
- this.eql(val);
1732
- flag2(this, "lockSsfi", prevLockSsfi);
1733
- } else this.assert(val === obj, "expected #{this} to equal #{exp}", "expected #{this} to not equal #{exp}", val, this._obj, true);
1734
- }
1735
- __name(assertEqual, "assertEqual");
1736
- Assertion.addMethod("equal", assertEqual);
1737
- Assertion.addMethod("equals", assertEqual);
1738
- Assertion.addMethod("eq", assertEqual);
1739
- function assertEql(obj, msg) {
1740
- if (msg) flag2(this, "message", msg);
1741
- let eql = flag2(this, "eql");
1742
- this.assert(eql(obj, flag2(this, "object")), "expected #{this} to deeply equal #{exp}", "expected #{this} to not deeply equal #{exp}", obj, this._obj, true);
1743
- }
1744
- __name(assertEql, "assertEql");
1745
- Assertion.addMethod("eql", assertEql);
1746
- Assertion.addMethod("eqls", assertEql);
1747
- function assertAbove(n, msg) {
1748
- if (msg) flag2(this, "message", msg);
1749
- let obj = flag2(this, "object"), doLength = flag2(this, "doLength"), flagMsg = flag2(this, "message"), msgPrefix = flagMsg ? flagMsg + ": " : "", ssfi = flag2(this, "ssfi"), objType = type(obj).toLowerCase(), nType = type(n).toLowerCase();
1750
- if (doLength && objType !== "map" && objType !== "set") new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
1751
- if (!doLength && objType === "date" && nType !== "date") throw new AssertionError(msgPrefix + "the argument to above must be a date", void 0, ssfi);
1752
- else if (!isNumeric(n) && (doLength || isNumeric(obj))) throw new AssertionError(msgPrefix + "the argument to above must be a number", void 0, ssfi);
1753
- else if (!doLength && objType !== "date" && !isNumeric(obj)) {
1754
- let printObj = objType === "string" ? "'" + obj + "'" : obj;
1755
- throw new AssertionError(msgPrefix + "expected " + printObj + " to be a number or a date", void 0, ssfi);
1756
- }
1757
- if (doLength) {
1758
- let descriptor = "length", itemsCount;
1759
- if (objType === "map" || objType === "set") {
1760
- descriptor = "size";
1761
- itemsCount = obj.size;
1762
- } else itemsCount = obj.length;
1763
- this.assert(itemsCount > n, "expected #{this} to have a " + descriptor + " above #{exp} but got #{act}", "expected #{this} to not have a " + descriptor + " above #{exp}", n, itemsCount);
1764
- } else this.assert(obj > n, "expected #{this} to be above #{exp}", "expected #{this} to be at most #{exp}", n);
1765
- }
1766
- __name(assertAbove, "assertAbove");
1767
- Assertion.addMethod("above", assertAbove);
1768
- Assertion.addMethod("gt", assertAbove);
1769
- Assertion.addMethod("greaterThan", assertAbove);
1770
- function assertLeast(n, msg) {
1771
- if (msg) flag2(this, "message", msg);
1772
- let obj = flag2(this, "object"), doLength = flag2(this, "doLength"), flagMsg = flag2(this, "message"), msgPrefix = flagMsg ? flagMsg + ": " : "", ssfi = flag2(this, "ssfi"), objType = type(obj).toLowerCase(), nType = type(n).toLowerCase(), errorMessage, shouldThrow = true;
1773
- if (doLength && objType !== "map" && objType !== "set") new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
1774
- if (!doLength && objType === "date" && nType !== "date") errorMessage = msgPrefix + "the argument to least must be a date";
1775
- else if (!isNumeric(n) && (doLength || isNumeric(obj))) errorMessage = msgPrefix + "the argument to least must be a number";
1776
- else if (!doLength && objType !== "date" && !isNumeric(obj)) {
1777
- let printObj = objType === "string" ? "'" + obj + "'" : obj;
1778
- errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
1779
- } else shouldThrow = false;
1780
- if (shouldThrow) throw new AssertionError(errorMessage, void 0, ssfi);
1781
- if (doLength) {
1782
- let descriptor = "length", itemsCount;
1783
- if (objType === "map" || objType === "set") {
1784
- descriptor = "size";
1785
- itemsCount = obj.size;
1786
- } else itemsCount = obj.length;
1787
- this.assert(itemsCount >= n, "expected #{this} to have a " + descriptor + " at least #{exp} but got #{act}", "expected #{this} to have a " + descriptor + " below #{exp}", n, itemsCount);
1788
- } else this.assert(obj >= n, "expected #{this} to be at least #{exp}", "expected #{this} to be below #{exp}", n);
1789
- }
1790
- __name(assertLeast, "assertLeast");
1791
- Assertion.addMethod("least", assertLeast);
1792
- Assertion.addMethod("gte", assertLeast);
1793
- Assertion.addMethod("greaterThanOrEqual", assertLeast);
1794
- function assertBelow(n, msg) {
1795
- if (msg) flag2(this, "message", msg);
1796
- let obj = flag2(this, "object"), doLength = flag2(this, "doLength"), flagMsg = flag2(this, "message"), msgPrefix = flagMsg ? flagMsg + ": " : "", ssfi = flag2(this, "ssfi"), objType = type(obj).toLowerCase(), nType = type(n).toLowerCase(), errorMessage, shouldThrow = true;
1797
- if (doLength && objType !== "map" && objType !== "set") new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
1798
- if (!doLength && objType === "date" && nType !== "date") errorMessage = msgPrefix + "the argument to below must be a date";
1799
- else if (!isNumeric(n) && (doLength || isNumeric(obj))) errorMessage = msgPrefix + "the argument to below must be a number";
1800
- else if (!doLength && objType !== "date" && !isNumeric(obj)) {
1801
- let printObj = objType === "string" ? "'" + obj + "'" : obj;
1802
- errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
1803
- } else shouldThrow = false;
1804
- if (shouldThrow) throw new AssertionError(errorMessage, void 0, ssfi);
1805
- if (doLength) {
1806
- let descriptor = "length", itemsCount;
1807
- if (objType === "map" || objType === "set") {
1808
- descriptor = "size";
1809
- itemsCount = obj.size;
1810
- } else itemsCount = obj.length;
1811
- this.assert(itemsCount < n, "expected #{this} to have a " + descriptor + " below #{exp} but got #{act}", "expected #{this} to not have a " + descriptor + " below #{exp}", n, itemsCount);
1812
- } else this.assert(obj < n, "expected #{this} to be below #{exp}", "expected #{this} to be at least #{exp}", n);
1813
- }
1814
- __name(assertBelow, "assertBelow");
1815
- Assertion.addMethod("below", assertBelow);
1816
- Assertion.addMethod("lt", assertBelow);
1817
- Assertion.addMethod("lessThan", assertBelow);
1818
- function assertMost(n, msg) {
1819
- if (msg) flag2(this, "message", msg);
1820
- let obj = flag2(this, "object"), doLength = flag2(this, "doLength"), flagMsg = flag2(this, "message"), msgPrefix = flagMsg ? flagMsg + ": " : "", ssfi = flag2(this, "ssfi"), objType = type(obj).toLowerCase(), nType = type(n).toLowerCase(), errorMessage, shouldThrow = true;
1821
- if (doLength && objType !== "map" && objType !== "set") new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
1822
- if (!doLength && objType === "date" && nType !== "date") errorMessage = msgPrefix + "the argument to most must be a date";
1823
- else if (!isNumeric(n) && (doLength || isNumeric(obj))) errorMessage = msgPrefix + "the argument to most must be a number";
1824
- else if (!doLength && objType !== "date" && !isNumeric(obj)) {
1825
- let printObj = objType === "string" ? "'" + obj + "'" : obj;
1826
- errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
1827
- } else shouldThrow = false;
1828
- if (shouldThrow) throw new AssertionError(errorMessage, void 0, ssfi);
1829
- if (doLength) {
1830
- let descriptor = "length", itemsCount;
1831
- if (objType === "map" || objType === "set") {
1832
- descriptor = "size";
1833
- itemsCount = obj.size;
1834
- } else itemsCount = obj.length;
1835
- this.assert(itemsCount <= n, "expected #{this} to have a " + descriptor + " at most #{exp} but got #{act}", "expected #{this} to have a " + descriptor + " above #{exp}", n, itemsCount);
1836
- } else this.assert(obj <= n, "expected #{this} to be at most #{exp}", "expected #{this} to be above #{exp}", n);
1837
- }
1838
- __name(assertMost, "assertMost");
1839
- Assertion.addMethod("most", assertMost);
1840
- Assertion.addMethod("lte", assertMost);
1841
- Assertion.addMethod("lessThanOrEqual", assertMost);
1842
- Assertion.addMethod("within", function(start, finish, msg) {
1843
- if (msg) flag2(this, "message", msg);
1844
- let obj = flag2(this, "object"), doLength = flag2(this, "doLength"), flagMsg = flag2(this, "message"), msgPrefix = flagMsg ? flagMsg + ": " : "", ssfi = flag2(this, "ssfi"), objType = type(obj).toLowerCase(), startType = type(start).toLowerCase(), finishType = type(finish).toLowerCase(), errorMessage, shouldThrow = true, range = startType === "date" && finishType === "date" ? start.toISOString() + ".." + finish.toISOString() : start + ".." + finish;
1845
- if (doLength && objType !== "map" && objType !== "set") new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
1846
- if (!doLength && objType === "date" && (startType !== "date" || finishType !== "date")) errorMessage = msgPrefix + "the arguments to within must be dates";
1847
- else if ((!isNumeric(start) || !isNumeric(finish)) && (doLength || isNumeric(obj))) errorMessage = msgPrefix + "the arguments to within must be numbers";
1848
- else if (!doLength && objType !== "date" && !isNumeric(obj)) {
1849
- let printObj = objType === "string" ? "'" + obj + "'" : obj;
1850
- errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
1851
- } else shouldThrow = false;
1852
- if (shouldThrow) throw new AssertionError(errorMessage, void 0, ssfi);
1853
- if (doLength) {
1854
- let descriptor = "length", itemsCount;
1855
- if (objType === "map" || objType === "set") {
1856
- descriptor = "size";
1857
- itemsCount = obj.size;
1858
- } else itemsCount = obj.length;
1859
- this.assert(itemsCount >= start && itemsCount <= finish, "expected #{this} to have a " + descriptor + " within " + range, "expected #{this} to not have a " + descriptor + " within " + range);
1860
- } else this.assert(obj >= start && obj <= finish, "expected #{this} to be within " + range, "expected #{this} to not be within " + range);
1861
- });
1862
- function assertInstanceOf(constructor, msg) {
1863
- if (msg) flag2(this, "message", msg);
1864
- let target = flag2(this, "object");
1865
- let ssfi = flag2(this, "ssfi");
1866
- let flagMsg = flag2(this, "message");
1867
- let isInstanceOf;
1868
- try {
1869
- isInstanceOf = target instanceof constructor;
1870
- } catch (err) {
1871
- if (err instanceof TypeError) {
1872
- flagMsg = flagMsg ? flagMsg + ": " : "";
1873
- throw new AssertionError(flagMsg + "The instanceof assertion needs a constructor but " + type(constructor) + " was given.", void 0, ssfi);
1874
- }
1875
- throw err;
1876
- }
1877
- let name = getName(constructor);
1878
- if (name == null) name = "an unnamed constructor";
1879
- this.assert(isInstanceOf, "expected #{this} to be an instance of " + name, "expected #{this} to not be an instance of " + name);
1880
- }
1881
- __name(assertInstanceOf, "assertInstanceOf");
1882
- Assertion.addMethod("instanceof", assertInstanceOf);
1883
- Assertion.addMethod("instanceOf", assertInstanceOf);
1884
- function assertProperty(name, val, msg) {
1885
- if (msg) flag2(this, "message", msg);
1886
- let isNested = flag2(this, "nested"), isOwn = flag2(this, "own"), flagMsg = flag2(this, "message"), obj = flag2(this, "object"), ssfi = flag2(this, "ssfi"), nameType = typeof name;
1887
- flagMsg = flagMsg ? flagMsg + ": " : "";
1888
- if (isNested) {
1889
- if (nameType !== "string") throw new AssertionError(flagMsg + "the argument to property must be a string when using nested syntax", void 0, ssfi);
1890
- } else if (nameType !== "string" && nameType !== "number" && nameType !== "symbol") throw new AssertionError(flagMsg + "the argument to property must be a string, number, or symbol", void 0, ssfi);
1891
- if (isNested && isOwn) throw new AssertionError(flagMsg + "The \"nested\" and \"own\" flags cannot be combined.", void 0, ssfi);
1892
- if (obj === null || obj === void 0) throw new AssertionError(flagMsg + "Target cannot be null or undefined.", void 0, ssfi);
1893
- let isDeep = flag2(this, "deep"), negate = flag2(this, "negate"), pathInfo = isNested ? getPathInfo(obj, name) : null, value = isNested ? pathInfo.value : obj[name], isEql = isDeep ? flag2(this, "eql") : (val1, val2) => val1 === val2;
1894
- let descriptor = "";
1895
- if (isDeep) descriptor += "deep ";
1896
- if (isOwn) descriptor += "own ";
1897
- if (isNested) descriptor += "nested ";
1898
- descriptor += "property ";
1899
- let hasProperty2;
1900
- if (isOwn) hasProperty2 = Object.prototype.hasOwnProperty.call(obj, name);
1901
- else if (isNested) hasProperty2 = pathInfo.exists;
1902
- else hasProperty2 = hasProperty(obj, name);
1903
- if (!negate || arguments.length === 1) this.assert(hasProperty2, "expected #{this} to have " + descriptor + inspect2(name), "expected #{this} to not have " + descriptor + inspect2(name));
1904
- if (arguments.length > 1) this.assert(hasProperty2 && isEql(val, value), "expected #{this} to have " + descriptor + inspect2(name) + " of #{exp}, but got #{act}", "expected #{this} to not have " + descriptor + inspect2(name) + " of #{act}", val, value);
1905
- flag2(this, "object", value);
1906
- }
1907
- __name(assertProperty, "assertProperty");
1908
- Assertion.addMethod("property", assertProperty);
1909
- function assertOwnProperty(_name, _value, _msg) {
1910
- flag2(this, "own", true);
1911
- assertProperty.apply(this, arguments);
1912
- }
1913
- __name(assertOwnProperty, "assertOwnProperty");
1914
- Assertion.addMethod("ownProperty", assertOwnProperty);
1915
- Assertion.addMethod("haveOwnProperty", assertOwnProperty);
1916
- function assertOwnPropertyDescriptor(name, descriptor, msg) {
1917
- if (typeof descriptor === "string") {
1918
- msg = descriptor;
1919
- descriptor = null;
1920
- }
1921
- if (msg) flag2(this, "message", msg);
1922
- let obj = flag2(this, "object");
1923
- let actualDescriptor = Object.getOwnPropertyDescriptor(Object(obj), name);
1924
- let eql = flag2(this, "eql");
1925
- if (actualDescriptor && descriptor) this.assert(eql(descriptor, actualDescriptor), "expected the own property descriptor for " + inspect2(name) + " on #{this} to match " + inspect2(descriptor) + ", got " + inspect2(actualDescriptor), "expected the own property descriptor for " + inspect2(name) + " on #{this} to not match " + inspect2(descriptor), descriptor, actualDescriptor, true);
1926
- else this.assert(actualDescriptor, "expected #{this} to have an own property descriptor for " + inspect2(name), "expected #{this} to not have an own property descriptor for " + inspect2(name));
1927
- flag2(this, "object", actualDescriptor);
1928
- }
1929
- __name(assertOwnPropertyDescriptor, "assertOwnPropertyDescriptor");
1930
- Assertion.addMethod("ownPropertyDescriptor", assertOwnPropertyDescriptor);
1931
- Assertion.addMethod("haveOwnPropertyDescriptor", assertOwnPropertyDescriptor);
1932
- function assertLengthChain() {
1933
- flag2(this, "doLength", true);
1934
- }
1935
- __name(assertLengthChain, "assertLengthChain");
1936
- function assertLength(n, msg) {
1937
- if (msg) flag2(this, "message", msg);
1938
- let obj = flag2(this, "object"), objType = type(obj).toLowerCase(), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi"), descriptor = "length", itemsCount;
1939
- switch (objType) {
1940
- case "map":
1941
- case "set":
1942
- descriptor = "size";
1943
- itemsCount = obj.size;
1944
- break;
1945
- default:
1946
- new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
1947
- itemsCount = obj.length;
1948
- }
1949
- this.assert(itemsCount == n, "expected #{this} to have a " + descriptor + " of #{exp} but got #{act}", "expected #{this} to not have a " + descriptor + " of #{act}", n, itemsCount);
1950
- }
1951
- __name(assertLength, "assertLength");
1952
- Assertion.addChainableMethod("length", assertLength, assertLengthChain);
1953
- Assertion.addChainableMethod("lengthOf", assertLength, assertLengthChain);
1954
- function assertMatch(re, msg) {
1955
- if (msg) flag2(this, "message", msg);
1956
- let obj = flag2(this, "object");
1957
- this.assert(re.exec(obj), "expected #{this} to match " + re, "expected #{this} not to match " + re);
1958
- }
1959
- __name(assertMatch, "assertMatch");
1960
- Assertion.addMethod("match", assertMatch);
1961
- Assertion.addMethod("matches", assertMatch);
1962
- Assertion.addMethod("string", function(str, msg) {
1963
- if (msg) flag2(this, "message", msg);
1964
- let obj = flag2(this, "object");
1965
- new Assertion(obj, flag2(this, "message"), flag2(this, "ssfi"), true).is.a("string");
1966
- this.assert(~obj.indexOf(str), "expected #{this} to contain " + inspect2(str), "expected #{this} to not contain " + inspect2(str));
1967
- });
1968
- function assertKeys(keys) {
1969
- let obj = flag2(this, "object"), objType = type(obj), keysType = type(keys), ssfi = flag2(this, "ssfi"), isDeep = flag2(this, "deep"), str, deepStr = "", actual, ok = true, flagMsg = flag2(this, "message");
1970
- flagMsg = flagMsg ? flagMsg + ": " : "";
1971
- let mixedArgsMsg = flagMsg + "when testing keys against an object or an array you must give a single Array|Object|String argument or multiple String arguments";
1972
- if (objType === "Map" || objType === "Set") {
1973
- deepStr = isDeep ? "deeply " : "";
1974
- actual = [];
1975
- obj.forEach(function(val, key) {
1976
- actual.push(key);
1977
- });
1978
- if (keysType !== "Array") keys = Array.prototype.slice.call(arguments);
1979
- } else {
1980
- actual = getOwnEnumerableProperties(obj);
1981
- switch (keysType) {
1982
- case "Array":
1983
- if (arguments.length > 1) throw new AssertionError(mixedArgsMsg, void 0, ssfi);
1984
- break;
1985
- case "Object":
1986
- if (arguments.length > 1) throw new AssertionError(mixedArgsMsg, void 0, ssfi);
1987
- keys = Object.keys(keys);
1988
- break;
1989
- default: keys = Array.prototype.slice.call(arguments);
1990
- }
1991
- keys = keys.map(function(val) {
1992
- return typeof val === "symbol" ? val : String(val);
1993
- });
1994
- }
1995
- if (!keys.length) throw new AssertionError(flagMsg + "keys required", void 0, ssfi);
1996
- let len = keys.length, any = flag2(this, "any"), all = flag2(this, "all"), expected = keys, isEql = isDeep ? flag2(this, "eql") : (val1, val2) => val1 === val2;
1997
- if (!any && !all) all = true;
1998
- if (any) ok = expected.some(function(expectedKey) {
1999
- return actual.some(function(actualKey) {
2000
- return isEql(expectedKey, actualKey);
2001
- });
2002
- });
2003
- if (all) {
2004
- ok = expected.every(function(expectedKey) {
2005
- return actual.some(function(actualKey) {
2006
- return isEql(expectedKey, actualKey);
2007
- });
2008
- });
2009
- if (!flag2(this, "contains")) ok = ok && keys.length == actual.length;
2010
- }
2011
- if (len > 1) {
2012
- keys = keys.map(function(key) {
2013
- return inspect2(key);
2014
- });
2015
- let last = keys.pop();
2016
- if (all) str = keys.join(", ") + ", and " + last;
2017
- if (any) str = keys.join(", ") + ", or " + last;
2018
- } else str = inspect2(keys[0]);
2019
- str = (len > 1 ? "keys " : "key ") + str;
2020
- str = (flag2(this, "contains") ? "contain " : "have ") + str;
2021
- this.assert(ok, "expected #{this} to " + deepStr + str, "expected #{this} to not " + deepStr + str, expected.slice(0).sort(compareByInspect), actual.sort(compareByInspect), true);
2022
- }
2023
- __name(assertKeys, "assertKeys");
2024
- Assertion.addMethod("keys", assertKeys);
2025
- Assertion.addMethod("key", assertKeys);
2026
- function assertThrows(errorLike, errMsgMatcher, msg) {
2027
- if (msg) flag2(this, "message", msg);
2028
- let obj = flag2(this, "object"), ssfi = flag2(this, "ssfi"), flagMsg = flag2(this, "message"), negate = flag2(this, "negate") || false;
2029
- new Assertion(obj, flagMsg, ssfi, true).is.a("function");
2030
- if (isRegExp2(errorLike) || typeof errorLike === "string") {
2031
- errMsgMatcher = errorLike;
2032
- errorLike = null;
2033
- }
2034
- let caughtErr;
2035
- let errorWasThrown = false;
2036
- try {
2037
- obj();
2038
- } catch (err) {
2039
- errorWasThrown = true;
2040
- caughtErr = err;
2041
- }
2042
- let everyArgIsUndefined = errorLike === void 0 && errMsgMatcher === void 0;
2043
- let everyArgIsDefined = Boolean(errorLike && errMsgMatcher);
2044
- let errorLikeFail = false;
2045
- let errMsgMatcherFail = false;
2046
- if (everyArgIsUndefined || !everyArgIsUndefined && !negate) {
2047
- let errorLikeString = "an error";
2048
- if (errorLike instanceof Error) errorLikeString = "#{exp}";
2049
- else if (errorLike) errorLikeString = check_error_exports.getConstructorName(errorLike);
2050
- let actual = caughtErr;
2051
- if (caughtErr instanceof Error) actual = caughtErr.toString();
2052
- else if (typeof caughtErr === "string") actual = caughtErr;
2053
- else if (caughtErr && (typeof caughtErr === "object" || typeof caughtErr === "function")) try {
2054
- actual = check_error_exports.getConstructorName(caughtErr);
2055
- } catch (_err) {}
2056
- this.assert(errorWasThrown, "expected #{this} to throw " + errorLikeString, "expected #{this} to not throw an error but #{act} was thrown", errorLike && errorLike.toString(), actual);
2057
- }
2058
- if (errorLike && caughtErr) {
2059
- if (errorLike instanceof Error) {
2060
- if (check_error_exports.compatibleInstance(caughtErr, errorLike) === negate) if (everyArgIsDefined && negate) errorLikeFail = true;
2061
- else this.assert(negate, "expected #{this} to throw #{exp} but #{act} was thrown", "expected #{this} to not throw #{exp}" + (caughtErr && !negate ? " but #{act} was thrown" : ""), errorLike.toString(), caughtErr.toString());
2062
- }
2063
- if (check_error_exports.compatibleConstructor(caughtErr, errorLike) === negate) if (everyArgIsDefined && negate) errorLikeFail = true;
2064
- else this.assert(negate, "expected #{this} to throw #{exp} but #{act} was thrown", "expected #{this} to not throw #{exp}" + (caughtErr ? " but #{act} was thrown" : ""), errorLike instanceof Error ? errorLike.toString() : errorLike && check_error_exports.getConstructorName(errorLike), caughtErr instanceof Error ? caughtErr.toString() : caughtErr && check_error_exports.getConstructorName(caughtErr));
2065
- }
2066
- if (caughtErr && errMsgMatcher !== void 0 && errMsgMatcher !== null) {
2067
- let placeholder = "including";
2068
- if (isRegExp2(errMsgMatcher)) placeholder = "matching";
2069
- if (check_error_exports.compatibleMessage(caughtErr, errMsgMatcher) === negate) if (everyArgIsDefined && negate) errMsgMatcherFail = true;
2070
- else this.assert(negate, "expected #{this} to throw error " + placeholder + " #{exp} but got #{act}", "expected #{this} to throw error not " + placeholder + " #{exp}", errMsgMatcher, check_error_exports.getMessage(caughtErr));
2071
- }
2072
- if (errorLikeFail && errMsgMatcherFail) this.assert(negate, "expected #{this} to throw #{exp} but #{act} was thrown", "expected #{this} to not throw #{exp}" + (caughtErr ? " but #{act} was thrown" : ""), errorLike instanceof Error ? errorLike.toString() : errorLike && check_error_exports.getConstructorName(errorLike), caughtErr instanceof Error ? caughtErr.toString() : caughtErr && check_error_exports.getConstructorName(caughtErr));
2073
- flag2(this, "object", caughtErr);
2074
- }
2075
- __name(assertThrows, "assertThrows");
2076
- Assertion.addMethod("throw", assertThrows);
2077
- Assertion.addMethod("throws", assertThrows);
2078
- Assertion.addMethod("Throw", assertThrows);
2079
- function respondTo(method, msg) {
2080
- if (msg) flag2(this, "message", msg);
2081
- let obj = flag2(this, "object"), itself = flag2(this, "itself"), context = "function" === typeof obj && !itself ? obj.prototype[method] : obj[method];
2082
- this.assert("function" === typeof context, "expected #{this} to respond to " + inspect2(method), "expected #{this} to not respond to " + inspect2(method));
2083
- }
2084
- __name(respondTo, "respondTo");
2085
- Assertion.addMethod("respondTo", respondTo);
2086
- Assertion.addMethod("respondsTo", respondTo);
2087
- Assertion.addProperty("itself", function() {
2088
- flag2(this, "itself", true);
2089
- });
2090
- function satisfy(matcher, msg) {
2091
- if (msg) flag2(this, "message", msg);
2092
- let result = matcher(flag2(this, "object"));
2093
- this.assert(result, "expected #{this} to satisfy " + objDisplay(matcher), "expected #{this} to not satisfy" + objDisplay(matcher), flag2(this, "negate") ? false : true, result);
2094
- }
2095
- __name(satisfy, "satisfy");
2096
- Assertion.addMethod("satisfy", satisfy);
2097
- Assertion.addMethod("satisfies", satisfy);
2098
- function closeTo(expected, delta, msg) {
2099
- if (msg) flag2(this, "message", msg);
2100
- let obj = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
2101
- new Assertion(obj, flagMsg, ssfi, true).is.numeric;
2102
- let message = "A `delta` value is required for `closeTo`";
2103
- if (delta == void 0) throw new AssertionError(flagMsg ? `${flagMsg}: ${message}` : message, void 0, ssfi);
2104
- new Assertion(delta, flagMsg, ssfi, true).is.numeric;
2105
- message = "A `expected` value is required for `closeTo`";
2106
- if (expected == void 0) throw new AssertionError(flagMsg ? `${flagMsg}: ${message}` : message, void 0, ssfi);
2107
- new Assertion(expected, flagMsg, ssfi, true).is.numeric;
2108
- const abs = /* @__PURE__ */ __name((x) => x < 0 ? -x : x, "abs");
2109
- const strip = /* @__PURE__ */ __name((number) => parseFloat(parseFloat(number).toPrecision(12)), "strip");
2110
- this.assert(strip(abs(obj - expected)) <= delta, "expected #{this} to be close to " + expected + " +/- " + delta, "expected #{this} not to be close to " + expected + " +/- " + delta);
2111
- }
2112
- __name(closeTo, "closeTo");
2113
- Assertion.addMethod("closeTo", closeTo);
2114
- Assertion.addMethod("approximately", closeTo);
2115
- function isSubsetOf(_subset, _superset, cmp, contains, ordered) {
2116
- let superset = Array.from(_superset);
2117
- let subset = Array.from(_subset);
2118
- if (!contains) {
2119
- if (subset.length !== superset.length) return false;
2120
- superset = superset.slice();
2121
- }
2122
- return subset.every(function(elem, idx) {
2123
- if (ordered) return cmp ? cmp(elem, superset[idx]) : elem === superset[idx];
2124
- if (!cmp) {
2125
- let matchIdx = superset.indexOf(elem);
2126
- if (matchIdx === -1) return false;
2127
- if (!contains) superset.splice(matchIdx, 1);
2128
- return true;
2129
- }
2130
- return superset.some(function(elem2, matchIdx) {
2131
- if (!cmp(elem, elem2)) return false;
2132
- if (!contains) superset.splice(matchIdx, 1);
2133
- return true;
2134
- });
2135
- });
2136
- }
2137
- __name(isSubsetOf, "isSubsetOf");
2138
- Assertion.addMethod("members", function(subset, msg) {
2139
- if (msg) flag2(this, "message", msg);
2140
- let obj = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
2141
- new Assertion(obj, flagMsg, ssfi, true).to.be.iterable;
2142
- new Assertion(subset, flagMsg, ssfi, true).to.be.iterable;
2143
- let contains = flag2(this, "contains");
2144
- let ordered = flag2(this, "ordered");
2145
- let subject, failMsg, failNegateMsg;
2146
- if (contains) {
2147
- subject = ordered ? "an ordered superset" : "a superset";
2148
- failMsg = "expected #{this} to be " + subject + " of #{exp}";
2149
- failNegateMsg = "expected #{this} to not be " + subject + " of #{exp}";
2150
- } else {
2151
- subject = ordered ? "ordered members" : "members";
2152
- failMsg = "expected #{this} to have the same " + subject + " as #{exp}";
2153
- failNegateMsg = "expected #{this} to not have the same " + subject + " as #{exp}";
2154
- }
2155
- let cmp = flag2(this, "deep") ? flag2(this, "eql") : void 0;
2156
- this.assert(isSubsetOf(subset, obj, cmp, contains, ordered), failMsg, failNegateMsg, subset, obj, true);
2157
- });
2158
- Assertion.addProperty("iterable", function(msg) {
2159
- if (msg) flag2(this, "message", msg);
2160
- let obj = flag2(this, "object");
2161
- this.assert(obj != void 0 && obj[Symbol.iterator], "expected #{this} to be an iterable", "expected #{this} to not be an iterable", obj);
2162
- });
2163
- function oneOf(list, msg) {
2164
- if (msg) flag2(this, "message", msg);
2165
- let expected = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi"), contains = flag2(this, "contains"), isDeep = flag2(this, "deep"), eql = flag2(this, "eql");
2166
- new Assertion(list, flagMsg, ssfi, true).to.be.an("array");
2167
- if (contains) this.assert(list.some(function(possibility) {
2168
- return expected.indexOf(possibility) > -1;
2169
- }), "expected #{this} to contain one of #{exp}", "expected #{this} to not contain one of #{exp}", list, expected);
2170
- else if (isDeep) this.assert(list.some(function(possibility) {
2171
- return eql(expected, possibility);
2172
- }), "expected #{this} to deeply equal one of #{exp}", "expected #{this} to deeply equal one of #{exp}", list, expected);
2173
- else this.assert(list.indexOf(expected) > -1, "expected #{this} to be one of #{exp}", "expected #{this} to not be one of #{exp}", list, expected);
2174
- }
2175
- __name(oneOf, "oneOf");
2176
- Assertion.addMethod("oneOf", oneOf);
2177
- function assertChanges(subject, prop, msg) {
2178
- if (msg) flag2(this, "message", msg);
2179
- let fn = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
2180
- new Assertion(fn, flagMsg, ssfi, true).is.a("function");
2181
- let initial;
2182
- if (!prop) {
2183
- new Assertion(subject, flagMsg, ssfi, true).is.a("function");
2184
- initial = subject();
2185
- } else {
2186
- new Assertion(subject, flagMsg, ssfi, true).to.have.property(prop);
2187
- initial = subject[prop];
2188
- }
2189
- fn();
2190
- let final = prop === void 0 || prop === null ? subject() : subject[prop];
2191
- let msgObj = prop === void 0 || prop === null ? initial : "." + prop;
2192
- flag2(this, "deltaMsgObj", msgObj);
2193
- flag2(this, "initialDeltaValue", initial);
2194
- flag2(this, "finalDeltaValue", final);
2195
- flag2(this, "deltaBehavior", "change");
2196
- flag2(this, "realDelta", final !== initial);
2197
- this.assert(initial !== final, "expected " + msgObj + " to change", "expected " + msgObj + " to not change");
2198
- }
2199
- __name(assertChanges, "assertChanges");
2200
- Assertion.addMethod("change", assertChanges);
2201
- Assertion.addMethod("changes", assertChanges);
2202
- function assertIncreases(subject, prop, msg) {
2203
- if (msg) flag2(this, "message", msg);
2204
- let fn = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
2205
- new Assertion(fn, flagMsg, ssfi, true).is.a("function");
2206
- let initial;
2207
- if (!prop) {
2208
- new Assertion(subject, flagMsg, ssfi, true).is.a("function");
2209
- initial = subject();
2210
- } else {
2211
- new Assertion(subject, flagMsg, ssfi, true).to.have.property(prop);
2212
- initial = subject[prop];
2213
- }
2214
- new Assertion(initial, flagMsg, ssfi, true).is.a("number");
2215
- fn();
2216
- let final = prop === void 0 || prop === null ? subject() : subject[prop];
2217
- let msgObj = prop === void 0 || prop === null ? initial : "." + prop;
2218
- flag2(this, "deltaMsgObj", msgObj);
2219
- flag2(this, "initialDeltaValue", initial);
2220
- flag2(this, "finalDeltaValue", final);
2221
- flag2(this, "deltaBehavior", "increase");
2222
- flag2(this, "realDelta", final - initial);
2223
- this.assert(final - initial > 0, "expected " + msgObj + " to increase", "expected " + msgObj + " to not increase");
2224
- }
2225
- __name(assertIncreases, "assertIncreases");
2226
- Assertion.addMethod("increase", assertIncreases);
2227
- Assertion.addMethod("increases", assertIncreases);
2228
- function assertDecreases(subject, prop, msg) {
2229
- if (msg) flag2(this, "message", msg);
2230
- let fn = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
2231
- new Assertion(fn, flagMsg, ssfi, true).is.a("function");
2232
- let initial;
2233
- if (!prop) {
2234
- new Assertion(subject, flagMsg, ssfi, true).is.a("function");
2235
- initial = subject();
2236
- } else {
2237
- new Assertion(subject, flagMsg, ssfi, true).to.have.property(prop);
2238
- initial = subject[prop];
2239
- }
2240
- new Assertion(initial, flagMsg, ssfi, true).is.a("number");
2241
- fn();
2242
- let final = prop === void 0 || prop === null ? subject() : subject[prop];
2243
- let msgObj = prop === void 0 || prop === null ? initial : "." + prop;
2244
- flag2(this, "deltaMsgObj", msgObj);
2245
- flag2(this, "initialDeltaValue", initial);
2246
- flag2(this, "finalDeltaValue", final);
2247
- flag2(this, "deltaBehavior", "decrease");
2248
- flag2(this, "realDelta", initial - final);
2249
- this.assert(final - initial < 0, "expected " + msgObj + " to decrease", "expected " + msgObj + " to not decrease");
2250
- }
2251
- __name(assertDecreases, "assertDecreases");
2252
- Assertion.addMethod("decrease", assertDecreases);
2253
- Assertion.addMethod("decreases", assertDecreases);
2254
- function assertDelta(delta, msg) {
2255
- if (msg) flag2(this, "message", msg);
2256
- let msgObj = flag2(this, "deltaMsgObj");
2257
- let initial = flag2(this, "initialDeltaValue");
2258
- let final = flag2(this, "finalDeltaValue");
2259
- let behavior = flag2(this, "deltaBehavior");
2260
- let realDelta = flag2(this, "realDelta");
2261
- let expression;
2262
- if (behavior === "change") expression = Math.abs(final - initial) === Math.abs(delta);
2263
- else expression = realDelta === Math.abs(delta);
2264
- this.assert(expression, "expected " + msgObj + " to " + behavior + " by " + delta, "expected " + msgObj + " to not " + behavior + " by " + delta);
2265
- }
2266
- __name(assertDelta, "assertDelta");
2267
- Assertion.addMethod("by", assertDelta);
2268
- Assertion.addProperty("extensible", function() {
2269
- let obj = flag2(this, "object");
2270
- let isExtensible = obj === Object(obj) && Object.isExtensible(obj);
2271
- this.assert(isExtensible, "expected #{this} to be extensible", "expected #{this} to not be extensible");
2272
- });
2273
- Assertion.addProperty("sealed", function() {
2274
- let obj = flag2(this, "object");
2275
- let isSealed = obj === Object(obj) ? Object.isSealed(obj) : true;
2276
- this.assert(isSealed, "expected #{this} to be sealed", "expected #{this} to not be sealed");
2277
- });
2278
- Assertion.addProperty("frozen", function() {
2279
- let obj = flag2(this, "object");
2280
- let isFrozen = obj === Object(obj) ? Object.isFrozen(obj) : true;
2281
- this.assert(isFrozen, "expected #{this} to be frozen", "expected #{this} to not be frozen");
2282
- });
2283
- Assertion.addProperty("finite", function(_msg) {
2284
- let obj = flag2(this, "object");
2285
- this.assert(typeof obj === "number" && isFinite(obj), "expected #{this} to be a finite number", "expected #{this} to not be a finite number");
2286
- });
2287
- function compareSubset(expected, actual) {
2288
- if (expected === actual) return true;
2289
- if (typeof actual !== typeof expected) return false;
2290
- if (typeof expected !== "object" || expected === null) return expected === actual;
2291
- if (!actual) return false;
2292
- if (Array.isArray(expected)) {
2293
- if (!Array.isArray(actual)) return false;
2294
- return expected.every(function(exp) {
2295
- return actual.some(function(act) {
2296
- return compareSubset(exp, act);
2297
- });
2298
- });
2299
- }
2300
- if (expected instanceof Date) if (actual instanceof Date) return expected.getTime() === actual.getTime();
2301
- else return false;
2302
- return Object.keys(expected).every(function(key) {
2303
- let expectedValue = expected[key];
2304
- let actualValue = actual[key];
2305
- if (typeof expectedValue === "object" && expectedValue !== null && actualValue !== null) return compareSubset(expectedValue, actualValue);
2306
- if (typeof expectedValue === "function") return expectedValue(actualValue);
2307
- return actualValue === expectedValue;
2308
- });
2309
- }
2310
- __name(compareSubset, "compareSubset");
2311
- Assertion.addMethod("containSubset", function(expected) {
2312
- const actual = flag(this, "object");
2313
- const showDiff = config.showDiff;
2314
- this.assert(compareSubset(expected, actual), "expected #{act} to contain subset #{exp}", "expected #{act} to not contain subset #{exp}", expected, actual, showDiff);
2315
- });
2316
- function expect(val, message) {
2317
- return new Assertion(val, message);
2318
- }
2319
- __name(expect, "expect");
2320
- expect.fail = function(actual, expected, message, operator) {
2321
- if (arguments.length < 2) {
2322
- message = actual;
2323
- actual = void 0;
2324
- }
2325
- message = message || "expect.fail()";
2326
- throw new AssertionError(message, {
2327
- actual,
2328
- expected,
2329
- operator
2330
- }, expect.fail);
2331
- };
2332
- var should_exports = {};
2333
- __export(should_exports, {
2334
- Should: () => Should,
2335
- should: () => should
2336
- });
2337
- function loadShould() {
2338
- function shouldGetter() {
2339
- if (this instanceof String || this instanceof Number || this instanceof Boolean || typeof Symbol === "function" && this instanceof Symbol || typeof BigInt === "function" && this instanceof BigInt) return new Assertion(this.valueOf(), null, shouldGetter);
2340
- return new Assertion(this, null, shouldGetter);
2341
- }
2342
- __name(shouldGetter, "shouldGetter");
2343
- function shouldSetter(value) {
2344
- Object.defineProperty(this, "should", {
2345
- value,
2346
- enumerable: true,
2347
- configurable: true,
2348
- writable: true
2349
- });
2350
- }
2351
- __name(shouldSetter, "shouldSetter");
2352
- Object.defineProperty(Object.prototype, "should", {
2353
- set: shouldSetter,
2354
- get: shouldGetter,
2355
- configurable: true
2356
- });
2357
- let should2 = {};
2358
- should2.fail = function(actual, expected, message, operator) {
2359
- if (arguments.length < 2) {
2360
- message = actual;
2361
- actual = void 0;
2362
- }
2363
- message = message || "should.fail()";
2364
- throw new AssertionError(message, {
2365
- actual,
2366
- expected,
2367
- operator
2368
- }, should2.fail);
2369
- };
2370
- should2.equal = function(actual, expected, message) {
2371
- new Assertion(actual, message).to.equal(expected);
2372
- };
2373
- should2.Throw = function(fn, errt, errs, msg) {
2374
- new Assertion(fn, msg).to.Throw(errt, errs);
2375
- };
2376
- should2.exist = function(val, msg) {
2377
- new Assertion(val, msg).to.exist;
2378
- };
2379
- should2.not = {};
2380
- should2.not.equal = function(actual, expected, msg) {
2381
- new Assertion(actual, msg).to.not.equal(expected);
2382
- };
2383
- should2.not.Throw = function(fn, errt, errs, msg) {
2384
- new Assertion(fn, msg).to.not.Throw(errt, errs);
2385
- };
2386
- should2.not.exist = function(val, msg) {
2387
- new Assertion(val, msg).to.not.exist;
2388
- };
2389
- should2["throw"] = should2["Throw"];
2390
- should2.not["throw"] = should2.not["Throw"];
2391
- return should2;
2392
- }
2393
- __name(loadShould, "loadShould");
2394
- var should = loadShould;
2395
- var Should = loadShould;
2396
- function assert(express, errmsg) {
2397
- new Assertion(null, null, assert, true).assert(express, errmsg, "[ negation message unavailable ]");
2398
- }
2399
- __name(assert, "assert");
2400
- assert.fail = function(actual, expected, message, operator) {
2401
- if (arguments.length < 2) {
2402
- message = actual;
2403
- actual = void 0;
2404
- }
2405
- message = message || "assert.fail()";
2406
- throw new AssertionError(message, {
2407
- actual,
2408
- expected,
2409
- operator
2410
- }, assert.fail);
2411
- };
2412
- assert.isOk = function(val, msg) {
2413
- new Assertion(val, msg, assert.isOk, true).is.ok;
2414
- };
2415
- assert.isNotOk = function(val, msg) {
2416
- new Assertion(val, msg, assert.isNotOk, true).is.not.ok;
2417
- };
2418
- assert.equal = function(act, exp, msg) {
2419
- let test2 = new Assertion(act, msg, assert.equal, true);
2420
- test2.assert(exp == flag(test2, "object"), "expected #{this} to equal #{exp}", "expected #{this} to not equal #{act}", exp, act, true);
2421
- };
2422
- assert.notEqual = function(act, exp, msg) {
2423
- let test2 = new Assertion(act, msg, assert.notEqual, true);
2424
- test2.assert(exp != flag(test2, "object"), "expected #{this} to not equal #{exp}", "expected #{this} to equal #{act}", exp, act, true);
2425
- };
2426
- assert.strictEqual = function(act, exp, msg) {
2427
- new Assertion(act, msg, assert.strictEqual, true).to.equal(exp);
2428
- };
2429
- assert.notStrictEqual = function(act, exp, msg) {
2430
- new Assertion(act, msg, assert.notStrictEqual, true).to.not.equal(exp);
2431
- };
2432
- assert.deepEqual = assert.deepStrictEqual = function(act, exp, msg) {
2433
- new Assertion(act, msg, assert.deepEqual, true).to.eql(exp);
2434
- };
2435
- assert.notDeepEqual = function(act, exp, msg) {
2436
- new Assertion(act, msg, assert.notDeepEqual, true).to.not.eql(exp);
2437
- };
2438
- assert.isAbove = function(val, abv, msg) {
2439
- new Assertion(val, msg, assert.isAbove, true).to.be.above(abv);
2440
- };
2441
- assert.isAtLeast = function(val, atlst, msg) {
2442
- new Assertion(val, msg, assert.isAtLeast, true).to.be.least(atlst);
2443
- };
2444
- assert.isBelow = function(val, blw, msg) {
2445
- new Assertion(val, msg, assert.isBelow, true).to.be.below(blw);
2446
- };
2447
- assert.isAtMost = function(val, atmst, msg) {
2448
- new Assertion(val, msg, assert.isAtMost, true).to.be.most(atmst);
2449
- };
2450
- assert.isTrue = function(val, msg) {
2451
- new Assertion(val, msg, assert.isTrue, true).is["true"];
2452
- };
2453
- assert.isNotTrue = function(val, msg) {
2454
- new Assertion(val, msg, assert.isNotTrue, true).to.not.equal(true);
2455
- };
2456
- assert.isFalse = function(val, msg) {
2457
- new Assertion(val, msg, assert.isFalse, true).is["false"];
2458
- };
2459
- assert.isNotFalse = function(val, msg) {
2460
- new Assertion(val, msg, assert.isNotFalse, true).to.not.equal(false);
2461
- };
2462
- assert.isNull = function(val, msg) {
2463
- new Assertion(val, msg, assert.isNull, true).to.equal(null);
2464
- };
2465
- assert.isNotNull = function(val, msg) {
2466
- new Assertion(val, msg, assert.isNotNull, true).to.not.equal(null);
2467
- };
2468
- assert.isNaN = function(val, msg) {
2469
- new Assertion(val, msg, assert.isNaN, true).to.be.NaN;
2470
- };
2471
- assert.isNotNaN = function(value, message) {
2472
- new Assertion(value, message, assert.isNotNaN, true).not.to.be.NaN;
2473
- };
2474
- assert.exists = function(val, msg) {
2475
- new Assertion(val, msg, assert.exists, true).to.exist;
2476
- };
2477
- assert.notExists = function(val, msg) {
2478
- new Assertion(val, msg, assert.notExists, true).to.not.exist;
2479
- };
2480
- assert.isUndefined = function(val, msg) {
2481
- new Assertion(val, msg, assert.isUndefined, true).to.equal(void 0);
2482
- };
2483
- assert.isDefined = function(val, msg) {
2484
- new Assertion(val, msg, assert.isDefined, true).to.not.equal(void 0);
2485
- };
2486
- assert.isCallable = function(value, message) {
2487
- new Assertion(value, message, assert.isCallable, true).is.callable;
2488
- };
2489
- assert.isNotCallable = function(value, message) {
2490
- new Assertion(value, message, assert.isNotCallable, true).is.not.callable;
2491
- };
2492
- assert.isObject = function(val, msg) {
2493
- new Assertion(val, msg, assert.isObject, true).to.be.a("object");
2494
- };
2495
- assert.isNotObject = function(val, msg) {
2496
- new Assertion(val, msg, assert.isNotObject, true).to.not.be.a("object");
2497
- };
2498
- assert.isArray = function(val, msg) {
2499
- new Assertion(val, msg, assert.isArray, true).to.be.an("array");
2500
- };
2501
- assert.isNotArray = function(val, msg) {
2502
- new Assertion(val, msg, assert.isNotArray, true).to.not.be.an("array");
2503
- };
2504
- assert.isString = function(val, msg) {
2505
- new Assertion(val, msg, assert.isString, true).to.be.a("string");
2506
- };
2507
- assert.isNotString = function(val, msg) {
2508
- new Assertion(val, msg, assert.isNotString, true).to.not.be.a("string");
2509
- };
2510
- assert.isNumber = function(val, msg) {
2511
- new Assertion(val, msg, assert.isNumber, true).to.be.a("number");
2512
- };
2513
- assert.isNotNumber = function(val, msg) {
2514
- new Assertion(val, msg, assert.isNotNumber, true).to.not.be.a("number");
2515
- };
2516
- assert.isNumeric = function(val, msg) {
2517
- new Assertion(val, msg, assert.isNumeric, true).is.numeric;
2518
- };
2519
- assert.isNotNumeric = function(val, msg) {
2520
- new Assertion(val, msg, assert.isNotNumeric, true).is.not.numeric;
2521
- };
2522
- assert.isFinite = function(val, msg) {
2523
- new Assertion(val, msg, assert.isFinite, true).to.be.finite;
2524
- };
2525
- assert.isBoolean = function(val, msg) {
2526
- new Assertion(val, msg, assert.isBoolean, true).to.be.a("boolean");
2527
- };
2528
- assert.isNotBoolean = function(val, msg) {
2529
- new Assertion(val, msg, assert.isNotBoolean, true).to.not.be.a("boolean");
2530
- };
2531
- assert.typeOf = function(val, type3, msg) {
2532
- new Assertion(val, msg, assert.typeOf, true).to.be.a(type3);
2533
- };
2534
- assert.notTypeOf = function(value, type3, message) {
2535
- new Assertion(value, message, assert.notTypeOf, true).to.not.be.a(type3);
2536
- };
2537
- assert.instanceOf = function(val, type3, msg) {
2538
- new Assertion(val, msg, assert.instanceOf, true).to.be.instanceOf(type3);
2539
- };
2540
- assert.notInstanceOf = function(val, type3, msg) {
2541
- new Assertion(val, msg, assert.notInstanceOf, true).to.not.be.instanceOf(type3);
2542
- };
2543
- assert.include = function(exp, inc, msg) {
2544
- new Assertion(exp, msg, assert.include, true).include(inc);
2545
- };
2546
- assert.notInclude = function(exp, inc, msg) {
2547
- new Assertion(exp, msg, assert.notInclude, true).not.include(inc);
2548
- };
2549
- assert.deepInclude = function(exp, inc, msg) {
2550
- new Assertion(exp, msg, assert.deepInclude, true).deep.include(inc);
2551
- };
2552
- assert.notDeepInclude = function(exp, inc, msg) {
2553
- new Assertion(exp, msg, assert.notDeepInclude, true).not.deep.include(inc);
2554
- };
2555
- assert.nestedInclude = function(exp, inc, msg) {
2556
- new Assertion(exp, msg, assert.nestedInclude, true).nested.include(inc);
2557
- };
2558
- assert.notNestedInclude = function(exp, inc, msg) {
2559
- new Assertion(exp, msg, assert.notNestedInclude, true).not.nested.include(inc);
2560
- };
2561
- assert.deepNestedInclude = function(exp, inc, msg) {
2562
- new Assertion(exp, msg, assert.deepNestedInclude, true).deep.nested.include(inc);
2563
- };
2564
- assert.notDeepNestedInclude = function(exp, inc, msg) {
2565
- new Assertion(exp, msg, assert.notDeepNestedInclude, true).not.deep.nested.include(inc);
2566
- };
2567
- assert.ownInclude = function(exp, inc, msg) {
2568
- new Assertion(exp, msg, assert.ownInclude, true).own.include(inc);
2569
- };
2570
- assert.notOwnInclude = function(exp, inc, msg) {
2571
- new Assertion(exp, msg, assert.notOwnInclude, true).not.own.include(inc);
2572
- };
2573
- assert.deepOwnInclude = function(exp, inc, msg) {
2574
- new Assertion(exp, msg, assert.deepOwnInclude, true).deep.own.include(inc);
2575
- };
2576
- assert.notDeepOwnInclude = function(exp, inc, msg) {
2577
- new Assertion(exp, msg, assert.notDeepOwnInclude, true).not.deep.own.include(inc);
2578
- };
2579
- assert.match = function(exp, re, msg) {
2580
- new Assertion(exp, msg, assert.match, true).to.match(re);
2581
- };
2582
- assert.notMatch = function(exp, re, msg) {
2583
- new Assertion(exp, msg, assert.notMatch, true).to.not.match(re);
2584
- };
2585
- assert.property = function(obj, prop, msg) {
2586
- new Assertion(obj, msg, assert.property, true).to.have.property(prop);
2587
- };
2588
- assert.notProperty = function(obj, prop, msg) {
2589
- new Assertion(obj, msg, assert.notProperty, true).to.not.have.property(prop);
2590
- };
2591
- assert.propertyVal = function(obj, prop, val, msg) {
2592
- new Assertion(obj, msg, assert.propertyVal, true).to.have.property(prop, val);
2593
- };
2594
- assert.notPropertyVal = function(obj, prop, val, msg) {
2595
- new Assertion(obj, msg, assert.notPropertyVal, true).to.not.have.property(prop, val);
2596
- };
2597
- assert.deepPropertyVal = function(obj, prop, val, msg) {
2598
- new Assertion(obj, msg, assert.deepPropertyVal, true).to.have.deep.property(prop, val);
2599
- };
2600
- assert.notDeepPropertyVal = function(obj, prop, val, msg) {
2601
- new Assertion(obj, msg, assert.notDeepPropertyVal, true).to.not.have.deep.property(prop, val);
2602
- };
2603
- assert.ownProperty = function(obj, prop, msg) {
2604
- new Assertion(obj, msg, assert.ownProperty, true).to.have.own.property(prop);
2605
- };
2606
- assert.notOwnProperty = function(obj, prop, msg) {
2607
- new Assertion(obj, msg, assert.notOwnProperty, true).to.not.have.own.property(prop);
2608
- };
2609
- assert.ownPropertyVal = function(obj, prop, value, msg) {
2610
- new Assertion(obj, msg, assert.ownPropertyVal, true).to.have.own.property(prop, value);
2611
- };
2612
- assert.notOwnPropertyVal = function(obj, prop, value, msg) {
2613
- new Assertion(obj, msg, assert.notOwnPropertyVal, true).to.not.have.own.property(prop, value);
2614
- };
2615
- assert.deepOwnPropertyVal = function(obj, prop, value, msg) {
2616
- new Assertion(obj, msg, assert.deepOwnPropertyVal, true).to.have.deep.own.property(prop, value);
2617
- };
2618
- assert.notDeepOwnPropertyVal = function(obj, prop, value, msg) {
2619
- new Assertion(obj, msg, assert.notDeepOwnPropertyVal, true).to.not.have.deep.own.property(prop, value);
2620
- };
2621
- assert.nestedProperty = function(obj, prop, msg) {
2622
- new Assertion(obj, msg, assert.nestedProperty, true).to.have.nested.property(prop);
2623
- };
2624
- assert.notNestedProperty = function(obj, prop, msg) {
2625
- new Assertion(obj, msg, assert.notNestedProperty, true).to.not.have.nested.property(prop);
2626
- };
2627
- assert.nestedPropertyVal = function(obj, prop, val, msg) {
2628
- new Assertion(obj, msg, assert.nestedPropertyVal, true).to.have.nested.property(prop, val);
2629
- };
2630
- assert.notNestedPropertyVal = function(obj, prop, val, msg) {
2631
- new Assertion(obj, msg, assert.notNestedPropertyVal, true).to.not.have.nested.property(prop, val);
2632
- };
2633
- assert.deepNestedPropertyVal = function(obj, prop, val, msg) {
2634
- new Assertion(obj, msg, assert.deepNestedPropertyVal, true).to.have.deep.nested.property(prop, val);
2635
- };
2636
- assert.notDeepNestedPropertyVal = function(obj, prop, val, msg) {
2637
- new Assertion(obj, msg, assert.notDeepNestedPropertyVal, true).to.not.have.deep.nested.property(prop, val);
2638
- };
2639
- assert.lengthOf = function(exp, len, msg) {
2640
- new Assertion(exp, msg, assert.lengthOf, true).to.have.lengthOf(len);
2641
- };
2642
- assert.hasAnyKeys = function(obj, keys, msg) {
2643
- new Assertion(obj, msg, assert.hasAnyKeys, true).to.have.any.keys(keys);
2644
- };
2645
- assert.hasAllKeys = function(obj, keys, msg) {
2646
- new Assertion(obj, msg, assert.hasAllKeys, true).to.have.all.keys(keys);
2647
- };
2648
- assert.containsAllKeys = function(obj, keys, msg) {
2649
- new Assertion(obj, msg, assert.containsAllKeys, true).to.contain.all.keys(keys);
2650
- };
2651
- assert.doesNotHaveAnyKeys = function(obj, keys, msg) {
2652
- new Assertion(obj, msg, assert.doesNotHaveAnyKeys, true).to.not.have.any.keys(keys);
2653
- };
2654
- assert.doesNotHaveAllKeys = function(obj, keys, msg) {
2655
- new Assertion(obj, msg, assert.doesNotHaveAllKeys, true).to.not.have.all.keys(keys);
2656
- };
2657
- assert.hasAnyDeepKeys = function(obj, keys, msg) {
2658
- new Assertion(obj, msg, assert.hasAnyDeepKeys, true).to.have.any.deep.keys(keys);
2659
- };
2660
- assert.hasAllDeepKeys = function(obj, keys, msg) {
2661
- new Assertion(obj, msg, assert.hasAllDeepKeys, true).to.have.all.deep.keys(keys);
2662
- };
2663
- assert.containsAllDeepKeys = function(obj, keys, msg) {
2664
- new Assertion(obj, msg, assert.containsAllDeepKeys, true).to.contain.all.deep.keys(keys);
2665
- };
2666
- assert.doesNotHaveAnyDeepKeys = function(obj, keys, msg) {
2667
- new Assertion(obj, msg, assert.doesNotHaveAnyDeepKeys, true).to.not.have.any.deep.keys(keys);
2668
- };
2669
- assert.doesNotHaveAllDeepKeys = function(obj, keys, msg) {
2670
- new Assertion(obj, msg, assert.doesNotHaveAllDeepKeys, true).to.not.have.all.deep.keys(keys);
2671
- };
2672
- assert.throws = function(fn, errorLike, errMsgMatcher, msg) {
2673
- if ("string" === typeof errorLike || errorLike instanceof RegExp) {
2674
- errMsgMatcher = errorLike;
2675
- errorLike = null;
2676
- }
2677
- return flag(new Assertion(fn, msg, assert.throws, true).to.throw(errorLike, errMsgMatcher), "object");
2678
- };
2679
- assert.doesNotThrow = function(fn, errorLike, errMsgMatcher, message) {
2680
- if ("string" === typeof errorLike || errorLike instanceof RegExp) {
2681
- errMsgMatcher = errorLike;
2682
- errorLike = null;
2683
- }
2684
- new Assertion(fn, message, assert.doesNotThrow, true).to.not.throw(errorLike, errMsgMatcher);
2685
- };
2686
- assert.operator = function(val, operator, val2, msg) {
2687
- let ok;
2688
- switch (operator) {
2689
- case "==":
2690
- ok = val == val2;
2691
- break;
2692
- case "===":
2693
- ok = val === val2;
2694
- break;
2695
- case ">":
2696
- ok = val > val2;
2697
- break;
2698
- case ">=":
2699
- ok = val >= val2;
2700
- break;
2701
- case "<":
2702
- ok = val < val2;
2703
- break;
2704
- case "<=":
2705
- ok = val <= val2;
2706
- break;
2707
- case "!=":
2708
- ok = val != val2;
2709
- break;
2710
- case "!==":
2711
- ok = val !== val2;
2712
- break;
2713
- default:
2714
- msg = msg ? msg + ": " : msg;
2715
- throw new AssertionError(msg + "Invalid operator \"" + operator + "\"", void 0, assert.operator);
2716
- }
2717
- let test2 = new Assertion(ok, msg, assert.operator, true);
2718
- test2.assert(true === flag(test2, "object"), "expected " + inspect2(val) + " to be " + operator + " " + inspect2(val2), "expected " + inspect2(val) + " to not be " + operator + " " + inspect2(val2));
2719
- };
2720
- assert.closeTo = function(act, exp, delta, msg) {
2721
- new Assertion(act, msg, assert.closeTo, true).to.be.closeTo(exp, delta);
2722
- };
2723
- assert.approximately = function(act, exp, delta, msg) {
2724
- new Assertion(act, msg, assert.approximately, true).to.be.approximately(exp, delta);
2725
- };
2726
- assert.sameMembers = function(set1, set2, msg) {
2727
- new Assertion(set1, msg, assert.sameMembers, true).to.have.same.members(set2);
2728
- };
2729
- assert.notSameMembers = function(set1, set2, msg) {
2730
- new Assertion(set1, msg, assert.notSameMembers, true).to.not.have.same.members(set2);
2731
- };
2732
- assert.sameDeepMembers = function(set1, set2, msg) {
2733
- new Assertion(set1, msg, assert.sameDeepMembers, true).to.have.same.deep.members(set2);
2734
- };
2735
- assert.notSameDeepMembers = function(set1, set2, msg) {
2736
- new Assertion(set1, msg, assert.notSameDeepMembers, true).to.not.have.same.deep.members(set2);
2737
- };
2738
- assert.sameOrderedMembers = function(set1, set2, msg) {
2739
- new Assertion(set1, msg, assert.sameOrderedMembers, true).to.have.same.ordered.members(set2);
2740
- };
2741
- assert.notSameOrderedMembers = function(set1, set2, msg) {
2742
- new Assertion(set1, msg, assert.notSameOrderedMembers, true).to.not.have.same.ordered.members(set2);
2743
- };
2744
- assert.sameDeepOrderedMembers = function(set1, set2, msg) {
2745
- new Assertion(set1, msg, assert.sameDeepOrderedMembers, true).to.have.same.deep.ordered.members(set2);
2746
- };
2747
- assert.notSameDeepOrderedMembers = function(set1, set2, msg) {
2748
- new Assertion(set1, msg, assert.notSameDeepOrderedMembers, true).to.not.have.same.deep.ordered.members(set2);
2749
- };
2750
- assert.includeMembers = function(superset, subset, msg) {
2751
- new Assertion(superset, msg, assert.includeMembers, true).to.include.members(subset);
2752
- };
2753
- assert.notIncludeMembers = function(superset, subset, msg) {
2754
- new Assertion(superset, msg, assert.notIncludeMembers, true).to.not.include.members(subset);
2755
- };
2756
- assert.includeDeepMembers = function(superset, subset, msg) {
2757
- new Assertion(superset, msg, assert.includeDeepMembers, true).to.include.deep.members(subset);
2758
- };
2759
- assert.notIncludeDeepMembers = function(superset, subset, msg) {
2760
- new Assertion(superset, msg, assert.notIncludeDeepMembers, true).to.not.include.deep.members(subset);
2761
- };
2762
- assert.includeOrderedMembers = function(superset, subset, msg) {
2763
- new Assertion(superset, msg, assert.includeOrderedMembers, true).to.include.ordered.members(subset);
2764
- };
2765
- assert.notIncludeOrderedMembers = function(superset, subset, msg) {
2766
- new Assertion(superset, msg, assert.notIncludeOrderedMembers, true).to.not.include.ordered.members(subset);
2767
- };
2768
- assert.includeDeepOrderedMembers = function(superset, subset, msg) {
2769
- new Assertion(superset, msg, assert.includeDeepOrderedMembers, true).to.include.deep.ordered.members(subset);
2770
- };
2771
- assert.notIncludeDeepOrderedMembers = function(superset, subset, msg) {
2772
- new Assertion(superset, msg, assert.notIncludeDeepOrderedMembers, true).to.not.include.deep.ordered.members(subset);
2773
- };
2774
- assert.oneOf = function(inList, list, msg) {
2775
- new Assertion(inList, msg, assert.oneOf, true).to.be.oneOf(list);
2776
- };
2777
- assert.isIterable = function(obj, msg) {
2778
- if (obj == void 0 || !obj[Symbol.iterator]) {
2779
- msg = msg ? `${msg} expected ${inspect2(obj)} to be an iterable` : `expected ${inspect2(obj)} to be an iterable`;
2780
- throw new AssertionError(msg, void 0, assert.isIterable);
2781
- }
2782
- };
2783
- assert.changes = function(fn, obj, prop, msg) {
2784
- if (arguments.length === 3 && typeof obj === "function") {
2785
- msg = prop;
2786
- prop = null;
2787
- }
2788
- new Assertion(fn, msg, assert.changes, true).to.change(obj, prop);
2789
- };
2790
- assert.changesBy = function(fn, obj, prop, delta, msg) {
2791
- if (arguments.length === 4 && typeof obj === "function") {
2792
- let tmpMsg = delta;
2793
- delta = prop;
2794
- msg = tmpMsg;
2795
- } else if (arguments.length === 3) {
2796
- delta = prop;
2797
- prop = null;
2798
- }
2799
- new Assertion(fn, msg, assert.changesBy, true).to.change(obj, prop).by(delta);
2800
- };
2801
- assert.doesNotChange = function(fn, obj, prop, msg) {
2802
- if (arguments.length === 3 && typeof obj === "function") {
2803
- msg = prop;
2804
- prop = null;
2805
- }
2806
- return new Assertion(fn, msg, assert.doesNotChange, true).to.not.change(obj, prop);
2807
- };
2808
- assert.changesButNotBy = function(fn, obj, prop, delta, msg) {
2809
- if (arguments.length === 4 && typeof obj === "function") {
2810
- let tmpMsg = delta;
2811
- delta = prop;
2812
- msg = tmpMsg;
2813
- } else if (arguments.length === 3) {
2814
- delta = prop;
2815
- prop = null;
2816
- }
2817
- new Assertion(fn, msg, assert.changesButNotBy, true).to.change(obj, prop).but.not.by(delta);
2818
- };
2819
- assert.increases = function(fn, obj, prop, msg) {
2820
- if (arguments.length === 3 && typeof obj === "function") {
2821
- msg = prop;
2822
- prop = null;
2823
- }
2824
- return new Assertion(fn, msg, assert.increases, true).to.increase(obj, prop);
2825
- };
2826
- assert.increasesBy = function(fn, obj, prop, delta, msg) {
2827
- if (arguments.length === 4 && typeof obj === "function") {
2828
- let tmpMsg = delta;
2829
- delta = prop;
2830
- msg = tmpMsg;
2831
- } else if (arguments.length === 3) {
2832
- delta = prop;
2833
- prop = null;
2834
- }
2835
- new Assertion(fn, msg, assert.increasesBy, true).to.increase(obj, prop).by(delta);
2836
- };
2837
- assert.doesNotIncrease = function(fn, obj, prop, msg) {
2838
- if (arguments.length === 3 && typeof obj === "function") {
2839
- msg = prop;
2840
- prop = null;
2841
- }
2842
- return new Assertion(fn, msg, assert.doesNotIncrease, true).to.not.increase(obj, prop);
2843
- };
2844
- assert.increasesButNotBy = function(fn, obj, prop, delta, msg) {
2845
- if (arguments.length === 4 && typeof obj === "function") {
2846
- let tmpMsg = delta;
2847
- delta = prop;
2848
- msg = tmpMsg;
2849
- } else if (arguments.length === 3) {
2850
- delta = prop;
2851
- prop = null;
2852
- }
2853
- new Assertion(fn, msg, assert.increasesButNotBy, true).to.increase(obj, prop).but.not.by(delta);
2854
- };
2855
- assert.decreases = function(fn, obj, prop, msg) {
2856
- if (arguments.length === 3 && typeof obj === "function") {
2857
- msg = prop;
2858
- prop = null;
2859
- }
2860
- return new Assertion(fn, msg, assert.decreases, true).to.decrease(obj, prop);
2861
- };
2862
- assert.decreasesBy = function(fn, obj, prop, delta, msg) {
2863
- if (arguments.length === 4 && typeof obj === "function") {
2864
- let tmpMsg = delta;
2865
- delta = prop;
2866
- msg = tmpMsg;
2867
- } else if (arguments.length === 3) {
2868
- delta = prop;
2869
- prop = null;
2870
- }
2871
- new Assertion(fn, msg, assert.decreasesBy, true).to.decrease(obj, prop).by(delta);
2872
- };
2873
- assert.doesNotDecrease = function(fn, obj, prop, msg) {
2874
- if (arguments.length === 3 && typeof obj === "function") {
2875
- msg = prop;
2876
- prop = null;
2877
- }
2878
- return new Assertion(fn, msg, assert.doesNotDecrease, true).to.not.decrease(obj, prop);
2879
- };
2880
- assert.doesNotDecreaseBy = function(fn, obj, prop, delta, msg) {
2881
- if (arguments.length === 4 && typeof obj === "function") {
2882
- let tmpMsg = delta;
2883
- delta = prop;
2884
- msg = tmpMsg;
2885
- } else if (arguments.length === 3) {
2886
- delta = prop;
2887
- prop = null;
2888
- }
2889
- return new Assertion(fn, msg, assert.doesNotDecreaseBy, true).to.not.decrease(obj, prop).by(delta);
2890
- };
2891
- assert.decreasesButNotBy = function(fn, obj, prop, delta, msg) {
2892
- if (arguments.length === 4 && typeof obj === "function") {
2893
- let tmpMsg = delta;
2894
- delta = prop;
2895
- msg = tmpMsg;
2896
- } else if (arguments.length === 3) {
2897
- delta = prop;
2898
- prop = null;
2899
- }
2900
- new Assertion(fn, msg, assert.decreasesButNotBy, true).to.decrease(obj, prop).but.not.by(delta);
2901
- };
2902
- assert.ifError = function(val) {
2903
- if (val) throw val;
2904
- };
2905
- assert.isExtensible = function(obj, msg) {
2906
- new Assertion(obj, msg, assert.isExtensible, true).to.be.extensible;
2907
- };
2908
- assert.isNotExtensible = function(obj, msg) {
2909
- new Assertion(obj, msg, assert.isNotExtensible, true).to.not.be.extensible;
2910
- };
2911
- assert.isSealed = function(obj, msg) {
2912
- new Assertion(obj, msg, assert.isSealed, true).to.be.sealed;
2913
- };
2914
- assert.isNotSealed = function(obj, msg) {
2915
- new Assertion(obj, msg, assert.isNotSealed, true).to.not.be.sealed;
2916
- };
2917
- assert.isFrozen = function(obj, msg) {
2918
- new Assertion(obj, msg, assert.isFrozen, true).to.be.frozen;
2919
- };
2920
- assert.isNotFrozen = function(obj, msg) {
2921
- new Assertion(obj, msg, assert.isNotFrozen, true).to.not.be.frozen;
2922
- };
2923
- assert.isEmpty = function(val, msg) {
2924
- new Assertion(val, msg, assert.isEmpty, true).to.be.empty;
2925
- };
2926
- assert.isNotEmpty = function(val, msg) {
2927
- new Assertion(val, msg, assert.isNotEmpty, true).to.not.be.empty;
2928
- };
2929
- assert.containsSubset = function(val, exp, msg) {
2930
- new Assertion(val, msg).to.containSubset(exp);
2931
- };
2932
- assert.doesNotContainSubset = function(val, exp, msg) {
2933
- new Assertion(val, msg).to.not.containSubset(exp);
2934
- };
2935
- for (const [name, as] of [
2936
- ["isOk", "ok"],
2937
- ["isNotOk", "notOk"],
2938
- ["throws", "throw"],
2939
- ["throws", "Throw"],
2940
- ["isExtensible", "extensible"],
2941
- ["isNotExtensible", "notExtensible"],
2942
- ["isSealed", "sealed"],
2943
- ["isNotSealed", "notSealed"],
2944
- ["isFrozen", "frozen"],
2945
- ["isNotFrozen", "notFrozen"],
2946
- ["isEmpty", "empty"],
2947
- ["isNotEmpty", "notEmpty"],
2948
- ["isCallable", "isFunction"],
2949
- ["isNotCallable", "isNotFunction"],
2950
- ["containsSubset", "containSubset"]
2951
- ]) assert[as] = assert[name];
2952
- var used = [];
2953
- function use(fn) {
2954
- const exports = {
2955
- use,
2956
- AssertionError,
2957
- util: utils_exports,
2958
- config,
2959
- expect,
2960
- assert,
2961
- Assertion,
2962
- ...should_exports
2963
- };
2964
- if (!~used.indexOf(fn)) {
2965
- fn(exports, utils_exports);
2966
- used.push(fn);
2967
- }
2968
- return exports;
2969
- }
2970
- __name(use, "use");
2971
-
2972
- //#endregion
2973
- exports.Assertion = Assertion;
2974
- exports.assert = assert;
2975
- exports.expect = expect;
2976
- exports.should = should;
2977
- exports.use = use;
2978
- exports.utils_exports = utils_exports;