hein 1.4.2 → 2.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/ESM_MIGRATION_NOTES.md +6 -0
- package/README.md +46 -7
- package/dist/assert-9EsvfQwn.d.cts +483 -0
- package/dist/assert-9EsvfQwn.d.cts.map +1 -0
- package/dist/assert-B_vcZS90.d.ts +481 -0
- package/dist/assert-B_vcZS90.d.ts.map +1 -0
- package/dist/assert-DZjgWjOw.cjs +1626 -0
- package/dist/assert-DZjgWjOw.cjs.map +1 -0
- package/dist/assert-kFXp7i_B.js +1260 -0
- package/dist/assert-kFXp7i_B.js.map +1 -0
- package/dist/assert.cjs +53 -0
- package/dist/assert.d.cts +3 -0
- package/dist/assert.d.ts +3 -27
- package/dist/assert.js +3 -84
- package/dist/chunk-CTAAG5j7.js +13 -0
- package/dist/expect.types-DPl6xY56.d.ts +99 -0
- package/dist/expect.types-DPl6xY56.d.ts.map +1 -0
- package/dist/expect.types-s8icgWp5.d.cts +99 -0
- package/dist/expect.types-s8icgWp5.d.cts.map +1 -0
- package/dist/expect.types.cjs +0 -0
- package/dist/expect.types.d.cts +3 -0
- package/dist/expect.types.d.ts +3 -66
- package/dist/expect.types.js +1 -4
- package/dist/index.cjs +596 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +16 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +15 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +573 -27
- package/dist/index.js.map +1 -1
- package/dist/throws-BrCCeBBl.d.ts +42 -0
- package/dist/throws-BrCCeBBl.d.ts.map +1 -0
- package/dist/throws-D7JsW4NM.d.cts +40 -0
- package/dist/throws-D7JsW4NM.d.cts.map +1 -0
- package/eslint.config.mjs +13 -0
- package/package.json +31 -18
- package/tsdown.config.ts +9 -0
- package/dist/assert/deep-equal.d.ts +0 -2
- package/dist/assert/deep-equal.d.ts.map +0 -1
- package/dist/assert/deep-equal.js +0 -26
- package/dist/assert/deep-equal.js.map +0 -1
- package/dist/assert/deep-has-property.d.ts +0 -20
- package/dist/assert/deep-has-property.d.ts.map +0 -1
- package/dist/assert/deep-has-property.js +0 -50
- package/dist/assert/deep-has-property.js.map +0 -1
- package/dist/assert/ends-with.d.ts +0 -11
- package/dist/assert/ends-with.d.ts.map +0 -1
- package/dist/assert/ends-with.js +0 -30
- package/dist/assert/ends-with.js.map +0 -1
- package/dist/assert/equal.d.ts +0 -9
- package/dist/assert/equal.d.ts.map +0 -1
- package/dist/assert/equal.js +0 -21
- package/dist/assert/equal.js.map +0 -1
- package/dist/assert/greater-than-equal.d.ts +0 -9
- package/dist/assert/greater-than-equal.d.ts.map +0 -1
- package/dist/assert/greater-than-equal.js +0 -20
- package/dist/assert/greater-than-equal.js.map +0 -1
- package/dist/assert/greater-than.d.ts +0 -9
- package/dist/assert/greater-than.d.ts.map +0 -1
- package/dist/assert/greater-than.js +0 -20
- package/dist/assert/greater-than.js.map +0 -1
- package/dist/assert/has-keys.d.ts +0 -14
- package/dist/assert/has-keys.d.ts.map +0 -1
- package/dist/assert/has-keys.js +0 -47
- package/dist/assert/has-keys.js.map +0 -1
- package/dist/assert/has-members.d.ts +0 -46
- package/dist/assert/has-members.d.ts.map +0 -1
- package/dist/assert/has-members.js +0 -58
- package/dist/assert/has-members.js.map +0 -1
- package/dist/assert/has-property.d.ts +0 -20
- package/dist/assert/has-property.d.ts.map +0 -1
- package/dist/assert/has-property.js +0 -47
- package/dist/assert/has-property.js.map +0 -1
- package/dist/assert/has-size.d.ts +0 -40
- package/dist/assert/has-size.d.ts.map +0 -1
- package/dist/assert/has-size.js +0 -68
- package/dist/assert/has-size.js.map +0 -1
- package/dist/assert/in-ballpark.d.ts +0 -14
- package/dist/assert/in-ballpark.d.ts.map +0 -1
- package/dist/assert/in-ballpark.js +0 -26
- package/dist/assert/in-ballpark.js.map +0 -1
- package/dist/assert/includes.d.ts +0 -22
- package/dist/assert/includes.d.ts.map +0 -1
- package/dist/assert/includes.js +0 -32
- package/dist/assert/includes.js.map +0 -1
- package/dist/assert/instance-of.d.ts +0 -13
- package/dist/assert/instance-of.d.ts.map +0 -1
- package/dist/assert/instance-of.js +0 -35
- package/dist/assert/instance-of.js.map +0 -1
- package/dist/assert/is-after.d.ts +0 -9
- package/dist/assert/is-after.d.ts.map +0 -1
- package/dist/assert/is-after.js +0 -27
- package/dist/assert/is-after.js.map +0 -1
- package/dist/assert/is-before.d.ts +0 -9
- package/dist/assert/is-before.d.ts.map +0 -1
- package/dist/assert/is-before.js +0 -27
- package/dist/assert/is-before.js.map +0 -1
- package/dist/assert/is-between.d.ts +0 -13
- package/dist/assert/is-between.d.ts.map +0 -1
- package/dist/assert/is-between.js +0 -38
- package/dist/assert/is-between.js.map +0 -1
- package/dist/assert/is-empty.d.ts +0 -29
- package/dist/assert/is-empty.d.ts.map +0 -1
- package/dist/assert/is-empty.js +0 -48
- package/dist/assert/is-empty.js.map +0 -1
- package/dist/assert/is-type.d.ts +0 -94
- package/dist/assert/is-type.d.ts.map +0 -1
- package/dist/assert/is-type.js +0 -32
- package/dist/assert/is-type.js.map +0 -1
- package/dist/assert/less-than-equal.d.ts +0 -9
- package/dist/assert/less-than-equal.d.ts.map +0 -1
- package/dist/assert/less-than-equal.js +0 -27
- package/dist/assert/less-than-equal.js.map +0 -1
- package/dist/assert/less-than.d.ts +0 -9
- package/dist/assert/less-than.d.ts.map +0 -1
- package/dist/assert/less-than.js +0 -20
- package/dist/assert/less-than.js.map +0 -1
- package/dist/assert/match.d.ts +0 -13
- package/dist/assert/match.d.ts.map +0 -1
- package/dist/assert/match.js +0 -29
- package/dist/assert/match.js.map +0 -1
- package/dist/assert/rejects.d.ts +0 -33
- package/dist/assert/rejects.d.ts.map +0 -1
- package/dist/assert/rejects.js +0 -48
- package/dist/assert/rejects.js.map +0 -1
- package/dist/assert/round-to.d.ts +0 -13
- package/dist/assert/round-to.d.ts.map +0 -1
- package/dist/assert/round-to.js +0 -43
- package/dist/assert/round-to.js.map +0 -1
- package/dist/assert/starts-with.d.ts +0 -12
- package/dist/assert/starts-with.d.ts.map +0 -1
- package/dist/assert/starts-with.js +0 -30
- package/dist/assert/starts-with.js.map +0 -1
- package/dist/assert/throws.d.ts +0 -33
- package/dist/assert/throws.d.ts.map +0 -1
- package/dist/assert/throws.js +0 -40
- package/dist/assert/throws.js.map +0 -1
- package/dist/assert.d.ts.map +0 -1
- package/dist/assert.js.map +0 -1
- package/dist/expect/after.d.ts +0 -11
- package/dist/expect/after.d.ts.map +0 -1
- package/dist/expect/after.js +0 -18
- package/dist/expect/after.js.map +0 -1
- package/dist/expect/ballpark.d.ts +0 -12
- package/dist/expect/ballpark.d.ts.map +0 -1
- package/dist/expect/ballpark.js +0 -18
- package/dist/expect/ballpark.js.map +0 -1
- package/dist/expect/before.d.ts +0 -11
- package/dist/expect/before.d.ts.map +0 -1
- package/dist/expect/before.js +0 -18
- package/dist/expect/before.js.map +0 -1
- package/dist/expect/between.d.ts +0 -21
- package/dist/expect/between.d.ts.map +0 -1
- package/dist/expect/between.js +0 -18
- package/dist/expect/between.js.map +0 -1
- package/dist/expect/empty.d.ts +0 -16
- package/dist/expect/empty.d.ts.map +0 -1
- package/dist/expect/empty.js +0 -18
- package/dist/expect/empty.js.map +0 -1
- package/dist/expect/end-with.d.ts +0 -12
- package/dist/expect/end-with.d.ts.map +0 -1
- package/dist/expect/end-with.js +0 -18
- package/dist/expect/end-with.js.map +0 -1
- package/dist/expect/eql.d.ts +0 -11
- package/dist/expect/eql.d.ts.map +0 -1
- package/dist/expect/eql.js +0 -22
- package/dist/expect/eql.js.map +0 -1
- package/dist/expect/equal-shorthand.d.ts +0 -14
- package/dist/expect/equal-shorthand.d.ts.map +0 -1
- package/dist/expect/equal-shorthand.js +0 -34
- package/dist/expect/equal-shorthand.js.map +0 -1
- package/dist/expect/equal.d.ts +0 -14
- package/dist/expect/equal.d.ts.map +0 -1
- package/dist/expect/equal.js +0 -28
- package/dist/expect/equal.js.map +0 -1
- package/dist/expect/excluding.d.ts +0 -11
- package/dist/expect/excluding.d.ts.map +0 -1
- package/dist/expect/excluding.js +0 -14
- package/dist/expect/excluding.js.map +0 -1
- package/dist/expect/greater-than-equal.d.ts +0 -32
- package/dist/expect/greater-than-equal.d.ts.map +0 -1
- package/dist/expect/greater-than-equal.js +0 -20
- package/dist/expect/greater-than-equal.js.map +0 -1
- package/dist/expect/greater-than.d.ts +0 -32
- package/dist/expect/greater-than.d.ts.map +0 -1
- package/dist/expect/greater-than.js +0 -20
- package/dist/expect/greater-than.js.map +0 -1
- package/dist/expect/has-property.d.ts +0 -36
- package/dist/expect/has-property.d.ts.map +0 -1
- package/dist/expect/has-property.js +0 -22
- package/dist/expect/has-property.js.map +0 -1
- package/dist/expect/include.d.ts +0 -25
- package/dist/expect/include.d.ts.map +0 -1
- package/dist/expect/include.js +0 -22
- package/dist/expect/include.js.map +0 -1
- package/dist/expect/instance-of-shorthand.d.ts +0 -34
- package/dist/expect/instance-of-shorthand.d.ts.map +0 -1
- package/dist/expect/instance-of-shorthand.js +0 -22
- package/dist/expect/instance-of-shorthand.js.map +0 -1
- package/dist/expect/instance-of.d.ts +0 -11
- package/dist/expect/instance-of.d.ts.map +0 -1
- package/dist/expect/instance-of.js +0 -18
- package/dist/expect/instance-of.js.map +0 -1
- package/dist/expect/keys.d.ts +0 -17
- package/dist/expect/keys.d.ts.map +0 -1
- package/dist/expect/keys.js +0 -18
- package/dist/expect/keys.js.map +0 -1
- package/dist/expect/length.d.ts +0 -28
- package/dist/expect/length.d.ts.map +0 -1
- package/dist/expect/length.js +0 -19
- package/dist/expect/length.js.map +0 -1
- package/dist/expect/less-than-equal.d.ts +0 -32
- package/dist/expect/less-than-equal.d.ts.map +0 -1
- package/dist/expect/less-than-equal.js +0 -20
- package/dist/expect/less-than-equal.js.map +0 -1
- package/dist/expect/less-than.d.ts +0 -32
- package/dist/expect/less-than.d.ts.map +0 -1
- package/dist/expect/less-than.js +0 -20
- package/dist/expect/less-than.js.map +0 -1
- package/dist/expect/match.d.ts +0 -10
- package/dist/expect/match.d.ts.map +0 -1
- package/dist/expect/match.js +0 -18
- package/dist/expect/match.js.map +0 -1
- package/dist/expect/members.d.ts +0 -20
- package/dist/expect/members.d.ts.map +0 -1
- package/dist/expect/members.js +0 -32
- package/dist/expect/members.js.map +0 -1
- package/dist/expect/reject.d.ts +0 -12
- package/dist/expect/reject.d.ts.map +0 -1
- package/dist/expect/reject.js +0 -13
- package/dist/expect/reject.js.map +0 -1
- package/dist/expect/round-to.d.ts +0 -12
- package/dist/expect/round-to.d.ts.map +0 -1
- package/dist/expect/round-to.js +0 -18
- package/dist/expect/round-to.js.map +0 -1
- package/dist/expect/start-with.d.ts +0 -12
- package/dist/expect/start-with.d.ts.map +0 -1
- package/dist/expect/start-with.js +0 -18
- package/dist/expect/start-with.js.map +0 -1
- package/dist/expect/throw.d.ts +0 -12
- package/dist/expect/throw.d.ts.map +0 -1
- package/dist/expect/throw.js +0 -13
- package/dist/expect/throw.js.map +0 -1
- package/dist/expect/type-shorthand.d.ts +0 -66
- package/dist/expect/type-shorthand.d.ts.map +0 -1
- package/dist/expect/type-shorthand.js +0 -34
- package/dist/expect/type-shorthand.js.map +0 -1
- package/dist/expect/type.d.ts +0 -10
- package/dist/expect/type.d.ts.map +0 -1
- package/dist/expect/type.js +0 -18
- package/dist/expect/type.js.map +0 -1
- package/dist/expect.d.ts +0 -33
- package/dist/expect.d.ts.map +0 -1
- package/dist/expect.js +0 -88
- package/dist/expect.js.map +0 -1
- package/dist/expect.types.d.ts.map +0 -1
- package/dist/expect.types.js.map +0 -1
- package/dist/mixins.d.ts +0 -26
- package/dist/mixins.d.ts.map +0 -1
- package/dist/mixins.js +0 -9
- package/dist/mixins.js.map +0 -1
- package/dist/utils/cast-array.d.ts +0 -2
- package/dist/utils/cast-array.d.ts.map +0 -1
- package/dist/utils/cast-array.js +0 -14
- package/dist/utils/cast-array.js.map +0 -1
- package/dist/utils/chain.d.ts +0 -3
- package/dist/utils/chain.d.ts.map +0 -1
- package/dist/utils/chain.js +0 -21
- package/dist/utils/chain.js.map +0 -1
- package/dist/utils/fail.d.ts +0 -6
- package/dist/utils/fail.d.ts.map +0 -1
- package/dist/utils/fail.js +0 -13
- package/dist/utils/fail.js.map +0 -1
- package/dist/utils/get-size.d.ts +0 -2
- package/dist/utils/get-size.d.ts.map +0 -1
- package/dist/utils/get-size.js +0 -24
- package/dist/utils/get-size.js.map +0 -1
- package/dist/utils/get-type.d.ts +0 -3
- package/dist/utils/get-type.d.ts.map +0 -1
- package/dist/utils/get-type.js +0 -17
- package/dist/utils/get-type.js.map +0 -1
- package/dist/utils/match.d.ts +0 -15
- package/dist/utils/match.d.ts.map +0 -1
- package/dist/utils/match.js +0 -150
- package/dist/utils/match.js.map +0 -1
- package/dist/utils/process-error.d.ts +0 -11
- package/dist/utils/process-error.d.ts.map +0 -1
- package/dist/utils/process-error.js +0 -98
- package/dist/utils/process-error.js.map +0 -1
- package/dist/utils/types.d.ts +0 -4
- package/dist/utils/types.d.ts.map +0 -1
- package/dist/utils/types.js +0 -3
- package/dist/utils/types.js.map +0 -1
- package/dist/utils/validate-numeric-and-dates.d.ts +0 -2
- package/dist/utils/validate-numeric-and-dates.d.ts.map +0 -1
- package/dist/utils/validate-numeric-and-dates.js +0 -15
- package/dist/utils/validate-numeric-and-dates.js.map +0 -1
- package/dist/utils/xor.d.ts +0 -2
- package/dist/utils/xor.d.ts.map +0 -1
- package/dist/utils/xor.js +0 -8
- package/dist/utils/xor.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,29 +1,575 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
1
|
+
import { any, assert_exports, createEvaluation, deepEqual, deepHasProperty, deepNotHasProperty, endsWith, equal, greaterThan, greaterThanEqual, hasKeys, hasMembers, hasProperty, hasSize, inBallpark, includes, instanceOf, isAfter, isBefore, isBetween, isEmpty, isType, lessThan, lessThanEqual, match, notAfter, notBefore, notBetween, notDeepEqual, notEndsWith, notEqual, notGreaterThan, notGreaterThanEqual, notHasKeys, notHasMembers, notHasProperty, notHasSize, notInBallpark, notIncludes, notInstanceOf, notIsEmpty, notIsType, notLessThan, notLessThanEqual, notMatch, notRejects, notRoundTo, notStartsWith, notThrows, rejects, roundTo, startsWith, throws } from "./assert-kFXp7i_B.js";
|
|
2
|
+
import { AssertionError, AssertionError as AssertionError$1, format } from "hein-assertion-utils";
|
|
3
|
+
import isPlainObject from "lodash/isPlainObject.js";
|
|
4
|
+
import omit from "lodash/omit.js";
|
|
5
|
+
import mapValues from "lodash/mapValues.js";
|
|
6
|
+
|
|
7
|
+
//#region src/mixins.ts
|
|
8
|
+
const mixins = {};
|
|
9
|
+
const use = (plugins) => {
|
|
10
|
+
Object.assign(mixins, plugins);
|
|
15
11
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/utils/chain.ts
|
|
15
|
+
const registerProperty = (object, name, value) => {
|
|
16
|
+
Object.defineProperty(object, name, {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get() {
|
|
19
|
+
return value();
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
return object;
|
|
23
|
+
};
|
|
24
|
+
const registerMethod = (object, name, value) => {
|
|
25
|
+
Object.defineProperty(object, name, { value });
|
|
26
|
+
return object;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/utils/get-size.ts
|
|
31
|
+
const getSize = (value) => {
|
|
32
|
+
if (Array.isArray(value)) return value.length;
|
|
33
|
+
if (isPlainObject(value)) return Object.keys(value).length;
|
|
34
|
+
if (value instanceof Map) return value.size;
|
|
35
|
+
if (value instanceof Set) return value.size;
|
|
36
|
+
if (typeof value === "string") return value.length;
|
|
37
|
+
return 0;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/expect/after.ts
|
|
42
|
+
use({ after: {
|
|
43
|
+
type: "method",
|
|
44
|
+
value: ({ value, inverted }) => (date) => {
|
|
45
|
+
if (inverted) notAfter(value, date);
|
|
46
|
+
else isAfter(value, date);
|
|
47
|
+
}
|
|
48
|
+
} });
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/expect/ballpark.ts
|
|
52
|
+
use({ ballpark: {
|
|
53
|
+
type: "method",
|
|
54
|
+
value: ({ value, inverted }) => (ballpark, multiplier = .1) => {
|
|
55
|
+
if (inverted) notInBallpark(value, ballpark, multiplier);
|
|
56
|
+
else inBallpark(value, ballpark, multiplier);
|
|
57
|
+
}
|
|
58
|
+
} });
|
|
59
|
+
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region src/expect/before.ts
|
|
62
|
+
use({ before: {
|
|
63
|
+
type: "method",
|
|
64
|
+
value: ({ value, inverted }) => (date) => {
|
|
65
|
+
if (inverted) notBefore(value, date);
|
|
66
|
+
else isBefore(value, date);
|
|
67
|
+
}
|
|
68
|
+
} });
|
|
69
|
+
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/expect/between.ts
|
|
72
|
+
use({ between: {
|
|
73
|
+
type: "method",
|
|
74
|
+
value: ({ value, inverted }) => (start, end, inclusive = true) => {
|
|
75
|
+
if (inverted) notBetween(value, start, end, { inclusive });
|
|
76
|
+
else isBetween(value, start, end, { inclusive });
|
|
77
|
+
}
|
|
78
|
+
} });
|
|
79
|
+
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/expect/empty.ts
|
|
82
|
+
use({ empty: {
|
|
83
|
+
type: "method",
|
|
84
|
+
value: ({ value, inverted }) => (message) => {
|
|
85
|
+
if (inverted) notIsEmpty(value, message);
|
|
86
|
+
else isEmpty(value, message);
|
|
87
|
+
}
|
|
88
|
+
} });
|
|
89
|
+
|
|
90
|
+
//#endregion
|
|
91
|
+
//#region src/expect/end-with.ts
|
|
92
|
+
use({ endWith: {
|
|
93
|
+
type: "method",
|
|
94
|
+
value: ({ value, inverted }) => (end) => {
|
|
95
|
+
if (inverted) notEndsWith(value, end);
|
|
96
|
+
else endsWith(value, end);
|
|
97
|
+
}
|
|
98
|
+
} });
|
|
99
|
+
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region src/expect/eql.ts
|
|
102
|
+
use({
|
|
103
|
+
partially: {
|
|
104
|
+
type: "property",
|
|
105
|
+
value: () => ({ partial: true })
|
|
106
|
+
},
|
|
107
|
+
eql: {
|
|
108
|
+
type: "method",
|
|
109
|
+
value: ({ value, inverted, partial }) => (other, message) => {
|
|
110
|
+
if (inverted) notDeepEqual(value, other, partial, message);
|
|
111
|
+
else deepEqual(value, other, partial, message);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
//#endregion
|
|
117
|
+
//#region src/expect/equal-shorthand.ts
|
|
118
|
+
use(Object.fromEntries(Object.entries({
|
|
119
|
+
false: false,
|
|
120
|
+
true: true
|
|
121
|
+
}).map(([key, expectValue]) => {
|
|
122
|
+
return [key, {
|
|
123
|
+
type: "method",
|
|
124
|
+
value: ({ inverted, value }) => () => {
|
|
125
|
+
if (inverted) {
|
|
126
|
+
const message = format("Expected {{= it.value }} to not be {{= it.key }}", {
|
|
127
|
+
key,
|
|
128
|
+
value
|
|
129
|
+
}, true);
|
|
130
|
+
notEqual(value, expectValue, message);
|
|
131
|
+
} else {
|
|
132
|
+
const message = format("Expected {{= it.value }} to be {{= it.key }}", {
|
|
133
|
+
key,
|
|
134
|
+
value
|
|
135
|
+
}, true);
|
|
136
|
+
equal(value, expectValue, message);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}];
|
|
140
|
+
})));
|
|
141
|
+
|
|
142
|
+
//#endregion
|
|
143
|
+
//#region src/expect/equal.ts
|
|
144
|
+
use({
|
|
145
|
+
equal: {
|
|
146
|
+
type: "method",
|
|
147
|
+
value: ({ value, inverted, deep }) => (other, message) => {
|
|
148
|
+
if (deep) {
|
|
149
|
+
if (inverted) notDeepEqual(value, other, message);
|
|
150
|
+
else deepEqual(value, other, message);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
if (inverted) notEqual(value, other, message);
|
|
154
|
+
else equal(value, other, message);
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
eq: {
|
|
158
|
+
type: "alias",
|
|
159
|
+
value: "equal"
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
//#endregion
|
|
164
|
+
//#region src/expect/excluding.ts
|
|
165
|
+
use({ excluding: {
|
|
166
|
+
type: "method",
|
|
167
|
+
value: (state) => (...keys) => {
|
|
168
|
+
return expectChain({
|
|
169
|
+
...state,
|
|
170
|
+
value: omit(state.value, keys)
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
} });
|
|
174
|
+
|
|
175
|
+
//#endregion
|
|
176
|
+
//#region src/expect/greater-than-equal.ts
|
|
177
|
+
use({
|
|
178
|
+
greaterThanOrEqual: {
|
|
179
|
+
type: "method",
|
|
180
|
+
value: ({ value, inverted }) => (other) => {
|
|
181
|
+
if (inverted) notGreaterThanEqual(value, other);
|
|
182
|
+
else greaterThanEqual(value, other);
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
gte: {
|
|
186
|
+
type: "alias",
|
|
187
|
+
value: "greaterThanOrEqual"
|
|
188
|
+
},
|
|
189
|
+
atLeast: {
|
|
190
|
+
type: "alias",
|
|
191
|
+
value: "greaterThanOrEqual"
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
//#endregion
|
|
196
|
+
//#region src/expect/greater-than.ts
|
|
197
|
+
use({
|
|
198
|
+
greaterThan: {
|
|
199
|
+
type: "method",
|
|
200
|
+
value: ({ value, inverted }) => (other) => {
|
|
201
|
+
if (inverted) notGreaterThan(value, other);
|
|
202
|
+
else greaterThan(value, other);
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
gt: {
|
|
206
|
+
type: "alias",
|
|
207
|
+
value: "greaterThan"
|
|
208
|
+
},
|
|
209
|
+
above: {
|
|
210
|
+
type: "alias",
|
|
211
|
+
value: "greaterThan"
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
//#endregion
|
|
216
|
+
//#region src/expect/has-property.ts
|
|
217
|
+
use({ property: {
|
|
218
|
+
type: "method",
|
|
219
|
+
value: ({ value, inverted, deep }) => (...args) => {
|
|
220
|
+
if (deep) {
|
|
221
|
+
if (inverted) return deepNotHasProperty(value, ...args);
|
|
222
|
+
return deepHasProperty(value, ...args);
|
|
223
|
+
}
|
|
224
|
+
if (inverted) return notHasProperty(value, ...args);
|
|
225
|
+
return hasProperty(value, ...args);
|
|
226
|
+
}
|
|
227
|
+
} });
|
|
228
|
+
|
|
229
|
+
//#endregion
|
|
230
|
+
//#region src/expect/include.ts
|
|
231
|
+
use({
|
|
232
|
+
include: {
|
|
233
|
+
type: "method",
|
|
234
|
+
value: ({ value, inverted }) => (...elements) => {
|
|
235
|
+
if (inverted) notIncludes(value, ...elements);
|
|
236
|
+
else includes(value, ...elements);
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
contain: {
|
|
240
|
+
type: "alias",
|
|
241
|
+
value: "include"
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
//#endregion
|
|
246
|
+
//#region src/expect/instance-of-shorthand.ts
|
|
247
|
+
const constructors = [
|
|
248
|
+
Date,
|
|
249
|
+
Map,
|
|
250
|
+
Set,
|
|
251
|
+
WeakMap,
|
|
252
|
+
WeakSet
|
|
253
|
+
];
|
|
254
|
+
use(Object.fromEntries(constructors.map((constructor) => {
|
|
255
|
+
return [constructor.name, {
|
|
256
|
+
type: "method",
|
|
257
|
+
value: ({ inverted, value }) => () => {
|
|
258
|
+
if (inverted) notInstanceOf(value, constructor);
|
|
259
|
+
else instanceOf(value, constructor);
|
|
260
|
+
}
|
|
261
|
+
}];
|
|
262
|
+
})));
|
|
263
|
+
|
|
264
|
+
//#endregion
|
|
265
|
+
//#region src/expect/instance-of.ts
|
|
266
|
+
use({ instanceOf: {
|
|
267
|
+
type: "method",
|
|
268
|
+
value: ({ value, inverted }) => (constructor) => {
|
|
269
|
+
if (inverted) notInstanceOf(value, constructor);
|
|
270
|
+
else instanceOf(value, constructor);
|
|
271
|
+
}
|
|
272
|
+
} });
|
|
273
|
+
|
|
274
|
+
//#endregion
|
|
275
|
+
//#region src/expect/keys.ts
|
|
276
|
+
use({ keys: {
|
|
277
|
+
type: "method",
|
|
278
|
+
value: ({ value, inverted }) => (keys) => {
|
|
279
|
+
if (inverted) notHasKeys(value, keys);
|
|
280
|
+
else hasKeys(value, keys);
|
|
281
|
+
}
|
|
282
|
+
} });
|
|
283
|
+
|
|
284
|
+
//#endregion
|
|
285
|
+
//#region src/expect/length.ts
|
|
286
|
+
use({
|
|
287
|
+
sizeOf: {
|
|
288
|
+
type: "alias",
|
|
289
|
+
value: "lengthOf"
|
|
290
|
+
},
|
|
291
|
+
lengthOf: {
|
|
292
|
+
type: "method",
|
|
293
|
+
value: ({ value, inverted }) => (length, message) => {
|
|
294
|
+
if (inverted) notHasSize(value, length, message);
|
|
295
|
+
else hasSize(value, length, message);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
//#endregion
|
|
301
|
+
//#region src/expect/less-than-equal.ts
|
|
302
|
+
use({
|
|
303
|
+
lessThanOrEqual: {
|
|
304
|
+
type: "method",
|
|
305
|
+
value: ({ value, inverted }) => (other) => {
|
|
306
|
+
if (inverted) notLessThanEqual(value, other);
|
|
307
|
+
else lessThanEqual(value, other);
|
|
308
|
+
}
|
|
309
|
+
},
|
|
310
|
+
lte: {
|
|
311
|
+
type: "alias",
|
|
312
|
+
value: "lessThanOrEqual"
|
|
313
|
+
},
|
|
314
|
+
atMost: {
|
|
315
|
+
type: "alias",
|
|
316
|
+
value: "lessThanOrEqual"
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
//#endregion
|
|
321
|
+
//#region src/expect/less-than.ts
|
|
322
|
+
use({
|
|
323
|
+
lessThan: {
|
|
324
|
+
type: "method",
|
|
325
|
+
value: ({ value, inverted }) => (other) => {
|
|
326
|
+
if (inverted) notLessThan(value, other);
|
|
327
|
+
else lessThan(value, other);
|
|
328
|
+
}
|
|
329
|
+
},
|
|
330
|
+
lt: {
|
|
331
|
+
type: "alias",
|
|
332
|
+
value: "lessThan"
|
|
333
|
+
},
|
|
334
|
+
below: {
|
|
335
|
+
type: "alias",
|
|
336
|
+
value: "lessThan"
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
//#endregion
|
|
341
|
+
//#region src/expect/match.ts
|
|
342
|
+
use({ match: {
|
|
343
|
+
type: "method",
|
|
344
|
+
value: ({ value, inverted }) => (regex) => {
|
|
345
|
+
if (inverted) notMatch(value, regex);
|
|
346
|
+
else match(value, regex);
|
|
347
|
+
}
|
|
348
|
+
} });
|
|
349
|
+
|
|
350
|
+
//#endregion
|
|
351
|
+
//#region src/expect/members.ts
|
|
352
|
+
use({
|
|
353
|
+
members: {
|
|
354
|
+
type: "method",
|
|
355
|
+
value: ({ value, inverted, same, deep, ordered, partial }) => (other, message) => {
|
|
356
|
+
if (inverted) notHasMembers(value, other, {
|
|
357
|
+
deep,
|
|
358
|
+
same,
|
|
359
|
+
ordered,
|
|
360
|
+
partial
|
|
361
|
+
}, message);
|
|
362
|
+
else hasMembers(value, other, {
|
|
363
|
+
deep,
|
|
364
|
+
same,
|
|
365
|
+
ordered,
|
|
366
|
+
partial
|
|
367
|
+
}, message);
|
|
368
|
+
}
|
|
369
|
+
},
|
|
370
|
+
same: {
|
|
371
|
+
type: "property",
|
|
372
|
+
value: (state) => {
|
|
373
|
+
state.same = true;
|
|
374
|
+
return state;
|
|
375
|
+
}
|
|
376
|
+
},
|
|
377
|
+
ordered: {
|
|
378
|
+
type: "property",
|
|
379
|
+
value: (state) => {
|
|
380
|
+
state.ordered = true;
|
|
381
|
+
return state;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
//#endregion
|
|
387
|
+
//#region src/expect/reject.ts
|
|
388
|
+
use({ reject: {
|
|
389
|
+
type: "method",
|
|
390
|
+
value: ({ value, inverted }) => (...args) => {
|
|
391
|
+
return inverted ? notRejects(value, ...args) : rejects(value, ...args);
|
|
392
|
+
}
|
|
393
|
+
} });
|
|
394
|
+
|
|
395
|
+
//#endregion
|
|
396
|
+
//#region src/expect/round-to.ts
|
|
397
|
+
use({ roundTo: {
|
|
398
|
+
type: "method",
|
|
399
|
+
value: ({ value, inverted }) => (target, decimal = 0) => {
|
|
400
|
+
if (inverted) notRoundTo(value, target, decimal);
|
|
401
|
+
else roundTo(value, target, decimal);
|
|
402
|
+
}
|
|
403
|
+
} });
|
|
404
|
+
|
|
405
|
+
//#endregion
|
|
406
|
+
//#region src/expect/start-with.ts
|
|
407
|
+
use({ startWith: {
|
|
408
|
+
type: "method",
|
|
409
|
+
value: ({ value, inverted }) => (start) => {
|
|
410
|
+
if (inverted) notStartsWith(value, start);
|
|
411
|
+
else startsWith(value, start);
|
|
412
|
+
}
|
|
413
|
+
} });
|
|
414
|
+
|
|
415
|
+
//#endregion
|
|
416
|
+
//#region src/expect/throw.ts
|
|
417
|
+
use({ throw: {
|
|
418
|
+
type: "method",
|
|
419
|
+
value: ({ value, inverted }) => (...args) => {
|
|
420
|
+
return inverted ? notThrows(value, ...args) : throws(value, ...args);
|
|
421
|
+
}
|
|
422
|
+
} });
|
|
423
|
+
|
|
424
|
+
//#endregion
|
|
425
|
+
//#region src/expect/type-shorthand.ts
|
|
426
|
+
use(Object.fromEntries([
|
|
427
|
+
"NaN",
|
|
428
|
+
"array",
|
|
429
|
+
"bigint",
|
|
430
|
+
"boolean",
|
|
431
|
+
"function",
|
|
432
|
+
"null",
|
|
433
|
+
"number",
|
|
434
|
+
"object",
|
|
435
|
+
"string",
|
|
436
|
+
"symbol",
|
|
437
|
+
"undefined"
|
|
438
|
+
].map((type) => {
|
|
439
|
+
return [type, {
|
|
440
|
+
type: "method",
|
|
441
|
+
value: ({ value, inverted }) => () => {
|
|
442
|
+
if (inverted) notIsType(value, type);
|
|
443
|
+
else isType(value, type);
|
|
444
|
+
}
|
|
445
|
+
}];
|
|
446
|
+
})));
|
|
447
|
+
|
|
448
|
+
//#endregion
|
|
449
|
+
//#region src/expect/type.ts
|
|
450
|
+
use({ type: {
|
|
451
|
+
type: "method",
|
|
452
|
+
value: ({ value, inverted }) => (type) => {
|
|
453
|
+
if (inverted) notIsType(value, type);
|
|
454
|
+
else isType(value, type);
|
|
455
|
+
}
|
|
456
|
+
} });
|
|
457
|
+
|
|
458
|
+
//#endregion
|
|
459
|
+
//#region src/utils/fail.ts
|
|
460
|
+
/**
|
|
461
|
+
* Throw an AssertionError
|
|
462
|
+
* @param {string} message - The message to pass to the AssertionError
|
|
463
|
+
*/
|
|
464
|
+
const fail = (message = "Fail") => {
|
|
465
|
+
throw new AssertionError$1(void 0, void 0, message);
|
|
466
|
+
};
|
|
467
|
+
|
|
468
|
+
//#endregion
|
|
469
|
+
//#region src/expect.ts
|
|
470
|
+
use({
|
|
471
|
+
to: {
|
|
472
|
+
type: "property",
|
|
473
|
+
value: () => null
|
|
474
|
+
},
|
|
475
|
+
be: {
|
|
476
|
+
type: "property",
|
|
477
|
+
value: () => null
|
|
478
|
+
},
|
|
479
|
+
a: {
|
|
480
|
+
type: "property",
|
|
481
|
+
value: () => null
|
|
482
|
+
},
|
|
483
|
+
an: {
|
|
484
|
+
type: "property",
|
|
485
|
+
value: () => null
|
|
486
|
+
},
|
|
487
|
+
and: {
|
|
488
|
+
type: "property",
|
|
489
|
+
value: ({ value, every,...rest }) => {
|
|
490
|
+
const values = mapValues(rest, () => {});
|
|
491
|
+
return {
|
|
492
|
+
value,
|
|
493
|
+
every,
|
|
494
|
+
...values
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
},
|
|
498
|
+
have: {
|
|
499
|
+
type: "property",
|
|
500
|
+
value: () => null
|
|
501
|
+
},
|
|
502
|
+
in: {
|
|
503
|
+
type: "property",
|
|
504
|
+
value: () => null
|
|
505
|
+
},
|
|
506
|
+
not: {
|
|
507
|
+
type: "property",
|
|
508
|
+
value: (state) => ({
|
|
509
|
+
...state,
|
|
510
|
+
inverted: !state.inverted
|
|
511
|
+
})
|
|
512
|
+
},
|
|
513
|
+
of: {
|
|
514
|
+
type: "property",
|
|
515
|
+
value: () => null
|
|
516
|
+
},
|
|
517
|
+
length: {
|
|
518
|
+
type: "property",
|
|
519
|
+
value: (state) => ({
|
|
520
|
+
...state,
|
|
521
|
+
getProperty: getSize
|
|
522
|
+
})
|
|
523
|
+
},
|
|
524
|
+
deep: {
|
|
525
|
+
type: "property",
|
|
526
|
+
value: (state) => ({
|
|
527
|
+
...state,
|
|
528
|
+
deep: true
|
|
529
|
+
})
|
|
530
|
+
},
|
|
531
|
+
every: {
|
|
532
|
+
type: "property",
|
|
533
|
+
value: (state) => ({
|
|
534
|
+
...state,
|
|
535
|
+
every: true
|
|
536
|
+
})
|
|
537
|
+
}
|
|
538
|
+
});
|
|
539
|
+
const expectChain = (state) => {
|
|
540
|
+
const chain = {};
|
|
541
|
+
for (const [key, v] of Object.entries(mixins)) {
|
|
542
|
+
const definition = v.type === "alias" ? mixins[v.value] : v;
|
|
543
|
+
if (definition.type === "property") registerProperty(chain, key, () => {
|
|
544
|
+
const newState = definition.value(state);
|
|
545
|
+
return expectChain({
|
|
546
|
+
...state,
|
|
547
|
+
...newState
|
|
548
|
+
});
|
|
549
|
+
});
|
|
550
|
+
else if (definition.type === "method") registerMethod(chain, key, (...args) => {
|
|
551
|
+
if (state.getProperty) definition.value({
|
|
552
|
+
value: state.getProperty(state.value),
|
|
553
|
+
inverted: state.inverted
|
|
554
|
+
})(...args);
|
|
555
|
+
else if (state.every) for (const value of state.value) definition.value({
|
|
556
|
+
...state,
|
|
557
|
+
value
|
|
558
|
+
})(...args);
|
|
559
|
+
else {
|
|
560
|
+
const result = definition.value({ ...state })(...args);
|
|
561
|
+
if (result) return result;
|
|
562
|
+
}
|
|
563
|
+
return expectChain(state);
|
|
564
|
+
});
|
|
565
|
+
}
|
|
566
|
+
return chain;
|
|
567
|
+
};
|
|
568
|
+
const expect = ((actual) => {
|
|
569
|
+
return expectChain({ value: actual });
|
|
570
|
+
});
|
|
571
|
+
expect.fail = fail;
|
|
572
|
+
|
|
573
|
+
//#endregion
|
|
574
|
+
export { AssertionError, any, assert_exports as assert, createEvaluation, expect, expectChain, fail, use };
|
|
29
575
|
//# sourceMappingURL=index.js.map
|