Next.js website for Rocky Mountain Vending company featuring: - Product catalog with Stripe integration - Service areas and parts pages - Admin dashboard with Clerk authentication - SEO optimized pages with JSON-LD structured data Co-authored-by: Cursor <cursoragent@cursor.com>
27 lines
628 B
Text
27 lines
628 B
Text
// @ts-ignore TS6133
|
|
import { expect, test } from "vitest";
|
|
|
|
import * as z from "zod/v3";
|
|
const stringSchema = z.string();
|
|
|
|
test("safeparse fail", () => {
|
|
const safe = stringSchema.safeParse(12);
|
|
expect(safe.success).toEqual(false);
|
|
expect(safe.error).toBeInstanceOf(z.ZodError);
|
|
});
|
|
|
|
test("safeparse pass", () => {
|
|
const safe = stringSchema.safeParse("12");
|
|
expect(safe.success).toEqual(true);
|
|
expect(safe.data).toEqual("12");
|
|
});
|
|
|
|
test("safeparse unexpected error", () => {
|
|
expect(() =>
|
|
stringSchema
|
|
.refine((data) => {
|
|
throw new Error(data);
|
|
})
|
|
.safeParse("12")
|
|
).toThrow();
|
|
});
|