MCPcopy Create free account
hub / github.com/Effect-TS/effect / assertSchemas

Function assertSchemas

packages/effect/test/utils/schemaCodegen.ts:25–41  ·  view source on GitHub ↗
(
  module: Codegen.Module,
  expected: Readonly<Record<string, SchemaRepresentation.Code>>,
  imports: ReadonlyArray<string> = ["import * as Schema from \"effect/Schema\""]
)

Source from the content-addressed store, hash-verified

23}
24
25export 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}

Callers 4

assertCodeFunction · 0.90
assertCodeFunction · 0.90

Calls 3

getMethod · 0.65
finalizeMethod · 0.45
mapMethod · 0.45

Tested by 2

assertCodeFunction · 0.72
assertCodeFunction · 0.72