( primitive: Primitive.Primitive<A>, arb: fc.Arbitrary<A>, primitiveTypeName: string )
| 113 | }) |
| 114 | |
| 115 | const simplePrimitiveTestSuite = <A>( |
| 116 | primitive: Primitive.Primitive<A>, |
| 117 | arb: fc.Arbitrary<A>, |
| 118 | primitiveTypeName: string |
| 119 | ) => { |
| 120 | describe(`${primitiveTypeName}`, () => { |
| 121 | it(`validates that valid values are accepted`, () => |
| 122 | fc.assert(fc.asyncProperty(arb, (value) => |
| 123 | Effect.gen(function*() { |
| 124 | const str = value instanceof Date ? value.toISOString() : `${value}` |
| 125 | const result = yield* Primitive.validate(primitive, Option.some(str), CliConfig.defaultConfig) |
| 126 | expect(result).toEqual(value) |
| 127 | }).pipe(runEffect)))) |
| 128 | |
| 129 | it(`validates that invalid values are rejected`, () => |
| 130 | Effect.gen(function*() { |
| 131 | const result = yield* Effect.flip(Primitive.validate(primitive, Option.some("bad"), CliConfig.defaultConfig)) |
| 132 | expect(result).toBe(`'bad' is not a ${Primitive.getTypeName(primitive)}`) |
| 133 | }).pipe(runEffect)) |
| 134 | }) |
| 135 | } |
| 136 | |
| 137 | const randomizeCharacterCases = (str: string): string => { |
| 138 | let result = "" |
no test coverage detected