@clipboard-health/testing-core 0.2.0 → 0.3.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 +50 -0
- package/package.json +2 -1
- package/src/index.d.ts +2 -0
- package/src/index.js +2 -0
- package/src/index.js.map +1 -1
- package/src/lib/expectToBeLeft.d.ts +2 -0
- package/src/lib/expectToBeLeft.js +11 -0
- package/src/lib/expectToBeLeft.js.map +1 -0
- package/src/lib/expectToBeNone.d.ts +2 -0
- package/src/lib/expectToBeNone.js +11 -0
- package/src/lib/expectToBeNone.js.map +1 -0
- package/src/lib/expectToBeRight.d.ts +2 -0
- package/src/lib/expectToBeRight.js +11 -0
- package/src/lib/expectToBeRight.js.map +1 -0
- package/src/lib/expectToBeSome.d.ts +2 -0
- package/src/lib/expectToBeSome.js +11 -0
- package/src/lib/expectToBeSome.js.map +1 -0
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
package/src/index.d.ts
CHANGED
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,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,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,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,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"}
|