test(core): cover Effect Schema event definitions
Exercise the new SyncEvent and BusEvent Schema overloads end to end and use Schema.isSchema for the conversion check so the mixed-schema path stays explicit and covered.
This commit is contained in:
@@ -23,16 +23,12 @@ export function define<Type extends string, P extends ZodType>(
|
||||
properties: P,
|
||||
): { type: Type; properties: P }
|
||||
export function define(type: string, properties: unknown) {
|
||||
const zodProperties = isEffectSchema(properties) ? zod(properties) : (properties as ZodType)
|
||||
const zodProperties = Schema.isSchema(properties) ? zod(properties) : (properties as ZodType)
|
||||
const result = { type, properties: zodProperties }
|
||||
registry.set(type, result as Definition)
|
||||
return result
|
||||
}
|
||||
|
||||
function isEffectSchema(value: unknown): value is Schema.Top {
|
||||
return typeof value === "object" && value !== null && "ast" in value
|
||||
}
|
||||
|
||||
export function payloads() {
|
||||
return registry
|
||||
.entries()
|
||||
|
||||
@@ -117,7 +117,7 @@ export function define<
|
||||
}
|
||||
|
||||
function toZodObject(value: ZodObject | Schema.Top): z.ZodObject {
|
||||
if (typeof value === "object" && value !== null && "ast" in value) {
|
||||
if (Schema.isSchema(value)) {
|
||||
return zod(value as Schema.Top) as unknown as z.ZodObject
|
||||
}
|
||||
return value as z.ZodObject
|
||||
|
||||
Reference in New Issue
Block a user