Files
memecoin-botV2/.pnpm-store/v10/files/65/d166f5f26233a9828a66774504c230526748c769e85efc8300f3cb7e6c869bb5ae8f1c35350b2125577d30a6654d7f1e01e8481aec0b17edb81532d6e3728e

23 lines
591 B
Plaintext

import { expect, test } from "vitest";
import * as z from "zod/v4";
test(".nullable()", () => {
const nullable = z.string().nullable();
expect(nullable.parse(null)).toBe(null);
expect(nullable.parse("asdf")).toBe("asdf");
expect(() => nullable.parse(123)).toThrow();
});
test(".nullable unwrap", () => {
const schema = z.string().nullable();
expect(schema).toBeInstanceOf(z.ZodNullable);
expect(schema.unwrap()).toBeInstanceOf(z.ZodString);
});
test("z.null", () => {
const n = z.null();
expect(n.parse(null)).toBe(null);
expect(() => n.parse("asdf")).toThrow();
});