From aa3987e3726f61ddc1a221b42ad4976f3dfc5a88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Valverd=C3=A9?= Date: Mon, 18 Mar 2024 17:15:15 +0100 Subject: [PATCH] Tests --- src/tests.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/tests.ts b/src/tests.ts index f8434d6..d63a63c 100644 --- a/src/tests.ts +++ b/src/tests.ts @@ -1,15 +1,17 @@ import { Implements } from "@thilawyn/traitify-ts" +import { Option } from "effect" import { z } from "zod" import { JsonifiedZodSchemaClass } from "./JsonifiedZodSchemaClass" import { ZodSchemaClass } from "./ZodSchemaClass" import { dejsonify, jsonify } from "./schema/jsonifiable" +import { effect } from "./schema/lib" import { MobXObservableZodSchemaObject } from "./traits/MobXObservableZodSchemaObject" const userExp = ZodSchemaClass( z.object({ /** User ID */ - id: z.bigint().default(-1n), + id: effect.option.option(z.bigint()).default(Option.none()), /** Username */ name: z.string(), @@ -24,8 +26,8 @@ const userExp = ZodSchemaClass( @userExp.staticImplements class User extends userExp.extends implements Implements {} -const userInst = User.create({ id: 1n, name: "User" }) -const userInstEffect = User.createEffect({ id: 1n, name: "User" }) +const userInst = User.create({ id: Option.some(1n), name: "User" }) +const userInstEffect = User.createEffect({ id: Option.some(1n), name: "User" }) const jsonifiedUserExp = JsonifiedZodSchemaClass(User, { @@ -52,4 +54,4 @@ const adminUserExp = User.extend(s => s.extend({ @adminUserExp.staticImplements class AdminUser extends adminUserExp.extends implements Implements {} -const admin = AdminUser.create({ id: 2n, name: "Admin" }) +const admin = AdminUser.create({ id: Option.some(2n), name: "Admin" })