Tests
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Julien Valverdé
2024-02-23 21:35:22 +01:00
parent cffc56e7f6
commit ed6b8c5979
2 changed files with 12 additions and 29 deletions

View File

@@ -7,10 +7,10 @@ export const jsonify = {
bigint: jsonifyBigIntSchema,
date: jsonifyDateSchema,
decimal: jsonifyDecimalSchema,
}
} as const
export const dejsonify = {
bigint: dejsonifyBigIntSchema,
date: dejsonifyDateSchema,
decimal: dejsonifyDecimalSchema,
}
} as const

View File

@@ -5,11 +5,13 @@ import { dejsonify, jsonify } from "./schema/jsonify"
import { ObservableZodSchemaObject } from "./traits/ObservableZodSchemaObject"
const newTestExp = new ZodSchemaClassBuilder(TraitExpression.NullSuperclass, [])
const exp = new ZodSchemaClassBuilder(TraitExpression.NullSuperclass, [])
.schema({
schema: z.object({
/** Object ID */
/** User ID */
id: z.bigint(),
/** Username */
name: z.string(),
}),
@@ -27,40 +29,21 @@ const newTestExp = new ZodSchemaClassBuilder(TraitExpression.NullSuperclass, [])
.expresses(ObservableZodSchemaObject)
.build()
@newTestExp.staticImplements
class Test extends newTestExp.extends implements Implements<typeof newTestExp> {}
@exp.staticImplements
class User extends exp.extends implements Implements<typeof exp> {}
Test.defaultValues
const inst = Test.create({ id: 1n, name: "" })
User.defaultValues
const inst = User.create({ id: 1n, name: "" })
console.log(inst)
Test.dejsonify({ id: 1n })
class SubTest extends Test.extend({
class SubTest extends User.extend({
schema: ({ schema }) => schema.extend({
prout: z.string()
}),
defaultValues: defaultValues => ({
...defaultValues
}),
defaultValues: v => v,
}) {}
const subInst = await SubTest.createPromise({ name: "", prout: "" })
console.log(subInst)
// class ChildTest extends Test {}
// ChildTest.instantiate({ name: "" })
const testSchema = { schema: Test.schema }
declare const testGenericSchema: {
schema: z.ZodObject<z.ZodRawShape, z.UnknownKeysParam, z.ZodTypeAny, object, object>
}
type U<T> = T
interface ExtendTest extends U<typeof testSchema> {
schema: z.ZodObject<any, any, any, any, any>
}