| 23 | } |
| 24 | |
| 25 | export function assertSchemas( |
| 26 | module: Codegen.Module, |
| 27 | expected: Readonly<Record<string, SchemaRepresentation.Code>>, |
| 28 | imports: ReadonlyArray<string> = ["import * as Schema from \"effect/Schema\""] |
| 29 | ): void { |
| 30 | const output = module.finalize() |
| 31 | assert.sameMembers([...output.imports], [...imports]) |
| 32 | assert.deepStrictEqual( |
| 33 | Object.fromEntries(output.declarations.map(({ binding, fragments }) => [output.names.get(binding)!, fragments])), |
| 34 | Object.fromEntries( |
| 35 | Object.entries(expected).map(([name, code]) => [name, [ |
| 36 | `export type ${name} = ${code.Type}`, |
| 37 | `export const ${name} = ${code.runtime}` |
| 38 | ]]) |
| 39 | ) |
| 40 | ) |
| 41 | } |