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