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

Function example

packages/effect/test/schema/representation/codegen.test.ts:75–88  ·  view source on GitHub ↗
(name: string, schema: Schema.Top, expectedType: string, samples: Samples)

Source from the content-addressed store, hash-verified

73}
74
75function example(name: string, schema: Schema.Top, expectedType: string, samples: Samples): void {
76 it(name, async () => {
77 const document = generate(schema)
78 const source = document.print()
79 register(name, source, [expectedType])
80 await withGeneratedModule<Generated>(source, ({ TestRoot0 }) => assertSamples(TestRoot0, samples))
81 // Exercise annotations on every schema shape without normalizing generated code.
82 const annotated = generate(schema.annotate({ description: "generated annotation" })).print()
83 await withGeneratedModule<Generated>(annotated, ({ TestRoot0 }) => {
84 assert.strictEqual(Schema.resolveAnnotations(TestRoot0)?.description, "generated annotation")
85 assertSamples(TestRoot0, samples)
86 })
87 })
88}
89
90function fromJson(schema: JsonSchema.JsonSchema): Schema.Top {
91 return SchemaRepresentation.fromJsonSchemaDocument(JsonSchema.fromSchemaDraft2020_12(schema), {

Callers 1

codegen.test.tsFile · 0.70

Calls 5

assertSamplesFunction · 0.85
printMethod · 0.80
generateFunction · 0.70
registerFunction · 0.70
annotateMethod · 0.65

Tested by

no test coverage detected