* Returns an object with `succeed` and `fail` helpers for testing the schema's `make` operation. * * **When to use** * * Use to assert how `Schema.make` accepts, transforms, or rejects * construction input for this schema. * * **Details** * * `succeed(input)` asserts make
(options?: Schema.MakeOptions)
| 117 | * @see {@link encoding} for assertions against encoded output |
| 118 | */ |
| 119 | make(options?: Schema.MakeOptions) { |
| 120 | const makeEffect = SchemaParser.makeEffect(this.schema) |
| 121 | async function succeed(input: S["Type"]): Promise<void> |
| 122 | async function succeed(input: S["~type.make.in"], expected: S["Type"]): Promise<void> |
| 123 | async function succeed(input: S["~type.make.in"], expected?: S["Type"]) { |
| 124 | const r = await Effect.runPromise( |
| 125 | makeEffect(input, options).pipe( |
| 126 | Effect.mapErrorEager(SchemaIssue.defaultFormatter), |
| 127 | Effect.result |
| 128 | ) |
| 129 | ) |
| 130 | expected = arguments.length === 1 ? input : expected |
| 131 | assert.deepStrictEqual(r, Result.succeed(expected)) |
| 132 | } |
| 133 | return { |
| 134 | succeed, |
| 135 | async fail(input: unknown, message: string) { |
| 136 | const r = await Effect.runPromise( |
| 137 | makeEffect(input, options).pipe( |
| 138 | Effect.mapErrorEager(SchemaIssue.defaultFormatter), |
| 139 | Effect.result |
| 140 | ) |
| 141 | ) |
| 142 | assert.deepStrictEqual(r, Result.fail(message)) |
| 143 | } |
| 144 | } |
| 145 | } |
| 146 | /** |
| 147 | * Runs a property-based test that encodes arbitrary values and then decodes them, asserting the decoded value equals the original. |
| 148 | * |
nothing calls this directly
no test coverage detected