bupkis 0.7.2 → 0.8.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 +7 -0
- package/dist/commonjs/assertion/assertion.d.ts +0 -13
- package/dist/commonjs/assertion/assertion.d.ts.map +1 -1
- package/dist/commonjs/assertion/assertion.js +42 -27
- package/dist/commonjs/assertion/assertion.js.map +1 -1
- package/dist/commonjs/assertion/create.d.ts +2 -0
- package/dist/commonjs/assertion/create.d.ts.map +1 -1
- package/dist/commonjs/assertion/create.js +7 -4
- package/dist/commonjs/assertion/create.js.map +1 -1
- package/dist/commonjs/assertion/impl/assertion-util.d.ts +2 -0
- package/dist/commonjs/assertion/impl/assertion-util.d.ts.map +1 -1
- package/dist/commonjs/assertion/impl/assertion-util.js +13 -2
- package/dist/commonjs/assertion/impl/assertion-util.js.map +1 -1
- package/dist/commonjs/assertion/impl/sync-basic.d.ts.map +1 -1
- package/dist/commonjs/assertion/impl/sync-basic.js +2 -3
- package/dist/commonjs/assertion/impl/sync-basic.js.map +1 -1
- package/dist/commonjs/assertion/impl/sync-collection.d.ts.map +1 -1
- package/dist/commonjs/assertion/impl/sync-collection.js +24 -14
- package/dist/commonjs/assertion/impl/sync-collection.js.map +1 -1
- package/dist/commonjs/assertion/impl/sync-esoteric.d.ts +1 -5
- package/dist/commonjs/assertion/impl/sync-esoteric.d.ts.map +1 -1
- package/dist/commonjs/assertion/impl/sync-esoteric.js +11 -13
- package/dist/commonjs/assertion/impl/sync-esoteric.js.map +1 -1
- package/dist/commonjs/assertion/impl/sync-parametric.d.ts.map +1 -1
- package/dist/commonjs/assertion/impl/sync-parametric.js +4 -2
- package/dist/commonjs/assertion/impl/sync-parametric.js.map +1 -1
- package/dist/commonjs/assertion/impl/sync.d.ts +2 -10
- package/dist/commonjs/assertion/impl/sync.d.ts.map +1 -1
- package/dist/commonjs/assertion/slotify.d.ts +1 -0
- package/dist/commonjs/assertion/slotify.d.ts.map +1 -1
- package/dist/commonjs/assertion/slotify.js +1 -0
- package/dist/commonjs/assertion/slotify.js.map +1 -1
- package/dist/commonjs/bootstrap.d.ts +1 -5
- package/dist/commonjs/bootstrap.d.ts.map +1 -1
- package/dist/commonjs/bootstrap.js +1 -0
- package/dist/commonjs/bootstrap.js.map +1 -1
- package/dist/commonjs/diff.d.ts +51 -0
- package/dist/commonjs/diff.d.ts.map +1 -0
- package/dist/commonjs/diff.js +279 -0
- package/dist/commonjs/diff.js.map +1 -0
- package/dist/commonjs/error.d.ts +17 -0
- package/dist/commonjs/error.d.ts.map +1 -1
- package/dist/commonjs/error.js +17 -7
- package/dist/commonjs/error.js.map +1 -1
- package/dist/commonjs/expect.d.ts.map +1 -1
- package/dist/commonjs/expect.js +13 -0
- package/dist/commonjs/expect.js.map +1 -1
- package/dist/commonjs/guards.d.ts +12 -8
- package/dist/commonjs/guards.d.ts.map +1 -1
- package/dist/commonjs/guards.js +24 -14
- package/dist/commonjs/guards.js.map +1 -1
- package/dist/commonjs/index.d.ts +1 -5
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/schema.d.ts.map +1 -1
- package/dist/commonjs/schema.js +3 -2
- package/dist/commonjs/schema.js.map +1 -1
- package/dist/commonjs/use.js +22 -8
- package/dist/commonjs/use.js.map +1 -1
- package/dist/commonjs/util.d.ts +1 -0
- package/dist/commonjs/util.d.ts.map +1 -1
- package/dist/commonjs/util.js +14 -10
- package/dist/commonjs/util.js.map +1 -1
- package/dist/commonjs/value-to-schema.d.ts +1 -0
- package/dist/commonjs/value-to-schema.d.ts.map +1 -1
- package/dist/commonjs/value-to-schema.js +17 -10
- package/dist/commonjs/value-to-schema.js.map +1 -1
- package/dist/esm/assertion/assertion.d.ts +0 -13
- package/dist/esm/assertion/assertion.d.ts.map +1 -1
- package/dist/esm/assertion/assertion.js +42 -27
- package/dist/esm/assertion/assertion.js.map +1 -1
- package/dist/esm/assertion/create.d.ts +2 -0
- package/dist/esm/assertion/create.d.ts.map +1 -1
- package/dist/esm/assertion/create.js +7 -4
- package/dist/esm/assertion/create.js.map +1 -1
- package/dist/esm/assertion/impl/assertion-util.d.ts +2 -0
- package/dist/esm/assertion/impl/assertion-util.d.ts.map +1 -1
- package/dist/esm/assertion/impl/assertion-util.js +13 -2
- package/dist/esm/assertion/impl/assertion-util.js.map +1 -1
- package/dist/esm/assertion/impl/sync-basic.d.ts.map +1 -1
- package/dist/esm/assertion/impl/sync-basic.js +2 -3
- package/dist/esm/assertion/impl/sync-basic.js.map +1 -1
- package/dist/esm/assertion/impl/sync-collection.d.ts.map +1 -1
- package/dist/esm/assertion/impl/sync-collection.js +24 -14
- package/dist/esm/assertion/impl/sync-collection.js.map +1 -1
- package/dist/esm/assertion/impl/sync-esoteric.d.ts +1 -5
- package/dist/esm/assertion/impl/sync-esoteric.d.ts.map +1 -1
- package/dist/esm/assertion/impl/sync-esoteric.js +11 -13
- package/dist/esm/assertion/impl/sync-esoteric.js.map +1 -1
- package/dist/esm/assertion/impl/sync-parametric.d.ts.map +1 -1
- package/dist/esm/assertion/impl/sync-parametric.js +4 -2
- package/dist/esm/assertion/impl/sync-parametric.js.map +1 -1
- package/dist/esm/assertion/impl/sync.d.ts +2 -10
- package/dist/esm/assertion/impl/sync.d.ts.map +1 -1
- package/dist/esm/assertion/slotify.d.ts +1 -0
- package/dist/esm/assertion/slotify.d.ts.map +1 -1
- package/dist/esm/assertion/slotify.js +1 -0
- package/dist/esm/assertion/slotify.js.map +1 -1
- package/dist/esm/bootstrap.d.ts +1 -5
- package/dist/esm/bootstrap.d.ts.map +1 -1
- package/dist/esm/bootstrap.js +1 -0
- package/dist/esm/bootstrap.js.map +1 -1
- package/dist/esm/diff.d.ts +51 -0
- package/dist/esm/diff.d.ts.map +1 -0
- package/dist/esm/diff.js +273 -0
- package/dist/esm/diff.js.map +1 -0
- package/dist/esm/error.d.ts +17 -0
- package/dist/esm/error.d.ts.map +1 -1
- package/dist/esm/error.js +17 -7
- package/dist/esm/error.js.map +1 -1
- package/dist/esm/expect.d.ts.map +1 -1
- package/dist/esm/expect.js +13 -0
- package/dist/esm/expect.js.map +1 -1
- package/dist/esm/guards.d.ts +12 -8
- package/dist/esm/guards.d.ts.map +1 -1
- package/dist/esm/guards.js +23 -12
- package/dist/esm/guards.js.map +1 -1
- package/dist/esm/index.d.ts +1 -5
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/schema.d.ts.map +1 -1
- package/dist/esm/schema.js +3 -2
- package/dist/esm/schema.js.map +1 -1
- package/dist/esm/use.js +19 -6
- package/dist/esm/use.js.map +1 -1
- package/dist/esm/util.d.ts +1 -0
- package/dist/esm/util.d.ts.map +1 -1
- package/dist/esm/util.js +14 -10
- package/dist/esm/util.js.map +1 -1
- package/dist/esm/value-to-schema.d.ts +1 -0
- package/dist/esm/value-to-schema.d.ts.map +1 -1
- package/dist/esm/value-to-schema.js +17 -10
- package/dist/esm/value-to-schema.js.map +1 -1
- package/package.json +22 -6
- package/src/assertion/assertion.ts +47 -28
- package/src/assertion/create.ts +8 -8
- package/src/assertion/impl/assertion-util.ts +27 -16
- package/src/assertion/impl/sync-basic.ts +3 -3
- package/src/assertion/impl/sync-collection.ts +34 -14
- package/src/assertion/impl/sync-esoteric.ts +17 -13
- package/src/assertion/impl/sync-parametric.ts +5 -2
- package/src/assertion/slotify.ts +1 -0
- package/src/bootstrap.ts +1 -0
- package/src/diff.ts +343 -0
- package/src/error.ts +35 -7
- package/src/expect.ts +13 -0
- package/src/guards.ts +27 -15
- package/src/schema.ts +4 -2
- package/src/use.ts +21 -7
- package/src/util.ts +15 -12
- package/src/value-to-schema.ts +18 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"value-to-schema.js","sourceRoot":"","sources":["../../src/value-to-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EACL,kB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AAC,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,CAAC,EAChD;wBACE,OAAO,EAAE,iDAAiD;qBAC3D,CACF,CAAC;gBACJ,CAAC;gBAED,OAAO,UAAU,CAAC;YACpB,CAAC;YAED,gDAAgD;YAChD,OAAO,CAAC,CAAC,MAAM,CACb,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,EAChD,EAAE,OAAO,EAAE,oBAAoB,EAAE,CAClC,CAAC;QACJ,CAAC;gBAAS,CAAC;YACT,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACxB,CAAC;IACH,CAAC;IAED,6BAA6B;IAC7B,OAAO,CAAC,CAAC,OAAO,EAAE,CAAC;AACrB,CAAC,CAAC;AAsEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,MAAM,CAAC;IACrD,mBAAmB,EAAE,IAAI;IACzB,iBAAiB,EAAE,IAAI;IACvB,aAAa,EAAE,KAAK;IACpB,aAAa,EAAE,IAAI;IACnB,MAAM,EAAE,KAAK;CACL,CAAgC,CAAC;AAE3C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,MAAM,CAAC;IACrD,mBAAmB,EAAE,IAAI;IACzB,iBAAiB,EAAE,IAAI;IACvB,aAAa,EAAE,IAAI;IACnB,aAAa,EAAE,IAAI;IACnB,MAAM,EAAE,IAAI;CACJ,CAAgC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bupkis",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Uncommonly extensible assertions for the beautiful people",
|
|
6
6
|
"repository": {
|
|
@@ -79,6 +79,16 @@
|
|
|
79
79
|
"types": "./dist/commonjs/index.d.ts",
|
|
80
80
|
"default": "./dist/commonjs/index.js"
|
|
81
81
|
}
|
|
82
|
+
},
|
|
83
|
+
"./diff": {
|
|
84
|
+
"import": {
|
|
85
|
+
"types": "./dist/esm/diff.d.ts",
|
|
86
|
+
"default": "./dist/esm/diff.js"
|
|
87
|
+
},
|
|
88
|
+
"require": {
|
|
89
|
+
"types": "./dist/commonjs/diff.d.ts",
|
|
90
|
+
"default": "./dist/commonjs/diff.js"
|
|
91
|
+
}
|
|
82
92
|
}
|
|
83
93
|
},
|
|
84
94
|
"files": [
|
|
@@ -138,6 +148,7 @@
|
|
|
138
148
|
},
|
|
139
149
|
"dependencies": {
|
|
140
150
|
"debug": "^4.4.1",
|
|
151
|
+
"jest-diff": "30.1.2",
|
|
141
152
|
"set.prototype.difference": "^1.1.7",
|
|
142
153
|
"set.prototype.intersection": "^1.1.7",
|
|
143
154
|
"set.prototype.isdisjointfrom": "^1.1.5",
|
|
@@ -158,6 +169,8 @@
|
|
|
158
169
|
"@types/node": "24.5.2",
|
|
159
170
|
"@types/slug": "5.0.9",
|
|
160
171
|
"@types/wallabyjs": "0.0.15",
|
|
172
|
+
"@typescript-eslint/typescript-estree": "8.44.1",
|
|
173
|
+
"@typescript-eslint/utils": "8.44.1",
|
|
161
174
|
"c8": "10.1.3",
|
|
162
175
|
"cspell": "9.2.1",
|
|
163
176
|
"escape-string-regexp": "5.0.0",
|
|
@@ -168,8 +181,8 @@
|
|
|
168
181
|
"fast-check": "4.3.0",
|
|
169
182
|
"globals": "16.4.0",
|
|
170
183
|
"husky": "9.1.7",
|
|
171
|
-
"knip": "5.
|
|
172
|
-
"lint-staged": "16.
|
|
184
|
+
"knip": "5.64.0",
|
|
185
|
+
"lint-staged": "16.2.0",
|
|
173
186
|
"markdownlint-cli2": "0.18.1",
|
|
174
187
|
"markdownlint-cli2-formatter-pretty": "0.0.8",
|
|
175
188
|
"npm-run-all2": "8.0.4",
|
|
@@ -182,7 +195,7 @@
|
|
|
182
195
|
"tsx": "4.20.5",
|
|
183
196
|
"type-fest": "4.41.0",
|
|
184
197
|
"typedoc": "0.28.13",
|
|
185
|
-
"typedoc-plugin-dt-links": "2.0.
|
|
198
|
+
"typedoc-plugin-dt-links": "2.0.20",
|
|
186
199
|
"typedoc-plugin-extras": "4.0.1",
|
|
187
200
|
"typedoc-plugin-mdn-links": "5.0.9",
|
|
188
201
|
"typedoc-plugin-redirect": "1.2.0",
|
|
@@ -212,6 +225,7 @@
|
|
|
212
225
|
"node": {
|
|
213
226
|
"entry": [
|
|
214
227
|
"scripts/*.js",
|
|
228
|
+
"scripts/*.ts",
|
|
215
229
|
"test/**/*.test.ts",
|
|
216
230
|
"test/types.types-test.ts",
|
|
217
231
|
"src/assertion/index.ts",
|
|
@@ -219,7 +233,8 @@
|
|
|
219
233
|
"src/types.ts",
|
|
220
234
|
"src/util.ts",
|
|
221
235
|
"src/schema.ts",
|
|
222
|
-
"src/guards.ts"
|
|
236
|
+
"src/guards.ts",
|
|
237
|
+
"src/diff.ts"
|
|
223
238
|
]
|
|
224
239
|
}
|
|
225
240
|
},
|
|
@@ -258,7 +273,8 @@
|
|
|
258
273
|
"./schema": "./src/schema.ts",
|
|
259
274
|
"./guards": "./src/guards.ts",
|
|
260
275
|
"./assertions": "./src/assertion/index.ts",
|
|
261
|
-
".": "./src/index.ts"
|
|
276
|
+
".": "./src/index.ts",
|
|
277
|
+
"./diff": "./src/diff.ts"
|
|
262
278
|
}
|
|
263
279
|
}
|
|
264
280
|
}
|
|
@@ -16,6 +16,11 @@ import { inspect } from 'util';
|
|
|
16
16
|
import { z } from 'zod/v4';
|
|
17
17
|
|
|
18
18
|
import { kStringLiteral } from '../constant.js';
|
|
19
|
+
import {
|
|
20
|
+
extractDiffValues,
|
|
21
|
+
generateDiff,
|
|
22
|
+
shouldGenerateDiff,
|
|
23
|
+
} from '../diff.js';
|
|
19
24
|
import { AssertionError, InvalidMetadataError } from '../error.js';
|
|
20
25
|
import { BupkisRegistry } from '../metadata.js';
|
|
21
26
|
import {
|
|
@@ -29,6 +34,7 @@ import {
|
|
|
29
34
|
} from './assertion-types.js';
|
|
30
35
|
|
|
31
36
|
const debug = createDebug('bupkis:assertion');
|
|
37
|
+
const { hasOwn, keys } = Object;
|
|
32
38
|
|
|
33
39
|
/**
|
|
34
40
|
* Modified charmap for {@link slug} to use underscores to replace hyphens (`-`;
|
|
@@ -75,6 +81,14 @@ export abstract class BupkisAssertion<
|
|
|
75
81
|
* @returns String representation
|
|
76
82
|
*/
|
|
77
83
|
public toString(): string {
|
|
84
|
+
/**
|
|
85
|
+
* Expands a Zod type into a human-readable string representation.
|
|
86
|
+
*
|
|
87
|
+
* @function
|
|
88
|
+
* @param zodType The Zod type to expand
|
|
89
|
+
* @param wrapCurlies Whether to wrap the result in curly braces
|
|
90
|
+
* @returns String representation of the Zod type
|
|
91
|
+
*/
|
|
78
92
|
const expand = (
|
|
79
93
|
zodType: z.core.$ZodType | z.ZodType,
|
|
80
94
|
wrapCurlies = false,
|
|
@@ -107,7 +121,7 @@ export abstract class BupkisAssertion<
|
|
|
107
121
|
repr = `{${expand((def as z.core.$ZodDefaultDef).innerType)}}`;
|
|
108
122
|
break;
|
|
109
123
|
case 'enum':
|
|
110
|
-
repr = `${
|
|
124
|
+
repr = `${keys((def as z.core.$ZodEnumDef<any>).entries as Record<PropertyKey, unknown>).join(' / ')}`;
|
|
111
125
|
break;
|
|
112
126
|
case 'intersection':
|
|
113
127
|
repr = `${expand((def as z.core.$ZodIntersectionDef<z.core.$ZodType>).left)} & ${expand((def as z.core.$ZodIntersectionDef<z.core.$ZodType>).right)}`;
|
|
@@ -154,26 +168,13 @@ export abstract class BupkisAssertion<
|
|
|
154
168
|
};
|
|
155
169
|
return `"${this.slots
|
|
156
170
|
.map((slot) =>
|
|
157
|
-
|
|
171
|
+
hasOwn(BupkisRegistry.get(slot) ?? {}, kStringLiteral)
|
|
158
172
|
? expand(slot)
|
|
159
173
|
: expand(slot, true),
|
|
160
174
|
)
|
|
161
175
|
.join(' ')}"`;
|
|
162
176
|
}
|
|
163
177
|
|
|
164
|
-
/**
|
|
165
|
-
* Translates a {@link z.ZodError} into an {@link AssertionError} with a
|
|
166
|
-
* human-friendly message.
|
|
167
|
-
*
|
|
168
|
-
* @remarks
|
|
169
|
-
* This does not handle parameterized assertions with more than one parameter
|
|
170
|
-
* too cleanly; it's unclear how a test runner would display the expected
|
|
171
|
-
* values. This will probably need a fix in the future.
|
|
172
|
-
* @param stackStartFn The function to start the stack trace from
|
|
173
|
-
* @param zodError The original `ZodError`
|
|
174
|
-
* @param values Values which caused the error
|
|
175
|
-
* @returns New `AssertionError`
|
|
176
|
-
*/
|
|
177
178
|
/**
|
|
178
179
|
* Translates a {@link z.ZodError} into an {@link AssertionError} with a
|
|
179
180
|
* human-friendly message.
|
|
@@ -192,22 +193,40 @@ export abstract class BupkisAssertion<
|
|
|
192
193
|
stackStartFn: (...args: any[]) => any,
|
|
193
194
|
values: ParsedValues<Parts>,
|
|
194
195
|
): AssertionError {
|
|
195
|
-
|
|
196
|
+
// Extract the subject (first value) from parsed values for diff generation
|
|
197
|
+
const subject = values.length > 0 ? values[0] : undefined;
|
|
196
198
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
pretty += `; ${keypath}: ${(errors as unknown[]).join('; ')}`;
|
|
200
|
-
}
|
|
199
|
+
// Try to extract meaningful actual/expected values for Node.js diff
|
|
200
|
+
const { actual, expected } = extractDiffValues(zodError, subject);
|
|
201
201
|
|
|
202
|
-
|
|
202
|
+
// Only use custom message if we could extract diff values
|
|
203
|
+
if (shouldGenerateDiff(actual, expected)) {
|
|
204
|
+
// Use jest-diff to generate rich, colored diff output
|
|
205
|
+
const diffOutput = generateDiff(expected, actual, {
|
|
206
|
+
aAnnotation: 'Expected',
|
|
207
|
+
bAnnotation: 'Received',
|
|
208
|
+
expand: false,
|
|
209
|
+
includeChangeCounts: true,
|
|
210
|
+
});
|
|
203
211
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
212
|
+
const message = diffOutput
|
|
213
|
+
? `Assertion ${this} failed:\n${diffOutput}`
|
|
214
|
+
: `Assertion ${this} failed: values are not equal`;
|
|
215
|
+
|
|
216
|
+
return new AssertionError({
|
|
217
|
+
actual,
|
|
218
|
+
expected,
|
|
219
|
+
message,
|
|
220
|
+
stackStartFn,
|
|
221
|
+
});
|
|
222
|
+
} else {
|
|
223
|
+
// Fall back to Zod's prettified error message
|
|
224
|
+
const pretty = z.prettifyError(zodError).slice(2);
|
|
225
|
+
return new AssertionError({
|
|
226
|
+
message: `Assertion ${this} failed:\n${pretty}`,
|
|
227
|
+
stackStartFn,
|
|
228
|
+
});
|
|
229
|
+
}
|
|
211
230
|
}
|
|
212
231
|
|
|
213
232
|
protected maybeParseValuesArgMismatch<Args extends readonly unknown[]>(
|
package/src/assertion/create.ts
CHANGED
|
@@ -93,9 +93,12 @@ import {
|
|
|
93
93
|
import { AssertionMetadataRegistry } from './assertion.js';
|
|
94
94
|
import { slotify } from './slotify.js';
|
|
95
95
|
|
|
96
|
+
const { isArray } = Array;
|
|
97
|
+
|
|
96
98
|
/**
|
|
97
99
|
* {@inheritDoc CreateAssertionFn}
|
|
98
100
|
*
|
|
101
|
+
* @function
|
|
99
102
|
* @throws {TypeError} Invalid assertion implementation type
|
|
100
103
|
* @group Assertion Creation
|
|
101
104
|
*/
|
|
@@ -107,7 +110,7 @@ export const createAssertion: CreateAssertionFn = <
|
|
|
107
110
|
impl: Impl,
|
|
108
111
|
metadata?: AssertionMetadata,
|
|
109
112
|
) => {
|
|
110
|
-
if (!
|
|
113
|
+
if (!isArray(parts)) {
|
|
111
114
|
throw new AssertionImplementationError('First parameter must be an array');
|
|
112
115
|
}
|
|
113
116
|
if (parts.length === 0) {
|
|
@@ -116,9 +119,7 @@ export const createAssertion: CreateAssertionFn = <
|
|
|
116
119
|
);
|
|
117
120
|
}
|
|
118
121
|
if (
|
|
119
|
-
!parts.every(
|
|
120
|
-
(part) => isString(part) || Array.isArray(part) || isZodType(part),
|
|
121
|
-
)
|
|
122
|
+
!parts.every((part) => isString(part) || isArray(part) || isZodType(part))
|
|
122
123
|
) {
|
|
123
124
|
throw new AssertionImplementationError(
|
|
124
125
|
'All assertion parts must be strings or Zod schemas',
|
|
@@ -165,6 +166,7 @@ export const createAssertion: CreateAssertionFn = <
|
|
|
165
166
|
/**
|
|
166
167
|
* {@inheritDoc CreateAsyncAssertionFn}
|
|
167
168
|
*
|
|
169
|
+
* @function
|
|
168
170
|
* @throws {TypeError} Invalid assertion implementation type
|
|
169
171
|
* @group Assertion Creation
|
|
170
172
|
*/
|
|
@@ -176,7 +178,7 @@ export const createAsyncAssertion: CreateAsyncAssertionFn = <
|
|
|
176
178
|
impl: Impl,
|
|
177
179
|
metadata?: AssertionMetadata,
|
|
178
180
|
) => {
|
|
179
|
-
if (!
|
|
181
|
+
if (!isArray(parts)) {
|
|
180
182
|
throw new AssertionImplementationError('First parameter must be an array');
|
|
181
183
|
}
|
|
182
184
|
if (parts.length === 0) {
|
|
@@ -185,9 +187,7 @@ export const createAsyncAssertion: CreateAsyncAssertionFn = <
|
|
|
185
187
|
);
|
|
186
188
|
}
|
|
187
189
|
if (
|
|
188
|
-
!parts.every(
|
|
189
|
-
(part) => isString(part) || Array.isArray(part) || isZodType(part),
|
|
190
|
-
)
|
|
190
|
+
!parts.every((part) => isString(part) || isArray(part) || isZodType(part))
|
|
191
191
|
) {
|
|
192
192
|
throw new AssertionImplementationError(
|
|
193
193
|
'All assertion parts must be strings or Zod schemas',
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* Executes & traps a `Promise` rejected from an async function, capturing the
|
|
10
10
|
* error.
|
|
11
11
|
*
|
|
12
|
+
* @function
|
|
12
13
|
* @param fn The function to execute that may throw an error or return a
|
|
13
14
|
* `Promise`
|
|
14
15
|
* @returns Rejection
|
|
@@ -24,16 +25,21 @@ export const trapAsyncFnError = async (fn: () => unknown) => {
|
|
|
24
25
|
/**
|
|
25
26
|
* Awaits & traps a Promise, capturing any rejection error.
|
|
26
27
|
*
|
|
28
|
+
* @function
|
|
27
29
|
* @param promise The `Promise` to trap
|
|
28
30
|
* @returns Rejection
|
|
29
31
|
*/
|
|
30
|
-
export const trapPromiseError =
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
export const trapPromiseError =
|
|
33
|
+
/**
|
|
34
|
+
* @function
|
|
35
|
+
*/
|
|
36
|
+
async (promise: PromiseLike<unknown>) => {
|
|
37
|
+
try {
|
|
38
|
+
await promise;
|
|
39
|
+
} catch (err) {
|
|
40
|
+
return err;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
37
43
|
|
|
38
44
|
/**
|
|
39
45
|
* Executes & traps a synchronous function that may throw, capturing any thrown
|
|
@@ -41,16 +47,21 @@ export const trapPromiseError = async (promise: PromiseLike<unknown>) => {
|
|
|
41
47
|
*
|
|
42
48
|
* @remarks
|
|
43
49
|
* Avoids throwing `undefined` for some reason.
|
|
50
|
+
* @function
|
|
44
51
|
* @param fn Function to execute
|
|
45
52
|
* @returns Error
|
|
46
53
|
*/
|
|
47
|
-
export const trapError =
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
54
|
+
export const trapError =
|
|
55
|
+
/**
|
|
56
|
+
* @function
|
|
57
|
+
*/
|
|
58
|
+
(fn: () => unknown): unknown => {
|
|
59
|
+
try {
|
|
60
|
+
fn();
|
|
61
|
+
} catch (err) {
|
|
62
|
+
if (err === undefined) {
|
|
63
|
+
return new Error('Function threw undefined');
|
|
64
|
+
}
|
|
65
|
+
return err;
|
|
53
66
|
}
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
};
|
|
67
|
+
};
|
|
@@ -27,6 +27,8 @@ import {
|
|
|
27
27
|
} from '../../schema.js';
|
|
28
28
|
import { createAssertion } from '../create.js';
|
|
29
29
|
|
|
30
|
+
const { ownKeys } = Reflect;
|
|
31
|
+
|
|
30
32
|
/**
|
|
31
33
|
* Asserts that the subject is a string value.
|
|
32
34
|
*
|
|
@@ -571,9 +573,7 @@ export const emptyArrayAssertion = createAssertion(
|
|
|
571
573
|
*/
|
|
572
574
|
export const emptyObjectAssertion = createAssertion(
|
|
573
575
|
[z.record(z.any(), z.unknown()), 'to be empty'],
|
|
574
|
-
z
|
|
575
|
-
.record(z.any(), z.unknown())
|
|
576
|
-
.refine((obj) => Reflect.ownKeys(obj).length === 0),
|
|
576
|
+
z.record(z.any(), z.unknown()).refine((obj) => ownKeys(obj).length === 0),
|
|
577
577
|
);
|
|
578
578
|
|
|
579
579
|
/**
|
|
@@ -32,6 +32,8 @@ import {
|
|
|
32
32
|
import { has } from '../../util.js';
|
|
33
33
|
import { createAssertion } from '../create.js';
|
|
34
34
|
|
|
35
|
+
const { hasOwn, keys } = Object;
|
|
36
|
+
|
|
35
37
|
/**
|
|
36
38
|
* Asserts that a Map or WeakMap contains a specific key. For WeakMap, the key
|
|
37
39
|
* must be an object.
|
|
@@ -101,7 +103,9 @@ export const mapContainsAssertion = createAssertion(
|
|
|
101
103
|
export const mapSizeAssertion = createAssertion(
|
|
102
104
|
[z.map(z.unknown(), z.unknown()), 'to have size', NonNegativeIntegerSchema],
|
|
103
105
|
(subject, expectedSize): AssertionFailure | boolean => {
|
|
104
|
-
if (subject.size === expectedSize)
|
|
106
|
+
if (subject.size === expectedSize) {
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
105
109
|
return {
|
|
106
110
|
actual: subject.size,
|
|
107
111
|
expected: expectedSize,
|
|
@@ -242,7 +246,9 @@ export const emptySetAssertion = createAssertion(
|
|
|
242
246
|
export const arrayContainsAssertion = createAssertion(
|
|
243
247
|
[z.array(z.any()), ['to contain', 'to include'], z.any()],
|
|
244
248
|
(subject, value): AssertionFailure | boolean => {
|
|
245
|
-
if (subject.includes(value))
|
|
249
|
+
if (subject.includes(value)) {
|
|
250
|
+
return true;
|
|
251
|
+
}
|
|
246
252
|
return {
|
|
247
253
|
actual: subject,
|
|
248
254
|
expected: `array containing ${String(value)}`,
|
|
@@ -266,7 +272,9 @@ export const arrayContainsAssertion = createAssertion(
|
|
|
266
272
|
export const arraySizeAssertion = createAssertion(
|
|
267
273
|
[z.array(z.any()), 'to have size', NonNegativeIntegerSchema],
|
|
268
274
|
(subject, expectedSize): AssertionFailure | boolean => {
|
|
269
|
-
if (subject.length === expectedSize)
|
|
275
|
+
if (subject.length === expectedSize) {
|
|
276
|
+
return true;
|
|
277
|
+
}
|
|
270
278
|
return {
|
|
271
279
|
actual: subject.length,
|
|
272
280
|
expected: expectedSize,
|
|
@@ -339,7 +347,7 @@ export const objectKeysAssertion = createAssertion(
|
|
|
339
347
|
z.array(z.string()).nonempty(),
|
|
340
348
|
],
|
|
341
349
|
(subject, keys) => {
|
|
342
|
-
const missing = keys.filter((k) => !
|
|
350
|
+
const missing = keys.filter((k) => !hasOwn(subject, k));
|
|
343
351
|
if (missing.length > 0) {
|
|
344
352
|
return {
|
|
345
353
|
actual: `missing keys: ${missing.join(', ')}`,
|
|
@@ -439,7 +447,7 @@ export const objectExactKeyAssertion = createAssertion(
|
|
|
439
447
|
],
|
|
440
448
|
(_, key) =>
|
|
441
449
|
NonCollectionObjectSchema.transform((v) => ({ ...v })).refine(
|
|
442
|
-
(value) =>
|
|
450
|
+
(value) => hasOwn(value, key),
|
|
443
451
|
{ error: `Expected object to have own exact key "${String(key)}"` },
|
|
444
452
|
),
|
|
445
453
|
);
|
|
@@ -459,7 +467,7 @@ export const objectExactKeyAssertion = createAssertion(
|
|
|
459
467
|
export const objectSizeAssertion = createAssertion(
|
|
460
468
|
[z.looseObject({}), 'to have size', NonNegativeIntegerSchema],
|
|
461
469
|
(subject, expectedSize) => {
|
|
462
|
-
const actual =
|
|
470
|
+
const actual = keys(subject).length;
|
|
463
471
|
if (actual !== expectedSize) {
|
|
464
472
|
return {
|
|
465
473
|
actual,
|
|
@@ -713,9 +721,11 @@ export const setSymmetricDifferenceEqualityAssertion = createAssertion(
|
|
|
713
721
|
export const mapKeyAssertion = createAssertion(
|
|
714
722
|
[z.map(z.unknown(), z.unknown()), 'to have key', z.unknown()],
|
|
715
723
|
(map, key): AssertionFailure | boolean => {
|
|
716
|
-
if (map.has(key))
|
|
724
|
+
if (map.has(key)) {
|
|
725
|
+
return true;
|
|
726
|
+
}
|
|
717
727
|
return {
|
|
718
|
-
actual:
|
|
728
|
+
actual: [...map.keys()],
|
|
719
729
|
expected: key,
|
|
720
730
|
message: `Expected Map to have key`,
|
|
721
731
|
};
|
|
@@ -739,10 +749,12 @@ export const mapValueAssertion = createAssertion(
|
|
|
739
749
|
[z.map(z.unknown(), z.unknown()), 'to have value', z.unknown()],
|
|
740
750
|
(map, value): AssertionFailure | boolean => {
|
|
741
751
|
for (const mapValue of map.values()) {
|
|
742
|
-
if (mapValue === value)
|
|
752
|
+
if (mapValue === value) {
|
|
753
|
+
return true;
|
|
754
|
+
}
|
|
743
755
|
}
|
|
744
756
|
return {
|
|
745
|
-
actual:
|
|
757
|
+
actual: [...map.values()],
|
|
746
758
|
expected: value,
|
|
747
759
|
message: `Expected Map to have value`,
|
|
748
760
|
};
|
|
@@ -781,7 +793,9 @@ export const mapEntryAssertion = createAssertion(
|
|
|
781
793
|
// At this point, if it's a WeakMap, we know key is a WeakKey
|
|
782
794
|
const actualValue =
|
|
783
795
|
map instanceof WeakMap ? map.get(key as WeakKey) : map.get(key);
|
|
784
|
-
if (actualValue === value)
|
|
796
|
+
if (actualValue === value) {
|
|
797
|
+
return true;
|
|
798
|
+
}
|
|
785
799
|
|
|
786
800
|
const hasKey =
|
|
787
801
|
map instanceof WeakMap ? map.has(key as WeakKey) : map.has(key);
|
|
@@ -867,7 +881,9 @@ export const collectionSizeGreaterThanAssertion = createAssertion(
|
|
|
867
881
|
NonNegativeIntegerSchema,
|
|
868
882
|
],
|
|
869
883
|
(collection, minSize): AssertionFailure | boolean => {
|
|
870
|
-
if (collection.size > minSize)
|
|
884
|
+
if (collection.size > minSize) {
|
|
885
|
+
return true;
|
|
886
|
+
}
|
|
871
887
|
return {
|
|
872
888
|
actual: collection.size,
|
|
873
889
|
expected: `size greater than ${minSize}`,
|
|
@@ -895,7 +911,9 @@ export const collectionSizeLessThanAssertion = createAssertion(
|
|
|
895
911
|
NonNegativeIntegerSchema,
|
|
896
912
|
],
|
|
897
913
|
(collection, maxSize): AssertionFailure | boolean => {
|
|
898
|
-
if (collection.size < maxSize)
|
|
914
|
+
if (collection.size < maxSize) {
|
|
915
|
+
return true;
|
|
916
|
+
}
|
|
899
917
|
return {
|
|
900
918
|
actual: collection.size,
|
|
901
919
|
expected: `size less than ${maxSize}`,
|
|
@@ -924,7 +942,9 @@ export const collectionSizeBetweenAssertion = createAssertion(
|
|
|
924
942
|
],
|
|
925
943
|
(collection, [min, max]): AssertionFailure | boolean => {
|
|
926
944
|
const size = collection.size;
|
|
927
|
-
if (size >= min && size <= max)
|
|
945
|
+
if (size >= min && size <= max) {
|
|
946
|
+
return true;
|
|
947
|
+
}
|
|
928
948
|
return {
|
|
929
949
|
actual: size,
|
|
930
950
|
expected: `size between ${min} and ${max} (inclusive)`,
|
|
@@ -12,9 +12,12 @@
|
|
|
12
12
|
|
|
13
13
|
import { z } from 'zod/v4';
|
|
14
14
|
|
|
15
|
+
import { isNonNullObject } from '../../guards.js';
|
|
15
16
|
import { DictionarySchema, PropertyKeySchema } from '../../schema.js';
|
|
16
17
|
import { createAssertion } from '../create.js';
|
|
17
18
|
|
|
19
|
+
const { getOwnPropertyDescriptor, isExtensible, isFrozen, isSealed } = Object;
|
|
20
|
+
|
|
18
21
|
/**
|
|
19
22
|
* Asserts that an object has a null prototype (i.e.,
|
|
20
23
|
* `Object.getPrototypeOf(obj) === null`).
|
|
@@ -72,7 +75,7 @@ export const enumerablePropertyAssertion = createAssertion(
|
|
|
72
75
|
z.unknown().nonoptional(),
|
|
73
76
|
],
|
|
74
77
|
(subject, obj) => {
|
|
75
|
-
if (!
|
|
78
|
+
if (!getOwnPropertyDescriptor(obj, subject)?.enumerable) {
|
|
76
79
|
return {
|
|
77
80
|
actual: false,
|
|
78
81
|
expected: true,
|
|
@@ -112,15 +115,16 @@ export const enumerablePropertyAssertion = createAssertion(
|
|
|
112
115
|
*/
|
|
113
116
|
export const enumerablePropertyAssertion2 = createAssertion(
|
|
114
117
|
[z.unknown().nonoptional(), 'to have enumerable property', PropertyKeySchema],
|
|
115
|
-
(
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
118
|
+
(_subject, key) =>
|
|
119
|
+
z.custom(
|
|
120
|
+
(value) =>
|
|
121
|
+
isNonNullObject(value) &&
|
|
122
|
+
key in value &&
|
|
123
|
+
!!getOwnPropertyDescriptor(value, key)?.enumerable,
|
|
124
|
+
{
|
|
125
|
+
error: `Expected property "${String(key)}" to be enumerable`,
|
|
126
|
+
},
|
|
127
|
+
),
|
|
124
128
|
);
|
|
125
129
|
|
|
126
130
|
/**
|
|
@@ -150,7 +154,7 @@ export const enumerablePropertyAssertion2 = createAssertion(
|
|
|
150
154
|
*/
|
|
151
155
|
export const sealedAssertion = createAssertion(
|
|
152
156
|
['to be sealed'],
|
|
153
|
-
z.any().refine((obj) =>
|
|
157
|
+
z.any().refine((obj) => isSealed(obj)),
|
|
154
158
|
);
|
|
155
159
|
|
|
156
160
|
/**
|
|
@@ -181,7 +185,7 @@ export const sealedAssertion = createAssertion(
|
|
|
181
185
|
* @group Esoteric Assertions
|
|
182
186
|
*/
|
|
183
187
|
export const frozenAssertion = createAssertion(['to be frozen'], (subject) => {
|
|
184
|
-
if (!
|
|
188
|
+
if (!isFrozen(subject)) {
|
|
185
189
|
return {
|
|
186
190
|
actual: false,
|
|
187
191
|
expected: true,
|
|
@@ -221,5 +225,5 @@ export const frozenAssertion = createAssertion(['to be frozen'], (subject) => {
|
|
|
221
225
|
*/
|
|
222
226
|
export const extensibleAssertion = createAssertion(
|
|
223
227
|
['to be extensible'],
|
|
224
|
-
z.any().refine((obj) =>
|
|
228
|
+
z.any().refine((obj) => isExtensible(obj)),
|
|
225
229
|
);
|
|
@@ -34,10 +34,13 @@ import {
|
|
|
34
34
|
import { createAssertion } from '../create.js';
|
|
35
35
|
import { trapError } from './assertion-util.js';
|
|
36
36
|
|
|
37
|
+
const { freeze } = Object;
|
|
38
|
+
const { abs } = Math;
|
|
39
|
+
|
|
37
40
|
/**
|
|
38
41
|
* For {@link typeOfAssertion}
|
|
39
42
|
*/
|
|
40
|
-
const knownTypes =
|
|
43
|
+
const knownTypes = freeze(
|
|
41
44
|
new Set([
|
|
42
45
|
'string',
|
|
43
46
|
'number',
|
|
@@ -271,7 +274,7 @@ export const numberWithinRangeAssertion = createAssertion(
|
|
|
271
274
|
export const numberCloseToAssertion = createAssertion(
|
|
272
275
|
[z.number(), 'to be close to', z.number(), z.number().optional()],
|
|
273
276
|
(subject, expected, tolerance = 1e-9) => {
|
|
274
|
-
const diff =
|
|
277
|
+
const diff = abs(subject - expected);
|
|
275
278
|
if (diff > tolerance) {
|
|
276
279
|
return {
|
|
277
280
|
actual: subject,
|
package/src/assertion/slotify.ts
CHANGED
|
@@ -30,6 +30,7 @@ import { BupkisRegistry } from '../metadata.js';
|
|
|
30
30
|
* processing string literals and Zod schemas, registering metadata for runtime
|
|
31
31
|
* introspection, and handling validation constraints such as preventing "not "
|
|
32
32
|
* prefixes in string literal parts.
|
|
33
|
+
* @function
|
|
33
34
|
* @param parts Assertion parts
|
|
34
35
|
* @returns Slots
|
|
35
36
|
*/
|
package/src/bootstrap.ts
CHANGED