-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmockDate.spec.ts
37 lines (33 loc) · 904 Bytes
/
mockDate.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { describe, expect, it } from "vitest";
import {
parse,
parseAsync,
date,
dateAsync,
minValue,
maxValue
} from "valibot";
import { Valimock } from "../Valimock.js";
const mockSchema = new Valimock().mock;
describe(`mockDate`, () => {
const requirement = new Date(Date.now() + 3600000);
it.each([
date(),
date([minValue(requirement)]),
date([maxValue(requirement)])
])(`should generate valid mock data (%#)`, (schema) => {
const result = mockSchema(schema);
expect(parse(schema, result)).toStrictEqual(result);
});
it.each([
dateAsync(),
dateAsync([minValue(requirement)]),
dateAsync([maxValue(requirement)])
])(
`should generate valid mock data with async validation (%#)`,
async (schema) => {
const result = mockSchema(schema);
await expect(parseAsync(schema, result)).resolves.toStrictEqual(result);
}
);
});