-
Notifications
You must be signed in to change notification settings - Fork 516
Expand file tree
/
Copy pathschema.test.ts
More file actions
57 lines (53 loc) · 1.6 KB
/
schema.test.ts
File metadata and controls
57 lines (53 loc) · 1.6 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
53
54
55
56
57
import { describe, expect, it } from "vitest";
import { branchPaymentsSchema } from "./schema";
describe("branchPaymentsSchema", () => {
it("accepts partial payments config without products", async () => {
await expect(branchPaymentsSchema.validate({
blockNewPurchases: true,
})).resolves.toMatchObject({
blockNewPurchases: true,
});
});
it("accepts product lines without products", async () => {
await expect(branchPaymentsSchema.validate({
productLines: {
pro: {
displayName: "Pro",
customerType: "user",
},
},
})).resolves.toMatchObject({
productLines: {
pro: {
displayName: "Pro",
customerType: "user",
},
},
});
});
it("rejects a product that references a missing product line", async () => {
await expect(branchPaymentsSchema.validate({
products: {
pro: {
customerType: "user",
productLineId: "missing-line",
},
},
})).rejects.toThrow('Product "pro" specifies product line ID "missing-line", but that product line does not exist');
});
it("rejects a product whose customer type differs from its product line", async () => {
await expect(branchPaymentsSchema.validate({
productLines: {
teamLine: {
customerType: "team",
},
},
products: {
pro: {
customerType: "user",
productLineId: "teamLine",
},
},
})).rejects.toThrow('Product "pro" has customer type "user" but its product line "teamLine" has customer type "team"');
});
});