assertron 11.5.2 → 11.5.4
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/README.md +7 -7
- package/cjs/_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/defineProperty.js +12 -0
- package/cjs/_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/toPrimitive.js +14 -0
- package/cjs/_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/toPropertyKey.js +9 -0
- package/cjs/_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/typeof.js +16 -0
- package/cjs/_virtual/_rolldown/runtime.js +23 -0
- package/cjs/assert-order/AssertOrder.d.ts +42 -39
- package/cjs/assert-order/AssertOrder.d.ts.map +1 -1
- package/cjs/assert-order/AssertOrder.js +118 -146
- package/cjs/assert-order/AssertOrder.js.map +1 -1
- package/cjs/assert-order/InvalidOrder.d.ts +10 -7
- package/cjs/assert-order/InvalidOrder.d.ts.map +1 -1
- package/cjs/assert-order/InvalidOrder.js +24 -43
- package/cjs/assert-order/InvalidOrder.js.map +1 -1
- package/cjs/assert-order/StateMachine.js +101 -156
- package/cjs/assert-order/StateMachine.js.map +1 -1
- package/cjs/assert-order/index.d.ts +4 -4
- package/cjs/assert-order/types.d.ts +9 -6
- package/cjs/assert-order/types.d.ts.map +1 -1
- package/cjs/assertron/assertron.d.ts +23 -20
- package/cjs/assertron/assertron.d.ts.map +1 -1
- package/cjs/assertron/assertron.js +36 -39
- package/cjs/assertron/assertron.js.map +1 -1
- package/cjs/assertron/falsy.js +5 -6
- package/cjs/assertron/falsy.js.map +1 -1
- package/cjs/assertron/index.d.ts +3 -3
- package/cjs/assertron/isInstanceof.js +6 -7
- package/cjs/assertron/isInstanceof.js.map +1 -1
- package/cjs/assertron/pathEqual.js +7 -8
- package/cjs/assertron/pathEqual.js.map +1 -1
- package/cjs/assertron/rejects.js +8 -8
- package/cjs/assertron/rejects.js.map +1 -1
- package/cjs/assertron/repeat.js +23 -31
- package/cjs/assertron/repeat.js.map +1 -1
- package/cjs/assertron/resolves.js +8 -8
- package/cjs/assertron/resolves.js.map +1 -1
- package/cjs/assertron/satisfies.d.ts +5 -10
- package/cjs/assertron/satisfies.d.ts.map +1 -1
- package/cjs/assertron/satisfies.js +12 -14
- package/cjs/assertron/satisfies.js.map +1 -1
- package/cjs/assertron/throws.js +48 -55
- package/cjs/assertron/throws.js.map +1 -1
- package/cjs/assertron/truthy.js +5 -6
- package/cjs/assertron/truthy.js.map +1 -1
- package/cjs/errors.d.ts +13 -10
- package/cjs/errors.d.ts.map +1 -1
- package/cjs/errors.js +19 -29
- package/cjs/errors.js.map +1 -1
- package/cjs/index.d.ts +10 -8
- package/cjs/index.js +98 -37
- package/cjs/index.js.map +1 -1
- package/cjs/package.json +3 -1
- package/cjs/types.d.ts +5 -2
- package/cjs/types.d.ts.map +1 -1
- package/cjs/utils/index.js +18 -25
- package/cjs/utils/index.js.map +1 -1
- package/cjs/utils/isErrorConstructor.js +4 -4
- package/cjs/utils/isErrorConstructor.js.map +1 -1
- package/cjs/utils/notEqualMessage.js +4 -4
- package/cjs/utils/notEqualMessage.js.map +1 -1
- package/cjs/utils/notSatisfiedMessage.js +14 -23
- package/cjs/utils/notSatisfiedMessage.js.map +1 -1
- package/cjs/utils/notThrownMessage.js +5 -5
- package/cjs/utils/notThrownMessage.js.map +1 -1
- package/cjs/utils/promiseMessages.js +7 -13
- package/cjs/utils/promiseMessages.js.map +1 -1
- package/cjs/utils/unexpectedErrorMessage.js +6 -6
- package/cjs/utils/unexpectedErrorMessage.js.map +1 -1
- package/esm/_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/defineProperty.js +12 -0
- package/esm/_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/toPrimitive.js +14 -0
- package/esm/_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/toPropertyKey.js +9 -0
- package/esm/_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/typeof.js +11 -0
- package/esm/assert-order/AssertOrder.d.ts +42 -39
- package/esm/assert-order/AssertOrder.d.ts.map +1 -1
- package/esm/assert-order/AssertOrder.js +119 -143
- package/esm/assert-order/AssertOrder.js.map +1 -1
- package/esm/assert-order/InvalidOrder.d.ts +10 -7
- package/esm/assert-order/InvalidOrder.d.ts.map +1 -1
- package/esm/assert-order/InvalidOrder.js +24 -39
- package/esm/assert-order/InvalidOrder.js.map +1 -1
- package/esm/assert-order/StateMachine.js +99 -129
- package/esm/assert-order/StateMachine.js.map +1 -1
- package/esm/assert-order/index.d.ts +4 -4
- package/esm/assert-order/types.d.ts +9 -6
- package/esm/assert-order/types.d.ts.map +1 -1
- package/esm/assertron/assertron.d.ts +23 -20
- package/esm/assertron/assertron.d.ts.map +1 -1
- package/esm/assertron/assertron.js +36 -36
- package/esm/assertron/assertron.js.map +1 -1
- package/esm/assertron/falsy.js +7 -4
- package/esm/assertron/falsy.js.map +1 -1
- package/esm/assertron/index.d.ts +3 -3
- package/esm/assertron/isInstanceof.js +8 -5
- package/esm/assertron/isInstanceof.js.map +1 -1
- package/esm/assertron/pathEqual.js +9 -6
- package/esm/assertron/pathEqual.js.map +1 -1
- package/esm/assertron/rejects.js +10 -6
- package/esm/assertron/rejects.js.map +1 -1
- package/esm/assertron/repeat.js +22 -25
- package/esm/assertron/repeat.js.map +1 -1
- package/esm/assertron/resolves.js +10 -6
- package/esm/assertron/resolves.js.map +1 -1
- package/esm/assertron/satisfies.d.ts +5 -10
- package/esm/assertron/satisfies.d.ts.map +1 -1
- package/esm/assertron/satisfies.js +14 -12
- package/esm/assertron/satisfies.js.map +1 -1
- package/esm/assertron/throws.js +47 -49
- package/esm/assertron/throws.js.map +1 -1
- package/esm/assertron/truthy.js +7 -4
- package/esm/assertron/truthy.js.map +1 -1
- package/esm/errors.d.ts +13 -10
- package/esm/errors.d.ts.map +1 -1
- package/esm/errors.js +20 -26
- package/esm/errors.js.map +1 -1
- package/esm/index.d.ts +10 -8
- package/esm/index.js +10 -7
- package/esm/index.js.map +1 -1
- package/esm/types.d.ts +5 -2
- package/esm/types.d.ts.map +1 -1
- package/esm/utils/index.js +13 -9
- package/esm/utils/index.js.map +1 -1
- package/esm/utils/isErrorConstructor.js +6 -2
- package/esm/utils/isErrorConstructor.js.map +1 -1
- package/esm/utils/notEqualMessage.js +6 -2
- package/esm/utils/notEqualMessage.js.map +1 -1
- package/esm/utils/notSatisfiedMessage.js +15 -20
- package/esm/utils/notSatisfiedMessage.js.map +1 -1
- package/esm/utils/notThrownMessage.js +7 -3
- package/esm/utils/notThrownMessage.js.map +1 -1
- package/esm/utils/promiseMessages.js +9 -11
- package/esm/utils/promiseMessages.js.map +1 -1
- package/esm/utils/unexpectedErrorMessage.js +8 -4
- package/esm/utils/unexpectedErrorMessage.js.map +1 -1
- package/package.json +43 -68
- package/ts/assert-order/AssertOrder.ts +8 -6
- package/ts/assert-order/InvalidOrder.ts +4 -6
- package/ts/assert-order/StateMachine.ts +11 -7
- package/ts/assertron/assertron.ts +9 -19
- package/ts/assertron/falsy.ts +1 -2
- package/ts/assertron/isInstanceof.ts +1 -4
- package/ts/assertron/pathEqual.ts +1 -2
- package/ts/assertron/rejects.ts +2 -2
- package/ts/assertron/repeat.ts +5 -6
- package/ts/assertron/resolves.ts +3 -3
- package/ts/assertron/satisfies.ts +2 -4
- package/ts/assertron/throws.ts +14 -20
- package/ts/assertron/truthy.ts +1 -2
- package/ts/errors.ts +5 -1
- package/ts/index.ts +2 -2
- package/ts/utils/index.ts +1 -1
- package/ts/utils/notSatisfiedMessage.ts +2 -2
- package/ts/utils/promiseMessages.ts +5 -5
- package/cjs/assert-order/StateMachine.d.ts +0 -22
- package/cjs/assert-order/StateMachine.d.ts.map +0 -1
- package/cjs/assert-order/index.d.ts.map +0 -1
- package/cjs/assert-order/index.js +0 -20
- package/cjs/assert-order/index.js.map +0 -1
- package/cjs/assert-order/types.js +0 -3
- package/cjs/assert-order/types.js.map +0 -1
- package/cjs/assertron/falsy.d.ts +0 -2
- package/cjs/assertron/falsy.d.ts.map +0 -1
- package/cjs/assertron/index.d.ts.map +0 -1
- package/cjs/assertron/index.js +0 -18
- package/cjs/assertron/index.js.map +0 -1
- package/cjs/assertron/isInstanceof.d.ts +0 -3
- package/cjs/assertron/isInstanceof.d.ts.map +0 -1
- package/cjs/assertron/pathEqual.d.ts +0 -2
- package/cjs/assertron/pathEqual.d.ts.map +0 -1
- package/cjs/assertron/rejects.d.ts +0 -2
- package/cjs/assertron/rejects.d.ts.map +0 -1
- package/cjs/assertron/repeat.d.ts +0 -6
- package/cjs/assertron/repeat.d.ts.map +0 -1
- package/cjs/assertron/resolves.d.ts +0 -2
- package/cjs/assertron/resolves.d.ts.map +0 -1
- package/cjs/assertron/throws.d.ts +0 -6
- package/cjs/assertron/throws.d.ts.map +0 -1
- package/cjs/assertron/truthy.d.ts +0 -2
- package/cjs/assertron/truthy.d.ts.map +0 -1
- package/cjs/index.d.ts.map +0 -1
- package/cjs/types.js +0 -3
- package/cjs/types.js.map +0 -1
- package/cjs/utils/index.d.ts +0 -8
- package/cjs/utils/index.d.ts.map +0 -1
- package/cjs/utils/isErrorConstructor.d.ts +0 -3
- package/cjs/utils/isErrorConstructor.d.ts.map +0 -1
- package/cjs/utils/notEqualMessage.d.ts +0 -2
- package/cjs/utils/notEqualMessage.d.ts.map +0 -1
- package/cjs/utils/notSatisfiedMessage.d.ts +0 -3
- package/cjs/utils/notSatisfiedMessage.d.ts.map +0 -1
- package/cjs/utils/notThrownMessage.d.ts +0 -2
- package/cjs/utils/notThrownMessage.d.ts.map +0 -1
- package/cjs/utils/promiseMessages.d.ts +0 -3
- package/cjs/utils/promiseMessages.d.ts.map +0 -1
- package/cjs/utils/unexpectedErrorMessage.d.ts +0 -3
- package/cjs/utils/unexpectedErrorMessage.d.ts.map +0 -1
- package/esm/assert-order/StateMachine.d.ts +0 -22
- package/esm/assert-order/StateMachine.d.ts.map +0 -1
- package/esm/assert-order/index.d.ts.map +0 -1
- package/esm/assert-order/index.js +0 -4
- package/esm/assert-order/index.js.map +0 -1
- package/esm/assert-order/types.js +0 -2
- package/esm/assert-order/types.js.map +0 -1
- package/esm/assertron/falsy.d.ts +0 -2
- package/esm/assertron/falsy.d.ts.map +0 -1
- package/esm/assertron/index.d.ts.map +0 -1
- package/esm/assertron/index.js +0 -2
- package/esm/assertron/index.js.map +0 -1
- package/esm/assertron/isInstanceof.d.ts +0 -3
- package/esm/assertron/isInstanceof.d.ts.map +0 -1
- package/esm/assertron/pathEqual.d.ts +0 -2
- package/esm/assertron/pathEqual.d.ts.map +0 -1
- package/esm/assertron/rejects.d.ts +0 -2
- package/esm/assertron/rejects.d.ts.map +0 -1
- package/esm/assertron/repeat.d.ts +0 -6
- package/esm/assertron/repeat.d.ts.map +0 -1
- package/esm/assertron/resolves.d.ts +0 -2
- package/esm/assertron/resolves.d.ts.map +0 -1
- package/esm/assertron/throws.d.ts +0 -6
- package/esm/assertron/throws.d.ts.map +0 -1
- package/esm/assertron/truthy.d.ts +0 -2
- package/esm/assertron/truthy.d.ts.map +0 -1
- package/esm/index.d.ts.map +0 -1
- package/esm/types.js +0 -2
- package/esm/types.js.map +0 -1
- package/esm/utils/index.d.ts +0 -8
- package/esm/utils/index.d.ts.map +0 -1
- package/esm/utils/isErrorConstructor.d.ts +0 -3
- package/esm/utils/isErrorConstructor.d.ts.map +0 -1
- package/esm/utils/notEqualMessage.d.ts +0 -2
- package/esm/utils/notEqualMessage.d.ts.map +0 -1
- package/esm/utils/notSatisfiedMessage.d.ts +0 -3
- package/esm/utils/notSatisfiedMessage.d.ts.map +0 -1
- package/esm/utils/notThrownMessage.d.ts +0 -2
- package/esm/utils/notThrownMessage.d.ts.map +0 -1
- package/esm/utils/promiseMessages.d.ts +0 -3
- package/esm/utils/promiseMessages.d.ts.map +0 -1
- package/esm/utils/unexpectedErrorMessage.d.ts +0 -3
- package/esm/utils/unexpectedErrorMessage.d.ts.map +0 -1
- package/ts/assert-order/internalInterfaces.ts +0 -5
- package/ts/testUtils.ts +0 -81
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"throws.js","
|
|
1
|
+
{"version":3,"file":"throws.js","names":[],"sources":["../../ts/assertron/throws.ts"],"sourcesContent":["import isPromise from 'is-promise'\nimport { AssertionError } from '../errors.js'\nimport type { ErrorConstructor, ErrorValidator } from '../types.js'\nimport { isErrorConstructor, notRejectedMessage, notThrownMessage, unexpectedErrorMessage } from '../utils/index.js'\n\nexport function throws<E extends Error>(\n\tvalue: PromiseLike<any>,\n\terror?: ErrorValidator | ErrorConstructor<E>,\n): Promise<E>\nexport function throws<E extends Error>(\n\tvalue: (...args: any[]) => never,\n\terror?: ErrorValidator | ErrorConstructor<E>,\n): E\nexport function throws<E extends Error, R = any>(\n\tvalue: (...args: any[]) => R,\n\terror?: ErrorValidator | ErrorConstructor<E>,\n): R extends Promise<any> ? Promise<E> : E\nexport function throws<T, R = any>(\n\tvalue: (...args: any[]) => R,\n\tvalidator?: ErrorValidator,\n): R extends Promise<any> ? Promise<T> : T\nexport function throws(\n\tvalue: PromiseLike<any> | (() => any | PromiseLike<any>),\n\tvalidator?: ErrorValidator | ErrorConstructor<any>,\n): any {\n\tif (typeof value !== 'function' && !isPromise(value)) {\n\t\tthrow new AssertionError('`assertron.throws()` must be called with a function or promise.', {\n\t\t\tssf: throws,\n\t\t})\n\t}\n\n\tif (!isPromise(value)) {\n\t\tconst { threw, err, result } = tryCatch(value)\n\t\tif (threw) {\n\t\t\tif (failValidation(validator, err)) {\n\t\t\t\tthrow new AssertionError(unexpectedErrorMessage(err, validator), { ssf: throws })\n\t\t\t}\n\t\t\treturn err\n\t\t}\n\t\tvalue = result\n\t}\n\n\tif (isPromise(value)) {\n\t\treturn value.then(\n\t\t\t(value) => {\n\t\t\t\tthrow new AssertionError(notRejectedMessage(value), { ssf: throws })\n\t\t\t},\n\t\t\t(err) => {\n\t\t\t\tif (failValidation(validator, err)) {\n\t\t\t\t\tthrow new AssertionError(unexpectedErrorMessage(err, validator), { ssf: throws, cause: err })\n\t\t\t\t}\n\t\t\t\treturn err\n\t\t\t},\n\t\t)\n\t}\n\n\tthrow new AssertionError(notThrownMessage(value), { ssf: throws })\n}\n\nfunction tryCatch(fn: () => any) {\n\tlet result: any\n\tlet err: any\n\tlet threw = false\n\ttry {\n\t\tresult = fn()\n\t} catch (e) {\n\t\terr = e\n\t\tthrew = true\n\t}\n\treturn { threw, err, result }\n}\nfunction failValidation(\n\tvalidator: ErrorValidator | ErrorConstructor<any> | undefined,\n\terror: any,\n): validator is ErrorValidator | ErrorConstructor<any> {\n\tif (!validator) return false\n\n\tif (isErrorConstructor(validator)) {\n\t\treturn !(error instanceof validator)\n\t}\n\treturn !validator(error)\n}\n"],"mappings":";;;;;;;AAqBA,SAAgB,OACf,OACA,WACM;CACN,IAAI,OAAO,UAAU,cAAc,CAAC,UAAU,KAAK,GAClD,MAAM,IAAI,eAAe,mEAAmE,EAC3F,KAAK,OACN,CAAC;CAGF,IAAI,CAAC,UAAU,KAAK,GAAG;EACtB,MAAM,EAAE,OAAO,KAAK,WAAW,SAAS,KAAK;EAC7C,IAAI,OAAO;GACV,IAAI,eAAe,WAAW,GAAG,GAChC,MAAM,IAAI,eAAe,uBAAuB,KAAK,SAAS,GAAG,EAAE,KAAK,OAAO,CAAC;GAEjF,OAAO;EACR;EACA,QAAQ;CACT;CAEA,IAAI,UAAU,KAAK,GAClB,OAAO,MAAM,MACX,UAAU;EACV,MAAM,IAAI,eAAe,mBAAmB,KAAK,GAAG,EAAE,KAAK,OAAO,CAAC;CACpE,IACC,QAAQ;EACR,IAAI,eAAe,WAAW,GAAG,GAChC,MAAM,IAAI,eAAe,uBAAuB,KAAK,SAAS,GAAG;GAAE,KAAK;GAAQ,OAAO;EAAI,CAAC;EAE7F,OAAO;CACR,CACD;CAGD,MAAM,IAAI,eAAe,iBAAiB,KAAK,GAAG,EAAE,KAAK,OAAO,CAAC;AAClE;AAEA,SAAS,SAAS,IAAe;CAChC,IAAI;CACJ,IAAI;CACJ,IAAI,QAAQ;CACZ,IAAI;EACH,SAAS,GAAG;CACb,SAAS,GAAG;EACX,MAAM;EACN,QAAQ;CACT;CACA,OAAO;EAAE;EAAO;EAAK;CAAO;AAC7B;AACA,SAAS,eACR,WACA,OACsD;CACtD,IAAI,CAAC,WAAW,OAAO;CAEvB,IAAI,mBAAmB,SAAS,GAC/B,OAAO,EAAE,iBAAiB;CAE3B,OAAO,CAAC,UAAU,KAAK;AACxB"}
|
package/esm/assertron/truthy.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { AssertionError } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { AssertionError } from "../errors.js";
|
|
2
|
+
//#region ts/assertron/truthy.ts
|
|
3
|
+
function truthy(value, message) {
|
|
4
|
+
if (!value) throw new AssertionError(message ?? `Expected value to be truthy, but received ${value}`, { ssf: truthy });
|
|
5
5
|
}
|
|
6
|
+
//#endregion
|
|
7
|
+
export { truthy };
|
|
8
|
+
|
|
6
9
|
//# sourceMappingURL=truthy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"truthy.js","
|
|
1
|
+
{"version":3,"file":"truthy.js","names":[],"sources":["../../ts/assertron/truthy.ts"],"sourcesContent":["import { AssertionError } from '../errors.js'\n\nexport function truthy(value: unknown, message?: string | undefined): void {\n\tif (!value) throw new AssertionError(message ?? `Expected value to be truthy, but received ${value}`, { ssf: truthy })\n}\n"],"mappings":";;AAEA,SAAgB,OAAO,OAAgB,SAAoC;CAC1E,IAAI,CAAC,OAAO,MAAM,IAAI,eAAe,WAAW,6CAA6C,SAAS,EAAE,KAAK,OAAO,CAAC;AACtH"}
|
package/esm/errors.d.ts
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
import { ModuleError } from
|
|
2
|
-
import
|
|
1
|
+
import { ModuleError } from "iso-error";
|
|
2
|
+
import { RequiredPick } from "type-plus";
|
|
3
|
+
//#region ts/errors.d.ts
|
|
3
4
|
/**
|
|
4
5
|
* A base error for all assertion errors
|
|
5
6
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
declare class AssertionError extends ModuleError {
|
|
8
|
+
constructor(message: string, options: AssertionError.Options);
|
|
8
9
|
}
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
declare namespace AssertionError {
|
|
11
|
+
type Options = RequiredPick<ModuleError.Options, 'ssf'>;
|
|
11
12
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
declare class FailOnOccurrence extends AssertionError {
|
|
14
|
+
occurrence: number;
|
|
15
|
+
error: any;
|
|
16
|
+
constructor(occurrence: number, error: any, options: AssertionError.Options);
|
|
16
17
|
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { AssertionError, FailOnOccurrence };
|
|
17
20
|
//# sourceMappingURL=errors.d.ts.map
|
package/esm/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","
|
|
1
|
+
{"version":3,"file":"errors.d.ts","names":[],"sources":["../ts/errors.ts"],"mappings":";;;;;;cAOa,uBAAuB;EACnC,YAAY,iBAAiB,SAAS,eAAe;;kBAKrC;OACJ,UAAU,aAAa,YAAY;;cAGnC,yBAAyB;EAE7B;EACA;EAFR,YACQ,oBACA,YACP,SAAS,eAAe"}
|
package/esm/errors.js
CHANGED
|
@@ -1,28 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { failOnOccurrence } from "./utils/index.js";
|
|
2
|
+
import { ModuleError } from "iso-error";
|
|
3
|
+
//#region ts/errors.ts
|
|
3
4
|
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
enumerable: true,
|
|
22
|
-
configurable: true,
|
|
23
|
-
writable: true,
|
|
24
|
-
value: error
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
}
|
|
5
|
+
* A base error for all assertion errors
|
|
6
|
+
*/
|
|
7
|
+
var AssertionError = class extends ModuleError {
|
|
8
|
+
constructor(message, options) {
|
|
9
|
+
super("assertron", message, options);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
var FailOnOccurrence = class extends AssertionError {
|
|
13
|
+
constructor(occurrence, error, options) {
|
|
14
|
+
super(failOnOccurrence(occurrence, error), options);
|
|
15
|
+
this.occurrence = occurrence;
|
|
16
|
+
this.error = error;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
export { AssertionError, FailOnOccurrence };
|
|
21
|
+
|
|
28
22
|
//# sourceMappingURL=errors.js.map
|
package/esm/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","
|
|
1
|
+
{"version":3,"file":"errors.js","names":[],"sources":["../ts/errors.ts"],"sourcesContent":["import { ModuleError } from 'iso-error'\nimport type { RequiredPick } from 'type-plus'\nimport { failOnOccurrence } from './utils/index.js'\n\n/**\n * A base error for all assertion errors\n */\nexport class AssertionError extends ModuleError {\n\tconstructor(message: string, options: AssertionError.Options) {\n\t\tsuper('assertron', message, options)\n\t}\n}\n\nexport namespace AssertionError {\n\texport type Options = RequiredPick<ModuleError.Options, 'ssf'>\n}\n\nexport class FailOnOccurrence extends AssertionError {\n\tconstructor(\n\t\tpublic occurrence: number,\n\t\tpublic error: any,\n\t\toptions: AssertionError.Options,\n\t) {\n\t\tsuper(failOnOccurrence(occurrence, error), options)\n\t}\n}\n"],"mappings":";;;;;;AAOA,IAAa,iBAAb,cAAoC,YAAY;CAC/C,YAAY,SAAiB,SAAiC;EAC7D,MAAM,aAAa,SAAS,OAAO;CACpC;AACD;AAMA,IAAa,mBAAb,cAAsC,eAAe;CACpD,YACC,YACA,OACA,SACC;EACD,MAAM,iBAAiB,YAAY,KAAK,GAAG,OAAO;EAJ3C,KAAA,aAAA;EACA,KAAA,QAAA;CAIR;AACD"}
|
package/esm/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { SatisfyExpectation } from "./assertron/satisfies.js";
|
|
2
|
+
import { Assertron, assertron } from "./assertron/assertron.js";
|
|
3
|
+
import "./assertron/index.js";
|
|
4
|
+
import { AssertOrder } from "./assert-order/AssertOrder.js";
|
|
5
|
+
import { AssertionError, FailOnOccurrence } from "./errors.js";
|
|
6
|
+
import { State } from "./assert-order/types.js";
|
|
7
|
+
import { InvalidOrder } from "./assert-order/InvalidOrder.js";
|
|
8
|
+
import "./assert-order/index.js";
|
|
9
|
+
import { anything, every, has, hasAll, isInClosedInterval, isInLeftClosedInterval, isInOpenInterval, isInRange, isInRightClosedInterval, isTypeOf, none, some, startsWith } from "satisfier";
|
|
10
|
+
export { AssertOrder, AssertionError, Assertron, FailOnOccurrence, InvalidOrder, type SatisfyExpectation, State, assertron as a, assertron as default, anything, assertron, every, has, hasAll, isInClosedInterval, isInLeftClosedInterval, isInOpenInterval, isInRange, isInRightClosedInterval, isTypeOf, none, some, startsWith };
|
package/esm/index.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { AssertionError, FailOnOccurrence } from "./errors.js";
|
|
2
|
+
import { assertron } from "./assertron/assertron.js";
|
|
3
|
+
import { InvalidOrder } from "./assert-order/InvalidOrder.js";
|
|
4
|
+
import { AssertOrder } from "./assert-order/AssertOrder.js";
|
|
5
|
+
import { anything, every, has, hasAll, isInClosedInterval, isInLeftClosedInterval, isInOpenInterval, isInRange, isInRightClosedInterval, isTypeOf, none, some, startsWith } from "satisfier";
|
|
6
|
+
//#region ts/index.ts
|
|
7
|
+
var ts_default = assertron;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { AssertOrder, AssertionError, FailOnOccurrence, InvalidOrder, assertron as a, anything, assertron, ts_default as default, every, has, hasAll, isInClosedInterval, isInLeftClosedInterval, isInOpenInterval, isInRange, isInRightClosedInterval, isTypeOf, none, some, startsWith };
|
|
10
|
+
|
|
8
11
|
//# sourceMappingURL=index.js.map
|
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../ts/index.ts"],"sourcesContent":["import { assertron } from './assertron/index.js'\n\nexport {\n\tanything,\n\tevery,\n\thas,\n\thasAll,\n\tisInClosedInterval,\n\tisInLeftClosedInterval,\n\tisInOpenInterval,\n\tisInRange,\n\tisInRightClosedInterval,\n\tisTypeOf,\n\tnone,\n\tsome,\n\tstartsWith,\n} from 'satisfier'\nexport * from './assert-order/index.js'\nexport * from './assertron/index.js'\nexport * from './errors.js'\nexport { assertron as a }\n\nexport default assertron\n"],"mappings":";;;;;;AAsBA,IAAA,aAAe"}
|
package/esm/types.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region ts/types.d.ts
|
|
2
|
+
type ErrorValidator = (value: any) => boolean;
|
|
3
|
+
type ErrorConstructor<E extends Error> = new (...args: any[]) => E;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { ErrorConstructor, ErrorValidator };
|
|
3
6
|
//# sourceMappingURL=types.d.ts.map
|
package/esm/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../ts/types.ts"],"mappings":";KAAY,kBAAkB;KAClB,iBAAiB,UAAU,iBAAiB,gBAAgB"}
|
package/esm/utils/index.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { isErrorConstructor } from "./isErrorConstructor.js";
|
|
2
|
+
import { notEqualMessage } from "./notEqualMessage.js";
|
|
3
|
+
import { notSatisfiedMessage } from "./notSatisfiedMessage.js";
|
|
4
|
+
import { notThrownMessage } from "./notThrownMessage.js";
|
|
5
|
+
import { notRejectedMessage, notResolvedMessage } from "./promiseMessages.js";
|
|
6
|
+
import { unexpectedErrorMessage } from "./unexpectedErrorMessage.js";
|
|
7
|
+
import { tersify } from "tersify";
|
|
8
|
+
//#region ts/utils/index.ts
|
|
9
|
+
function failOnOccurrence(occurrence, error) {
|
|
10
|
+
return `Failed on ${occurrence} occurrence: ${tersify(error, { maxLength: Number.POSITIVE_INFINITY })}`;
|
|
10
11
|
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { failOnOccurrence, isErrorConstructor, notEqualMessage, notRejectedMessage, notResolvedMessage, notSatisfiedMessage, notThrownMessage, unexpectedErrorMessage };
|
|
14
|
+
|
|
11
15
|
//# sourceMappingURL=index.js.map
|
package/esm/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../ts/utils/index.ts"],"sourcesContent":["import { tersify } from 'tersify'\n\nexport * from './isErrorConstructor.js'\nexport * from './notEqualMessage.js'\nexport * from './notSatisfiedMessage.js'\nexport * from './notThrownMessage.js'\nexport * from './promiseMessages.js'\nexport * from './unexpectedErrorMessage.js'\n\nexport function failOnOccurrence(occurrence: number, error: any) {\n\treturn `Failed on ${occurrence} occurrence: ${tersify(error, { maxLength: Number.POSITIVE_INFINITY })}`\n}\n"],"mappings":";;;;;;;;AASA,SAAgB,iBAAiB,YAAoB,OAAY;CAChE,OAAO,aAAa,WAAW,eAAe,QAAQ,OAAO,EAAE,WAAW,OAAO,kBAAkB,CAAC;AACrG"}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region ts/utils/isErrorConstructor.ts
|
|
2
|
+
function isErrorConstructor(validator) {
|
|
3
|
+
return Object.prototype.isPrototypeOf.call(Error.prototype, validator.prototype);
|
|
3
4
|
}
|
|
5
|
+
//#endregion
|
|
6
|
+
export { isErrorConstructor };
|
|
7
|
+
|
|
4
8
|
//# sourceMappingURL=isErrorConstructor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isErrorConstructor.js","
|
|
1
|
+
{"version":3,"file":"isErrorConstructor.js","names":[],"sources":["../../ts/utils/isErrorConstructor.ts"],"sourcesContent":["import type { ErrorConstructor } from '../types.js'\n\nexport function isErrorConstructor(validator: any): validator is ErrorConstructor<any> {\n\treturn Object.prototype.isPrototypeOf.call(Error.prototype, validator.prototype)\n}\n"],"mappings":";AAEA,SAAgB,mBAAmB,WAAoD;CACtF,OAAO,OAAO,UAAU,cAAc,KAAK,MAAM,WAAW,UAAU,SAAS;AAChF"}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region ts/utils/notEqualMessage.ts
|
|
2
|
+
function notEqualMessage(actual, expected) {
|
|
3
|
+
return `Expected value to equal ${expected}, but received ${actual}`;
|
|
3
4
|
}
|
|
5
|
+
//#endregion
|
|
6
|
+
export { notEqualMessage };
|
|
7
|
+
|
|
4
8
|
//# sourceMappingURL=notEqualMessage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notEqualMessage.js","
|
|
1
|
+
{"version":3,"file":"notEqualMessage.js","names":[],"sources":["../../ts/utils/notEqualMessage.ts"],"sourcesContent":["export function notEqualMessage(actual: any, expected: any) {\n\treturn `Expected value to equal ${expected}, but received ${actual}`\n}\n"],"mappings":";AAAA,SAAgB,gBAAgB,QAAa,UAAe;CAC3D,OAAO,2BAA2B,SAAS,iBAAiB;AAC7D"}
|
|
@@ -1,28 +1,23 @@
|
|
|
1
|
-
import { tersify } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
})
|
|
8
|
-
.join('\n');
|
|
1
|
+
import { tersify } from "tersify";
|
|
2
|
+
//#region ts/utils/notSatisfiedMessage.ts
|
|
3
|
+
function notSatisfiedMessage(entries) {
|
|
4
|
+
return entries.map((e) => {
|
|
5
|
+
return `Expect ${formatPath(e.path)} to satisfy ${formatValue(e.expected)}, but received ${formatValue(e.actual)}`;
|
|
6
|
+
}).join("\n");
|
|
9
7
|
}
|
|
10
8
|
function formatPath(entries) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
nodes.unshift('actual');
|
|
16
|
-
}
|
|
17
|
-
return nodes
|
|
18
|
-
.map(n => (isIndice(n) ? `[${n}]` : '.' + n))
|
|
19
|
-
.join('')
|
|
20
|
-
.slice(1);
|
|
9
|
+
if (entries.length === 0) return "actual";
|
|
10
|
+
const nodes = [...entries];
|
|
11
|
+
if (isIndice(nodes[0])) nodes.unshift("actual");
|
|
12
|
+
return nodes.map((n) => isIndice(n) ? `[${n}]` : "." + n).join("").slice(1);
|
|
21
13
|
}
|
|
22
14
|
function isIndice(node) {
|
|
23
|
-
|
|
15
|
+
return typeof node === "number";
|
|
24
16
|
}
|
|
25
17
|
function formatValue(value) {
|
|
26
|
-
|
|
18
|
+
return tersify(value);
|
|
27
19
|
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { notSatisfiedMessage };
|
|
22
|
+
|
|
28
23
|
//# sourceMappingURL=notSatisfiedMessage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notSatisfiedMessage.js","
|
|
1
|
+
{"version":3,"file":"notSatisfiedMessage.js","names":[],"sources":["../../ts/utils/notSatisfiedMessage.ts"],"sourcesContent":["import type { Diff } from 'satisfier'\nimport { tersify } from 'tersify'\n\nexport function notSatisfiedMessage(entries: Diff[]) {\n\treturn entries\n\t\t.map((e) => {\n\t\t\tconst path = formatPath(e.path)\n\t\t\treturn `Expect ${path} to satisfy ${formatValue(e.expected)}, but received ${formatValue(e.actual)}`\n\t\t})\n\t\t.join('\\n')\n}\n\nfunction formatPath(entries: (string | number)[]) {\n\tif (entries.length === 0) return 'actual'\n\tconst nodes = [...entries]\n\tif (isIndice(nodes[0])) {\n\t\tnodes.unshift('actual')\n\t}\n\treturn nodes\n\t\t.map((n) => (isIndice(n) ? `[${n}]` : '.' + n))\n\t\t.join('')\n\t\t.slice(1)\n}\n\nfunction isIndice(node: string | number): node is number {\n\treturn typeof node === 'number'\n}\n\nfunction formatValue(value: any) {\n\treturn tersify(value)\n}\n"],"mappings":";;AAGA,SAAgB,oBAAoB,SAAiB;CACpD,OAAO,QACL,KAAK,MAAM;EAEX,OAAO,UADM,WAAW,EAAE,IACN,EAAE,cAAc,YAAY,EAAE,QAAQ,EAAE,iBAAiB,YAAY,EAAE,MAAM;CAClG,CAAC,CAAC,CACD,KAAK,IAAI;AACZ;AAEA,SAAS,WAAW,SAA8B;CACjD,IAAI,QAAQ,WAAW,GAAG,OAAO;CACjC,MAAM,QAAQ,CAAC,GAAG,OAAO;CACzB,IAAI,SAAS,MAAM,EAAE,GACpB,MAAM,QAAQ,QAAQ;CAEvB,OAAO,MACL,KAAK,MAAO,SAAS,CAAC,IAAI,IAAI,EAAE,KAAK,MAAM,CAAE,CAAC,CAC9C,KAAK,EAAE,CAAC,CACR,MAAM,CAAC;AACV;AAEA,SAAS,SAAS,MAAuC;CACxD,OAAO,OAAO,SAAS;AACxB;AAEA,SAAS,YAAY,OAAY;CAChC,OAAO,QAAQ,KAAK;AACrB"}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { tersify } from
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { tersify } from "tersify";
|
|
2
|
+
//#region ts/utils/notThrownMessage.ts
|
|
3
|
+
function notThrownMessage(value) {
|
|
4
|
+
return `Expect function to throw, but it returned '${tersify(value)}' instead.`;
|
|
4
5
|
}
|
|
6
|
+
//#endregion
|
|
7
|
+
export { notThrownMessage };
|
|
8
|
+
|
|
5
9
|
//# sourceMappingURL=notThrownMessage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notThrownMessage.js","
|
|
1
|
+
{"version":3,"file":"notThrownMessage.js","names":[],"sources":["../../ts/utils/notThrownMessage.ts"],"sourcesContent":["import { tersify } from 'tersify'\n\nexport function notThrownMessage(value: any) {\n\treturn `Expect function to throw, but it returned '${tersify(value)}' instead.`\n}\n"],"mappings":";;AAEA,SAAgB,iBAAiB,OAAY;CAC5C,OAAO,8CAA8C,QAAQ,KAAK,EAAE;AACrE"}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { tersify } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { tersify } from "tersify";
|
|
2
|
+
//#region ts/utils/promiseMessages.ts
|
|
3
|
+
function notRejectedMessage(value) {
|
|
4
|
+
return "Expected promise to reject, but it resolves with " + (typeof value === "string" ? `'${value}'` : tersify(value, { maxLength: Number.POSITIVE_INFINITY }));
|
|
5
5
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
(typeof error === 'string'
|
|
9
|
-
? `'${error}'`
|
|
10
|
-
: error instanceof Error
|
|
11
|
-
? error
|
|
12
|
-
: tersify(error, { maxLength: Infinity })));
|
|
6
|
+
function notResolvedMessage(error) {
|
|
7
|
+
return "Expected promise to resolve, but it rejects with " + (typeof error === "string" ? `'${error}'` : error instanceof Error ? error : tersify(error, { maxLength: Number.POSITIVE_INFINITY }));
|
|
13
8
|
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { notRejectedMessage, notResolvedMessage };
|
|
11
|
+
|
|
14
12
|
//# sourceMappingURL=promiseMessages.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promiseMessages.js","
|
|
1
|
+
{"version":3,"file":"promiseMessages.js","names":[],"sources":["../../ts/utils/promiseMessages.ts"],"sourcesContent":["import { tersify } from 'tersify'\n\nexport function notRejectedMessage(value: any) {\n\treturn (\n\t\t'Expected promise to reject, but it resolves with ' +\n\t\t(typeof value === 'string' ? `'${value}'` : tersify(value, { maxLength: Number.POSITIVE_INFINITY }))\n\t)\n}\n\nexport function notResolvedMessage(error: any) {\n\treturn (\n\t\t'Expected promise to resolve, but it rejects with ' +\n\t\t(typeof error === 'string'\n\t\t\t? `'${error}'`\n\t\t\t: error instanceof Error\n\t\t\t\t? error\n\t\t\t\t: tersify(error, { maxLength: Number.POSITIVE_INFINITY }))\n\t)\n}\n"],"mappings":";;AAEA,SAAgB,mBAAmB,OAAY;CAC9C,OACC,uDACC,OAAO,UAAU,WAAW,IAAI,MAAM,KAAK,QAAQ,OAAO,EAAE,WAAW,OAAO,kBAAkB,CAAC;AAEpG;AAEA,SAAgB,mBAAmB,OAAY;CAC9C,OACC,uDACC,OAAO,UAAU,WACf,IAAI,MAAM,KACV,iBAAiB,QAChB,QACA,QAAQ,OAAO,EAAE,WAAW,OAAO,kBAAkB,CAAC;AAE5D"}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { isErrorConstructor } from "./isErrorConstructor.js";
|
|
2
|
+
import { tersify } from "tersify";
|
|
3
|
+
//#region ts/utils/unexpectedErrorMessage.ts
|
|
4
|
+
function unexpectedErrorMessage(actual, expected) {
|
|
5
|
+
return `Unexpected error. Expecting '${isErrorConstructor(expected) ? expected.name : tersify(expected)}' but received ${tersify(actual)}`;
|
|
5
6
|
}
|
|
7
|
+
//#endregion
|
|
8
|
+
export { unexpectedErrorMessage };
|
|
9
|
+
|
|
6
10
|
//# sourceMappingURL=unexpectedErrorMessage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unexpectedErrorMessage.js","
|
|
1
|
+
{"version":3,"file":"unexpectedErrorMessage.js","names":[],"sources":["../../ts/utils/unexpectedErrorMessage.ts"],"sourcesContent":["import { tersify } from 'tersify'\nimport type { ErrorConstructor, ErrorValidator } from '../types.js'\nimport { isErrorConstructor } from './isErrorConstructor.js'\n\nexport function unexpectedErrorMessage(actual: any, expected: ErrorValidator | ErrorConstructor<any>) {\n\treturn `Unexpected error. Expecting '${\n\t\tisErrorConstructor(expected) ? expected.name : tersify(expected)\n\t}' but received ${tersify(actual)}`\n}\n"],"mappings":";;;AAIA,SAAgB,uBAAuB,QAAa,UAAkD;CACrG,OAAO,gCACN,mBAAmB,QAAQ,IAAI,SAAS,OAAO,QAAQ,QAAQ,EAC/D,iBAAiB,QAAQ,MAAM;AACjC"}
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "assertron",
|
|
3
|
-
"version": "11.5.
|
|
3
|
+
"version": "11.5.4",
|
|
4
4
|
"description": "A supplementary assertion library",
|
|
5
|
-
"homepage": "https://github.com/
|
|
5
|
+
"homepage": "https://github.com/cyberuni/assertron",
|
|
6
6
|
"bugs": {
|
|
7
|
-
"url": "https://github.com/
|
|
7
|
+
"url": "https://github.com/cyberuni/assertron/issues"
|
|
8
8
|
},
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "https://github.com/
|
|
11
|
+
"url": "https://github.com/cyberuni/assertron.git"
|
|
12
12
|
},
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"author": {
|
|
@@ -37,83 +37,58 @@
|
|
|
37
37
|
"cjs",
|
|
38
38
|
"esm",
|
|
39
39
|
"ts",
|
|
40
|
+
"!ts/testUtils.ts",
|
|
40
41
|
"!**/*.{spec,test,unit,accept,integrate,system,perf,stress}.*"
|
|
41
42
|
],
|
|
42
43
|
"dependencies": {
|
|
43
44
|
"is-promise": "^4.0.0",
|
|
44
|
-
"iso-error": "^6.0.
|
|
45
|
-
"path-equal": "^1.2.
|
|
46
|
-
"satisfier": "^5.4.
|
|
47
|
-
"tersify": "^
|
|
48
|
-
"type-plus": "^7.6.
|
|
45
|
+
"iso-error": "^6.0.5",
|
|
46
|
+
"path-equal": "^1.2.7",
|
|
47
|
+
"satisfier": "^5.4.4",
|
|
48
|
+
"tersify": "^4.0.6",
|
|
49
|
+
"type-plus": "^7.6.2"
|
|
49
50
|
},
|
|
50
51
|
"devDependencies": {
|
|
51
|
-
"@
|
|
52
|
-
"@
|
|
53
|
-
"@commitlint/
|
|
54
|
-
"@
|
|
55
|
-
"@
|
|
52
|
+
"@biomejs/biome": "^2.5.11",
|
|
53
|
+
"@changesets/cli": "^3.0.1",
|
|
54
|
+
"@commitlint/cli": "^21.2.2",
|
|
55
|
+
"@commitlint/config-conventional": "^21.2.2",
|
|
56
|
+
"@repobuddy/biome": "^2.3.1",
|
|
57
|
+
"@size-limit/preset-small-lib": "^13.0.3",
|
|
56
58
|
"@types/lodash": "^4.14.182",
|
|
57
|
-
"@types/
|
|
58
|
-
"@
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"eslint": "^8.47.0",
|
|
62
|
-
"eslint-config-prettier": "^9.0.0",
|
|
63
|
-
"eslint-plugin-harmony": "^7.1.2",
|
|
64
|
-
"husky": "^8.0.1",
|
|
65
|
-
"jest": "^29.0.0",
|
|
66
|
-
"jest-validate": "^29.0.0",
|
|
67
|
-
"jest-watch-suspend": "^1.1.2",
|
|
68
|
-
"jest-watch-toggle-config": "^3.0.0",
|
|
69
|
-
"jest-watch-typeahead": "^2.0.0",
|
|
59
|
+
"@types/node": "^26.4.0",
|
|
60
|
+
"@vitest/coverage-v8": "^4.1.11",
|
|
61
|
+
"husky": "^9.1.7",
|
|
62
|
+
"knip": "~6.33.0",
|
|
70
63
|
"lodash": "^4.17.21",
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"tslib": "^2.4.0",
|
|
78
|
-
"typescript": "^5.0.0"
|
|
64
|
+
"rimraf": "^6.1.3",
|
|
65
|
+
"size-limit": "^13.0.3",
|
|
66
|
+
"tsdown": "^0.22.14",
|
|
67
|
+
"turbo": "^2.10.12",
|
|
68
|
+
"typescript": "^7.0.2",
|
|
69
|
+
"vitest": "^4.1.11"
|
|
79
70
|
},
|
|
80
|
-
"packageManager": "pnpm@8.15.5",
|
|
81
71
|
"engines": {
|
|
82
|
-
"node": ">=
|
|
72
|
+
"node": ">=20"
|
|
83
73
|
},
|
|
84
|
-
"size-limit": [
|
|
85
|
-
{
|
|
86
|
-
"path": "./cjs/index.js",
|
|
87
|
-
"limit": "15 KB"
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
"path": "./esm/index.js",
|
|
91
|
-
"limit": "10 KB"
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
"path": "./tslib/index.js",
|
|
95
|
-
"limit": "15 KB"
|
|
96
|
-
}
|
|
97
|
-
],
|
|
98
74
|
"scripts": {
|
|
99
|
-
"build": "
|
|
100
|
-
"
|
|
101
|
-
"
|
|
102
|
-
"
|
|
103
|
-
"
|
|
104
|
-
"clean": "rimraf cjs esm coverage lib libm",
|
|
75
|
+
"build": "tsdown",
|
|
76
|
+
"check": "biome check",
|
|
77
|
+
"check:fix": "biome check --write",
|
|
78
|
+
"clean": "rimraf cjs esm coverage lib libm tslib *.tsbuildinfo",
|
|
79
|
+
"coverage": "vitest run --coverage",
|
|
105
80
|
"cs": "changeset",
|
|
106
|
-
"
|
|
107
|
-
"
|
|
108
|
-
"
|
|
109
|
-
"
|
|
110
|
-
"
|
|
111
|
-
"test": "jest",
|
|
112
|
-
"test:watch": "jest --watch",
|
|
113
|
-
"test:type": "tsc",
|
|
81
|
+
"dev": "vitest",
|
|
82
|
+
"format": "biome format --write .",
|
|
83
|
+
"knip": "knip",
|
|
84
|
+
"lint": "biome lint .",
|
|
85
|
+
"nuke": "pnpm clean && rimraf node_modules .turbo",
|
|
114
86
|
"release": "changeset publish",
|
|
115
|
-
"
|
|
116
|
-
"
|
|
117
|
-
"watch": "
|
|
87
|
+
"size": "size-limit",
|
|
88
|
+
"test": "vitest run",
|
|
89
|
+
"test:watch": "vitest",
|
|
90
|
+
"typecheck": "tsc",
|
|
91
|
+
"verify": "biome ci . && turbo run build typecheck coverage knip size",
|
|
92
|
+
"version": "changeset version"
|
|
118
93
|
}
|
|
119
94
|
}
|
|
@@ -68,9 +68,11 @@ export class AssertOrder {
|
|
|
68
68
|
if (this.state.step === step) {
|
|
69
69
|
this.state.move()
|
|
70
70
|
return this.state.moveSubStep()
|
|
71
|
-
}
|
|
71
|
+
}
|
|
72
|
+
if (this.state.step === nextStep && this.state.subStep > 0) {
|
|
72
73
|
return this.state.moveSubStep()
|
|
73
|
-
}
|
|
74
|
+
}
|
|
75
|
+
throw new InvalidOrder(this.state.get(), 'atLeastOnce', [step], { ssf: this.atLeastOnce })
|
|
74
76
|
}
|
|
75
77
|
|
|
76
78
|
any(steps: number[], handler?: (step: number) => void) {
|
|
@@ -84,11 +86,11 @@ export class AssertOrder {
|
|
|
84
86
|
// false positive on `step: number`
|
|
85
87
|
// eslint-disable-next-line
|
|
86
88
|
onAny(steps: number[], ...asserts: Array<(step: number) => unknown>) {
|
|
87
|
-
steps.forEach(step => {
|
|
89
|
+
steps.forEach((step) => {
|
|
88
90
|
this.state.on(step, () => {
|
|
89
91
|
let firstError: any
|
|
90
92
|
let hasPass = false
|
|
91
|
-
asserts.forEach(assert => {
|
|
93
|
+
asserts.forEach((assert) => {
|
|
92
94
|
try {
|
|
93
95
|
assert(step)
|
|
94
96
|
hasPass = true
|
|
@@ -105,7 +107,7 @@ export class AssertOrder {
|
|
|
105
107
|
end(): number
|
|
106
108
|
end(timeout?: number) {
|
|
107
109
|
if (timeout) {
|
|
108
|
-
return new Promise(r => {
|
|
110
|
+
return new Promise((r) => {
|
|
109
111
|
setTimeout(r, timeout)
|
|
110
112
|
}).then(() => {
|
|
111
113
|
return this.end()
|
|
@@ -137,7 +139,7 @@ export class AssertOrder {
|
|
|
137
139
|
wait(step: number, callback?: () => void) {
|
|
138
140
|
if (callback) this.on(step, callback)
|
|
139
141
|
else
|
|
140
|
-
return new Promise<any>(a => {
|
|
142
|
+
return new Promise<any>((a) => {
|
|
141
143
|
this.on(step, a)
|
|
142
144
|
})
|
|
143
145
|
}
|