@clipboard-health/testing-core 0.3.1 → 0.4.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/README.md CHANGED
@@ -62,14 +62,14 @@ ok(length === 2);
62
62
  import { ok } from "node:assert/strict";
63
63
 
64
64
  import { expectToBeLeft } from "@clipboard-health/testing-core";
65
- import { type Either, left, right } from "@clipboard-health/util-typescript";
65
+ import { either as E } from "@clipboard-health/util-typescript";
66
66
 
67
- function divide(numerator: number, denominator: number): Either<string, number> {
67
+ function divide(numerator: number, denominator: number): E.Either<string, number> {
68
68
  if (denominator === 0) {
69
- return left("Cannot divide by zero");
69
+ return E.left("Cannot divide by zero");
70
70
  }
71
71
 
72
- return right(numerator / denominator);
72
+ return E.right(numerator / denominator);
73
73
  }
74
74
 
75
75
  const value = divide(10, 0);
@@ -87,14 +87,14 @@ ok(value.left === "Cannot divide by zero");
87
87
  import { ok } from "node:assert/strict";
88
88
 
89
89
  import { expectToBeRight } from "@clipboard-health/testing-core";
90
- import { type Either, left, right } from "@clipboard-health/util-typescript";
90
+ import { either as E } from "@clipboard-health/util-typescript";
91
91
 
92
- function divide(numerator: number, denominator: number): Either<string, number> {
92
+ function divide(numerator: number, denominator: number): E.Either<string, number> {
93
93
  if (denominator === 0) {
94
- return left("Cannot divide by zero");
94
+ return E.left("Cannot divide by zero");
95
95
  }
96
96
 
97
- return right(numerator / denominator);
97
+ return E.right(numerator / denominator);
98
98
  }
99
99
 
100
100
  const value = divide(10, 2);
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@clipboard-health/testing-core",
3
3
  "description": "TypeScript-friendly testing utilities.",
4
- "version": "0.3.1",
4
+ "version": "0.4.0",
5
5
  "dependencies": {
6
- "@clipboard-health/util-typescript": "0.1.1",
6
+ "@clipboard-health/util-typescript": "0.2.0",
7
7
  "tslib": "2.8.0",
8
8
  "zod": "3.23.8"
9
9
  },
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.expectToBeDefined = expectToBeDefined;
4
- const node_assert_1 = require("node:assert");
4
+ const strict_1 = require("node:assert/strict");
5
5
  /**
6
6
  * Asserts and narrows the type for defined values.
7
7
  *
8
8
  * @throws {AssertionError} for null or undefined values.
9
9
  */
10
10
  function expectToBeDefined(value) {
11
- (0, node_assert_1.ok)(value !== undefined && value !== null, "Expected value to be defined, got null or undefined");
11
+ (0, strict_1.ok)(value !== undefined && value !== null, "Expected value to be defined, got null or undefined");
12
12
  }
13
13
  //# sourceMappingURL=expectToBeDefined.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"expectToBeDefined.js","sourceRoot":"","sources":["../../../../../packages/testing-core/src/lib/expectToBeDefined.ts"],"names":[],"mappings":";;AAOA,8CAEC;AATD,6CAAiC;AAEjC;;;;GAIG;AACH,SAAgB,iBAAiB,CAAI,KAAoB;IACvD,IAAA,gBAAE,EAAC,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,qDAAqD,CAAC,CAAC;AACnG,CAAC"}
1
+ {"version":3,"file":"expectToBeDefined.js","sourceRoot":"","sources":["../../../../../packages/testing-core/src/lib/expectToBeDefined.ts"],"names":[],"mappings":";;AAOA,8CAEC;AATD,+CAAwC;AAExC;;;;GAIG;AACH,SAAgB,iBAAiB,CAAI,KAAoB;IACvD,IAAA,WAAE,EAAC,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,qDAAqD,CAAC,CAAC;AACnG,CAAC"}
@@ -1,2 +1,7 @@
1
- import { type Either, type Left } from "@clipboard-health/util-typescript";
2
- export declare function expectToBeLeft<E, A>(value: Either<E, A> | undefined): asserts value is Left<E>;
1
+ import { either as E } from "@clipboard-health/util-typescript";
2
+ /**
3
+ * Asserts and narrows the type of the provided Either value to Left.
4
+ * @param value - The Either value to check
5
+ * @throws {AssertionError} If the value is undefined or not a Left
6
+ */
7
+ export declare function expectToBeLeft<E, A>(value: E.Either<E, A> | undefined): asserts value is E.Left<E>;
@@ -1,11 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.expectToBeLeft = expectToBeLeft;
4
- const node_assert_1 = require("node:assert");
4
+ const strict_1 = require("node:assert/strict");
5
5
  const util_typescript_1 = require("@clipboard-health/util-typescript");
6
6
  const expectToBeDefined_1 = require("./expectToBeDefined");
7
+ /**
8
+ * Asserts and narrows the type of the provided Either value to Left.
9
+ * @param value - The Either value to check
10
+ * @throws {AssertionError} If the value is undefined or not a Left
11
+ */
7
12
  function expectToBeLeft(value) {
8
13
  (0, expectToBeDefined_1.expectToBeDefined)(value);
9
- (0, node_assert_1.ok)((0, util_typescript_1.isLeft)(value));
14
+ (0, strict_1.ok)(util_typescript_1.either.isLeft(value));
10
15
  }
11
16
  //# sourceMappingURL=expectToBeLeft.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"expectToBeLeft.js","sourceRoot":"","sources":["../../../../../packages/testing-core/src/lib/expectToBeLeft.ts"],"names":[],"mappings":";;AAMA,wCAGC;AATD,6CAAiC;AAEjC,uEAAmF;AAEnF,2DAAwD;AAExD,SAAgB,cAAc,CAAO,KAA+B;IAClE,IAAA,qCAAiB,EAAC,KAAK,CAAC,CAAC;IACzB,IAAA,gBAAE,EAAC,IAAA,wBAAM,EAAC,KAAK,CAAC,CAAC,CAAC;AACpB,CAAC"}
1
+ {"version":3,"file":"expectToBeLeft.js","sourceRoot":"","sources":["../../../../../packages/testing-core/src/lib/expectToBeLeft.ts"],"names":[],"mappings":";;AAWA,wCAKC;AAhBD,+CAAwC;AAExC,uEAAgE;AAEhE,2DAAwD;AAExD;;;;GAIG;AACH,SAAgB,cAAc,CAC5B,KAAiC;IAEjC,IAAA,qCAAiB,EAAC,KAAK,CAAC,CAAC;IACzB,IAAA,WAAE,EAAC,wBAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AACtB,CAAC"}
@@ -1,2 +1,7 @@
1
- import { type None, type Option } from "@clipboard-health/util-typescript";
2
- export declare function expectToBeNone<A>(value: Option<A> | undefined): asserts value is None;
1
+ import { option as O } from "@clipboard-health/util-typescript";
2
+ /**
3
+ * Asserts and narrows the type of the provided Option value to None.
4
+ * @param value - The Option value to check
5
+ * @throws {AssertionError} If the value is undefined or not a None
6
+ */
7
+ export declare function expectToBeNone<A>(value: O.Option<A> | undefined): asserts value is O.None;
@@ -1,11 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.expectToBeNone = expectToBeNone;
4
- const node_assert_1 = require("node:assert");
4
+ const strict_1 = require("node:assert/strict");
5
5
  const util_typescript_1 = require("@clipboard-health/util-typescript");
6
6
  const expectToBeDefined_1 = require("./expectToBeDefined");
7
+ /**
8
+ * Asserts and narrows the type of the provided Option value to None.
9
+ * @param value - The Option value to check
10
+ * @throws {AssertionError} If the value is undefined or not a None
11
+ */
7
12
  function expectToBeNone(value) {
8
13
  (0, expectToBeDefined_1.expectToBeDefined)(value);
9
- (0, node_assert_1.ok)((0, util_typescript_1.isNone)(value));
14
+ (0, strict_1.ok)(util_typescript_1.option.isNone(value));
10
15
  }
11
16
  //# sourceMappingURL=expectToBeNone.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"expectToBeNone.js","sourceRoot":"","sources":["../../../../../packages/testing-core/src/lib/expectToBeNone.ts"],"names":[],"mappings":";;AAMA,wCAGC;AATD,6CAAiC;AAEjC,uEAAmF;AAEnF,2DAAwD;AAExD,SAAgB,cAAc,CAAI,KAA4B;IAC5D,IAAA,qCAAiB,EAAC,KAAK,CAAC,CAAC;IACzB,IAAA,gBAAE,EAAC,IAAA,wBAAM,EAAC,KAAK,CAAC,CAAC,CAAC;AACpB,CAAC"}
1
+ {"version":3,"file":"expectToBeNone.js","sourceRoot":"","sources":["../../../../../packages/testing-core/src/lib/expectToBeNone.ts"],"names":[],"mappings":";;AAWA,wCAGC;AAdD,+CAAwC;AAExC,uEAAgE;AAEhE,2DAAwD;AAExD;;;;GAIG;AACH,SAAgB,cAAc,CAAI,KAA8B;IAC9D,IAAA,qCAAiB,EAAC,KAAK,CAAC,CAAC;IACzB,IAAA,WAAE,EAAC,wBAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AACtB,CAAC"}
@@ -1,2 +1,7 @@
1
- import { type Either, type Right } from "@clipboard-health/util-typescript";
2
- export declare function expectToBeRight<A, E>(value: Either<E, A> | undefined): asserts value is Right<A>;
1
+ import { either as E } from "@clipboard-health/util-typescript";
2
+ /**
3
+ * Asserts and narrows the type of the provided Either value to Right.
4
+ * @param value - The Either value to check
5
+ * @throws {AssertionError} If the value is undefined or not a Right
6
+ */
7
+ export declare function expectToBeRight<A, E>(value: E.Either<E, A> | undefined): asserts value is E.Right<A>;
@@ -1,11 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.expectToBeRight = expectToBeRight;
4
- const node_assert_1 = require("node:assert");
4
+ const strict_1 = require("node:assert/strict");
5
5
  const util_typescript_1 = require("@clipboard-health/util-typescript");
6
6
  const expectToBeDefined_1 = require("./expectToBeDefined");
7
+ /**
8
+ * Asserts and narrows the type of the provided Either value to Right.
9
+ * @param value - The Either value to check
10
+ * @throws {AssertionError} If the value is undefined or not a Right
11
+ */
7
12
  function expectToBeRight(value) {
8
13
  (0, expectToBeDefined_1.expectToBeDefined)(value);
9
- (0, node_assert_1.ok)((0, util_typescript_1.isRight)(value));
14
+ (0, strict_1.ok)(util_typescript_1.either.isRight(value));
10
15
  }
11
16
  //# sourceMappingURL=expectToBeRight.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"expectToBeRight.js","sourceRoot":"","sources":["../../../../../packages/testing-core/src/lib/expectToBeRight.ts"],"names":[],"mappings":";;AAMA,0CAGC;AATD,6CAAiC;AAEjC,uEAAqF;AAErF,2DAAwD;AAExD,SAAgB,eAAe,CAAO,KAA+B;IACnE,IAAA,qCAAiB,EAAC,KAAK,CAAC,CAAC;IACzB,IAAA,gBAAE,EAAC,IAAA,yBAAO,EAAC,KAAK,CAAC,CAAC,CAAC;AACrB,CAAC"}
1
+ {"version":3,"file":"expectToBeRight.js","sourceRoot":"","sources":["../../../../../packages/testing-core/src/lib/expectToBeRight.ts"],"names":[],"mappings":";;AAWA,0CAKC;AAhBD,+CAAwC;AAExC,uEAAgE;AAEhE,2DAAwD;AAExD;;;;GAIG;AACH,SAAgB,eAAe,CAC7B,KAAiC;IAEjC,IAAA,qCAAiB,EAAC,KAAK,CAAC,CAAC;IACzB,IAAA,WAAE,EAAC,wBAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;AACvB,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { type SafeParseError, type SafeParseReturnType } from "zod";
2
2
  /**
3
3
  * Asserts and narrows the type for Zod SafeParseReturnType to a SafeParseError.
4
- *
4
+ * @param value - The SafeParseReturnType value to check
5
5
  * @throws {AssertionError} for SafeParseSuccess.
6
6
  */
7
7
  export declare function expectToBeSafeParseError<Input, Output>(value: Readonly<SafeParseReturnType<Input, Output>>): asserts value is SafeParseError<Input>;
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.expectToBeSafeParseError = expectToBeSafeParseError;
4
- const node_assert_1 = require("node:assert");
4
+ const strict_1 = require("node:assert/strict");
5
5
  const expectToBeDefined_1 = require("./expectToBeDefined");
6
6
  /**
7
7
  * Asserts and narrows the type for Zod SafeParseReturnType to a SafeParseError.
8
- *
8
+ * @param value - The SafeParseReturnType value to check
9
9
  * @throws {AssertionError} for SafeParseSuccess.
10
10
  */
11
11
  function expectToBeSafeParseError(value) {
12
12
  (0, expectToBeDefined_1.expectToBeDefined)(value);
13
- (0, node_assert_1.ok)(!value.success, "Expected SafeParseError, got SafeParseSuccess");
13
+ (0, strict_1.ok)(!value.success, "Expected SafeParseError, got SafeParseSuccess");
14
14
  }
15
15
  //# sourceMappingURL=expectToBeSafeParseError.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"expectToBeSafeParseError.js","sourceRoot":"","sources":["../../../../../packages/testing-core/src/lib/expectToBeSafeParseError.ts"],"names":[],"mappings":";;AAWA,4DAKC;AAhBD,6CAAiC;AAIjC,2DAAwD;AAExD;;;;GAIG;AACH,SAAgB,wBAAwB,CACtC,KAAmD;IAEnD,IAAA,qCAAiB,EAAC,KAAK,CAAC,CAAC;IACzB,IAAA,gBAAE,EAAC,CAAC,KAAK,CAAC,OAAO,EAAE,+CAA+C,CAAC,CAAC;AACtE,CAAC"}
1
+ {"version":3,"file":"expectToBeSafeParseError.js","sourceRoot":"","sources":["../../../../../packages/testing-core/src/lib/expectToBeSafeParseError.ts"],"names":[],"mappings":";;AAWA,4DAKC;AAhBD,+CAAwC;AAIxC,2DAAwD;AAExD;;;;GAIG;AACH,SAAgB,wBAAwB,CACtC,KAAmD;IAEnD,IAAA,qCAAiB,EAAC,KAAK,CAAC,CAAC;IACzB,IAAA,WAAE,EAAC,CAAC,KAAK,CAAC,OAAO,EAAE,+CAA+C,CAAC,CAAC;AACtE,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { type SafeParseReturnType, type SafeParseSuccess } from "zod";
2
2
  /**
3
3
  * Asserts and narrows the type for Zod SafeParseReturnType to a SafeParseSuccess.
4
- *
4
+ * @param value - The SafeParseReturnType value to check
5
5
  * @throws {AssertionError} for SafeParseError.
6
6
  */
7
7
  export declare function expectToBeSafeParseSuccess<Input, Output>(value: Readonly<SafeParseReturnType<Input, Output>>): asserts value is SafeParseSuccess<Output>;
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.expectToBeSafeParseSuccess = expectToBeSafeParseSuccess;
4
- const node_assert_1 = require("node:assert");
4
+ const strict_1 = require("node:assert/strict");
5
5
  const expectToBeDefined_1 = require("./expectToBeDefined");
6
6
  /**
7
7
  * Asserts and narrows the type for Zod SafeParseReturnType to a SafeParseSuccess.
8
- *
8
+ * @param value - The SafeParseReturnType value to check
9
9
  * @throws {AssertionError} for SafeParseError.
10
10
  */
11
11
  function expectToBeSafeParseSuccess(value) {
12
12
  (0, expectToBeDefined_1.expectToBeDefined)(value);
13
- (0, node_assert_1.ok)(value.success, "Expected SafeParseSuccess, got SafeParseError");
13
+ (0, strict_1.ok)(value.success, "Expected SafeParseSuccess, got SafeParseError");
14
14
  }
15
15
  //# sourceMappingURL=expectToBeSafeParseSuccess.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"expectToBeSafeParseSuccess.js","sourceRoot":"","sources":["../../../../../packages/testing-core/src/lib/expectToBeSafeParseSuccess.ts"],"names":[],"mappings":";;AAWA,gEAKC;AAhBD,6CAAiC;AAIjC,2DAAwD;AAExD;;;;GAIG;AACH,SAAgB,0BAA0B,CACxC,KAAmD;IAEnD,IAAA,qCAAiB,EAAC,KAAK,CAAC,CAAC;IACzB,IAAA,gBAAE,EAAC,KAAK,CAAC,OAAO,EAAE,+CAA+C,CAAC,CAAC;AACrE,CAAC"}
1
+ {"version":3,"file":"expectToBeSafeParseSuccess.js","sourceRoot":"","sources":["../../../../../packages/testing-core/src/lib/expectToBeSafeParseSuccess.ts"],"names":[],"mappings":";;AAWA,gEAKC;AAhBD,+CAAwC;AAIxC,2DAAwD;AAExD;;;;GAIG;AACH,SAAgB,0BAA0B,CACxC,KAAmD;IAEnD,IAAA,qCAAiB,EAAC,KAAK,CAAC,CAAC;IACzB,IAAA,WAAE,EAAC,KAAK,CAAC,OAAO,EAAE,+CAA+C,CAAC,CAAC;AACrE,CAAC"}
@@ -1,2 +1,7 @@
1
- import { type Option, type Some } from "@clipboard-health/util-typescript";
2
- export declare function expectToBeSome<A>(value: Option<A> | undefined): asserts value is Some<A>;
1
+ import { option as O } from "@clipboard-health/util-typescript";
2
+ /**
3
+ * Asserts and narrows the type of the provided Option value to Some.
4
+ * @param value - The Option value to check
5
+ * @throws {AssertionError} If the value is undefined or not Some
6
+ */
7
+ export declare function expectToBeSome<A>(value: O.Option<A> | undefined): asserts value is O.Some<A>;
@@ -1,11 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.expectToBeSome = expectToBeSome;
4
- const node_assert_1 = require("node:assert");
4
+ const strict_1 = require("node:assert/strict");
5
5
  const util_typescript_1 = require("@clipboard-health/util-typescript");
6
6
  const expectToBeDefined_1 = require("./expectToBeDefined");
7
+ /**
8
+ * Asserts and narrows the type of the provided Option value to Some.
9
+ * @param value - The Option value to check
10
+ * @throws {AssertionError} If the value is undefined or not Some
11
+ */
7
12
  function expectToBeSome(value) {
8
13
  (0, expectToBeDefined_1.expectToBeDefined)(value);
9
- (0, node_assert_1.ok)((0, util_typescript_1.isSome)(value));
14
+ (0, strict_1.ok)(util_typescript_1.option.isSome(value));
10
15
  }
11
16
  //# sourceMappingURL=expectToBeSome.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"expectToBeSome.js","sourceRoot":"","sources":["../../../../../packages/testing-core/src/lib/expectToBeSome.ts"],"names":[],"mappings":";;AAMA,wCAGC;AATD,6CAAiC;AAEjC,uEAAmF;AAEnF,2DAAwD;AAExD,SAAgB,cAAc,CAAI,KAA4B;IAC5D,IAAA,qCAAiB,EAAC,KAAK,CAAC,CAAC;IACzB,IAAA,gBAAE,EAAC,IAAA,wBAAM,EAAC,KAAK,CAAC,CAAC,CAAC;AACpB,CAAC"}
1
+ {"version":3,"file":"expectToBeSome.js","sourceRoot":"","sources":["../../../../../packages/testing-core/src/lib/expectToBeSome.ts"],"names":[],"mappings":";;AAWA,wCAGC;AAdD,+CAAwC;AAExC,uEAAgE;AAEhE,2DAAwD;AAExD;;;;GAIG;AACH,SAAgB,cAAc,CAAI,KAA8B;IAC9D,IAAA,qCAAiB,EAAC,KAAK,CAAC,CAAC;IACzB,IAAA,WAAE,EAAC,wBAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AACtB,CAAC"}