blank project
This commit is contained in:
32
node_modules/zod/src/v3/tests/date.test.ts
generated
vendored
Normal file
32
node_modules/zod/src/v3/tests/date.test.ts
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
// @ts-ignore TS6133
|
||||
import { expect, test } from "vitest";
|
||||
|
||||
import * as z from "zod/v3";
|
||||
|
||||
const beforeBenchmarkDate = new Date(2022, 10, 4);
|
||||
const benchmarkDate = new Date(2022, 10, 5);
|
||||
const afterBenchmarkDate = new Date(2022, 10, 6);
|
||||
|
||||
const minCheck = z.date().min(benchmarkDate);
|
||||
const maxCheck = z.date().max(benchmarkDate);
|
||||
|
||||
test("passing validations", () => {
|
||||
minCheck.parse(benchmarkDate);
|
||||
minCheck.parse(afterBenchmarkDate);
|
||||
|
||||
maxCheck.parse(benchmarkDate);
|
||||
maxCheck.parse(beforeBenchmarkDate);
|
||||
});
|
||||
|
||||
test("failing validations", () => {
|
||||
expect(() => minCheck.parse(beforeBenchmarkDate)).toThrow();
|
||||
expect(() => maxCheck.parse(afterBenchmarkDate)).toThrow();
|
||||
});
|
||||
|
||||
test("min max getters", () => {
|
||||
expect(minCheck.minDate).toEqual(benchmarkDate);
|
||||
expect(minCheck.min(afterBenchmarkDate).minDate).toEqual(afterBenchmarkDate);
|
||||
|
||||
expect(maxCheck.maxDate).toEqual(benchmarkDate);
|
||||
expect(maxCheck.max(beforeBenchmarkDate).maxDate).toEqual(beforeBenchmarkDate);
|
||||
});
|
||||
Reference in New Issue
Block a user