-
-
Notifications
You must be signed in to change notification settings - Fork 97
Expand file tree
/
Copy pathinfix.type.test.ts
More file actions
52 lines (46 loc) · 1.48 KB
/
Copy pathinfix.type.test.ts
File metadata and controls
52 lines (46 loc) · 1.48 KB
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
42
43
44
45
46
47
48
49
50
51
52
import { describe, expectTypeOf, it } from "vitest";
import { CommaSeparated, OperationMode } from "../src/Typesense/Types";
describe("infix type", () => {
it("it should parse valid comma separated values", () => {
expectTypeOf<"always,fallback">().toEqualTypeOf<
CommaSeparated<"always,fallback", OperationMode>
>();
});
it("it should not parse double-comma separated values", () => {
expectTypeOf<
CommaSeparated<"always,,fallback", OperationMode>
>().toEqualTypeOf<{
error: "Invalid operation mode";
value: "";
}>();
});
it("should not parse a comma in the first position", () => {
expectTypeOf<
CommaSeparated<"always,fallback,", OperationMode>
>().toEqualTypeOf<{
error: "Invalid operation mode";
value: "";
}>();
});
it("should not parse a comma in the last position", () => {
expectTypeOf<
CommaSeparated<"always,fallback,", OperationMode>
>().toEqualTypeOf<{
error: "Invalid operation mode";
value: "";
}>();
});
it("should not parse an invalid operation mode in the middle of the string", () => {
expectTypeOf<
CommaSeparated<"always,fallback,xoff", OperationMode>
>().toEqualTypeOf<{
error: "Invalid operation mode";
value: "xoff";
}>();
});
it("should not care about whitespace", () => {
expectTypeOf<" always, fallback, off ">().toEqualTypeOf<
CommaSeparated<" always, fallback, off ", OperationMode>
>();
});
});