Rocky_Mountain_Vending/.pnpm-store/v10/files/6b/459cf0888b9ed499d5ffab9edc2f56002f9b6884c0ac6324a4a167a0befce299f18f0e382facc2faed00cb84effe7f8bcba4626242d5e4ac696d44e65cf5d4
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
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>
2026-02-12 16:22:15 -07:00

91 lines
2.4 KiB
Text

// @ts-ignore
import { File as WebFile } from "@web-std/file";
import { afterEach, beforeEach, expect, test } from "vitest";
import * as z from "zod/v4";
const minCheck = z.file().min(5);
const maxCheck = z.file().max(8);
const mimeCheck = z.file().mime(["text/plain", "application/json"]);
const originalFile = global.File;
beforeEach(async () => {
if (!globalThis.File) globalThis.File = WebFile;
});
afterEach(() => {
if (globalThis.File !== originalFile) {
globalThis.File = originalFile;
}
});
test("passing validations", () => {
minCheck.safeParse(new File(["12345"], "test.txt"));
maxCheck.safeParse(new File(["12345678"], "test.txt"));
mimeCheck.safeParse(new File([""], "test.csv", { type: "text/plain" }));
expect(() => mimeCheck.parse(new File([""], "test.txt"))).toThrow();
expect(() => mimeCheck.parse(new File([""], "test.txt", { type: "text/csv" }))).toThrow();
});
test("failing validations", () => {
expect(minCheck.safeParse(new File(["1234"], "test.txt"))).toMatchInlineSnapshot(`
{
"error": [ZodError: [
{
"origin": "file",
"code": "too_small",
"minimum": 5,
"path": [],
"message": "Too small: expected file to have >5 bytes"
}
]],
"success": false,
}
`);
expect(maxCheck.safeParse(new File(["123456789"], "test.txt"))).toMatchInlineSnapshot(`
{
"error": [ZodError: [
{
"origin": "file",
"code": "too_big",
"maximum": 8,
"path": [],
"message": "Too big: expected file to have <8 bytes"
}
]],
"success": false,
}
`);
expect(mimeCheck.safeParse(new File([""], "test.csv"))).toMatchInlineSnapshot(`
{
"error": [ZodError: [
{
"code": "invalid_value",
"values": [
"text/plain",
"application/json"
],
"path": [],
"message": "Invalid option: expected one of \\"text/plain\\"|\\"application/json\\""
}
]],
"success": false,
}
`);
expect(mimeCheck.safeParse(new File([""], "test.csv", { type: "text/csv" }))).toMatchInlineSnapshot(`
{
"error": [ZodError: [
{
"code": "invalid_value",
"values": [
"text/plain",
"application/json"
],
"path": [],
"message": "Invalid option: expected one of \\"text/plain\\"|\\"application/json\\""
}
]],
"success": false,
}
`);
});