Files
klz-cables.com/.pnpm-store/v10/files/2e/b4f5405d1bede66f64f68d7abf8bfc5bfc811710078d6ce2ba4d7d562ab7eb4f6e1aafd139451a0cde255a79041c96d193e281ec9cbae2e053881e41e17d8c
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

37 lines
1.0 KiB
Plaintext

// @ts-ignore TS6133
import { expect, test } from "vitest";
import * as z from "zod/v3";
const literalTuna = z.literal("tuna");
const literalFortyTwo = z.literal(42);
const literalTrue = z.literal(true);
const terrificSymbol = Symbol("terrific");
const literalTerrificSymbol = z.literal(terrificSymbol);
test("passing validations", () => {
literalTuna.parse("tuna");
literalFortyTwo.parse(42);
literalTrue.parse(true);
literalTerrificSymbol.parse(terrificSymbol);
});
test("failing validations", () => {
expect(() => literalTuna.parse("shark")).toThrow();
expect(() => literalFortyTwo.parse(43)).toThrow();
expect(() => literalTrue.parse(false)).toThrow();
expect(() => literalTerrificSymbol.parse(Symbol("terrific"))).toThrow();
});
test("invalid_literal should have `received` field with data", () => {
const data = "shark";
const result = literalTuna.safeParse(data);
if (!result.success) {
const issue = result.error.issues[0];
if (issue.code === "invalid_literal") {
expect(issue.received).toBe(data);
}
}
});