Download .opencode/node_modules/zod/src/v4/classic/tests/nan.test.ts from Chenloong999/opencode-data: direct link, hf CLI and curl.
- Browser
- Download file 645 Bytes
-
https://huggingface.co/datasets/Chenloong999/opencode-data/resolve/main/.opencode/node_modules/zod/src/v4/classic/tests/nan.test.ts
- Command line
-
hf download hf://datasets/Chenloong999/opencode-data/.opencode/node_modules/zod/src/v4/classic/tests/nan.test.ts
-
curl -L -o nan.test.ts https://huggingface.co/datasets/Chenloong999/opencode-data/resolve/main/.opencode/node_modules/zod/src/v4/classic/tests/nan.test.ts
645 Bytes
| import { expect, expectTypeOf, test } from "vitest"; | |
| import * as z from "zod/v4"; | |
| const schema = z.nan(); | |
| test("passing validations", () => { | |
| schema.parse(Number.NaN); | |
| schema.parse(Number("Not a number")); | |
| expectTypeOf<typeof schema._output>().toEqualTypeOf<number>(); | |
| }); | |
| test("failing validations", () => { | |
| expect(() => schema.parse(5)).toThrow(); | |
| expect(() => schema.parse("John")).toThrow(); | |
| expect(() => schema.parse(true)).toThrow(); | |
| expect(() => schema.parse(null)).toThrow(); | |
| expect(() => schema.parse(undefined)).toThrow(); | |
| expect(() => schema.parse({})).toThrow(); | |
| expect(() => schema.parse([])).toThrow(); | |
| }); | |