-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmockTuple.spec.ts
41 lines (38 loc) · 1.03 KB
/
mockTuple.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
38
39
40
41
import { describe, expect, it } from "vitest";
import {
parse,
parseAsync,
tuple,
tupleAsync,
string,
number,
url,
maxValue,
integer,
numberAsync,
maxLength
} from "valibot";
import { Valimock } from "../Valimock.js";
const mockSchema = new Valimock().mock;
describe(`mockTuple`, () => {
it.each([
tuple([string([url()]), number([maxValue(20), integer()])]),
tuple([string([url()]), number([maxValue(20), integer()])], [maxLength(2)])
])(`should generate valid mock data (%#)`, (schema) => {
const result = mockSchema(schema);
expect(parse(schema, result)).toStrictEqual(result);
});
it.each([
tupleAsync([string([url()]), numberAsync([maxValue(20), integer()])]),
tupleAsync(
[string([url()]), numberAsync([maxValue(20), integer()])],
[maxLength(2)]
)
])(
`should generate valid mock data with async validation (%#)`,
async (schema) => {
const result = mockSchema(schema);
await expect(parseAsync(schema, result)).resolves.toStrictEqual(result);
}
);
});