@clipboard-health/testing-core 0.2.0 → 0.3.1

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
@@ -55,6 +55,56 @@ ok(length === 2);
55
55
 
56
56
  ```
57
57
 
58
+ <!-- prettier-ignore -->
59
+ ```ts
60
+ // ./examples/expectToBeLeft.ts
61
+
62
+ import { ok } from "node:assert/strict";
63
+
64
+ import { expectToBeLeft } from "@clipboard-health/testing-core";
65
+ import { type Either, left, right } from "@clipboard-health/util-typescript";
66
+
67
+ function divide(numerator: number, denominator: number): Either<string, number> {
68
+ if (denominator === 0) {
69
+ return left("Cannot divide by zero");
70
+ }
71
+
72
+ return right(numerator / denominator);
73
+ }
74
+
75
+ const value = divide(10, 0);
76
+ expectToBeLeft(value);
77
+
78
+ // Narrowed to Left
79
+ ok(value.left === "Cannot divide by zero");
80
+
81
+ ```
82
+
83
+ <!-- prettier-ignore -->
84
+ ```ts
85
+ // ./examples/expectToBeRight.ts
86
+
87
+ import { ok } from "node:assert/strict";
88
+
89
+ import { expectToBeRight } from "@clipboard-health/testing-core";
90
+ import { type Either, left, right } from "@clipboard-health/util-typescript";
91
+
92
+ function divide(numerator: number, denominator: number): Either<string, number> {
93
+ if (denominator === 0) {
94
+ return left("Cannot divide by zero");
95
+ }
96
+
97
+ return right(numerator / denominator);
98
+ }
99
+
100
+ const value = divide(10, 2);
101
+ expectToBeRight(value);
102
+
103
+ // Narrowed to Right
104
+ ok(value.right === 5);
105
+
106
+ ```
107
+
58
108
  <!-- prettier-ignore -->
59
109
  ```ts
60
110
  // ./examples/expectToBeSafeParseError.ts
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@clipboard-health/testing-core",
3
3
  "description": "TypeScript-friendly testing utilities.",
4
- "version": "0.2.0",
4
+ "version": "0.3.1",
5
5
  "dependencies": {
6
+ "@clipboard-health/util-typescript": "0.1.1",
6
7
  "tslib": "2.8.0",
7
8
  "zod": "3.23.8"
8
9
  },
package/src/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
1
  export * from "./lib/expectToBeDefined";
2
+ export * from "./lib/expectToBeLeft";
3
+ export * from "./lib/expectToBeRight";
2
4
  export * from "./lib/expectToBeSafeParseError";
3
5
  export * from "./lib/expectToBeSafeParseSuccess";
package/src/index.js CHANGED
@@ -2,6 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./lib/expectToBeDefined"), exports);
5
+ tslib_1.__exportStar(require("./lib/expectToBeLeft"), exports);
6
+ tslib_1.__exportStar(require("./lib/expectToBeRight"), exports);
5
7
  tslib_1.__exportStar(require("./lib/expectToBeSafeParseError"), exports);
6
8
  tslib_1.__exportStar(require("./lib/expectToBeSafeParseSuccess"), exports);
7
9
  //# sourceMappingURL=index.js.map
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/testing-core/src/index.ts"],"names":[],"mappings":";;;AAAA,kEAAwC;AACxC,yEAA+C;AAC/C,2EAAiD"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/testing-core/src/index.ts"],"names":[],"mappings":";;;AAAA,kEAAwC;AACxC,+DAAqC;AACrC,gEAAsC;AACtC,yEAA+C;AAC/C,2EAAiD"}
@@ -0,0 +1,2 @@
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>;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.expectToBeLeft = expectToBeLeft;
4
+ const node_assert_1 = require("node:assert");
5
+ const util_typescript_1 = require("@clipboard-health/util-typescript");
6
+ const expectToBeDefined_1 = require("./expectToBeDefined");
7
+ function expectToBeLeft(value) {
8
+ (0, expectToBeDefined_1.expectToBeDefined)(value);
9
+ (0, node_assert_1.ok)((0, util_typescript_1.isLeft)(value));
10
+ }
11
+ //# sourceMappingURL=expectToBeLeft.js.map
@@ -0,0 +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"}
@@ -0,0 +1,2 @@
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;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.expectToBeNone = expectToBeNone;
4
+ const node_assert_1 = require("node:assert");
5
+ const util_typescript_1 = require("@clipboard-health/util-typescript");
6
+ const expectToBeDefined_1 = require("./expectToBeDefined");
7
+ function expectToBeNone(value) {
8
+ (0, expectToBeDefined_1.expectToBeDefined)(value);
9
+ (0, node_assert_1.ok)((0, util_typescript_1.isNone)(value));
10
+ }
11
+ //# sourceMappingURL=expectToBeNone.js.map
@@ -0,0 +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"}
@@ -0,0 +1,2 @@
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>;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.expectToBeRight = expectToBeRight;
4
+ const node_assert_1 = require("node:assert");
5
+ const util_typescript_1 = require("@clipboard-health/util-typescript");
6
+ const expectToBeDefined_1 = require("./expectToBeDefined");
7
+ function expectToBeRight(value) {
8
+ (0, expectToBeDefined_1.expectToBeDefined)(value);
9
+ (0, node_assert_1.ok)((0, util_typescript_1.isRight)(value));
10
+ }
11
+ //# sourceMappingURL=expectToBeRight.js.map
@@ -0,0 +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"}
@@ -0,0 +1,2 @@
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>;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.expectToBeSome = expectToBeSome;
4
+ const node_assert_1 = require("node:assert");
5
+ const util_typescript_1 = require("@clipboard-health/util-typescript");
6
+ const expectToBeDefined_1 = require("./expectToBeDefined");
7
+ function expectToBeSome(value) {
8
+ (0, expectToBeDefined_1.expectToBeDefined)(value);
9
+ (0, node_assert_1.ok)((0, util_typescript_1.isSome)(value));
10
+ }
11
+ //# sourceMappingURL=expectToBeSome.js.map
@@ -0,0 +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"}