Skip to content

Commit 53ff4e0

Browse files
committed
refactor(tests): replace 'kind' fields with 'id' in config store validation tests
1 parent 67e9305 commit 53ff4e0

1 file changed

Lines changed: 23 additions & 16 deletions

File tree

packages/file-store/src/__tests__/config-store-validator.test.ts

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,30 @@ jest.mock("@nhsdigital/nhs-notify-event-schemas-supplier-config", () => {
1010
return {
1111
$ChannelType: z.literal("LETTER"),
1212
$VolumeGroup: z.object({
13-
kind: z.literal("volume-group"),
13+
id: z.string(),
1414
name: z.string(),
1515
}),
1616
$LetterVariant: z.object({
17-
kind: z.literal("letter-variant"),
17+
id: z.string(),
1818
packSpecificationIds: z.array(z.string()).min(1),
1919
}),
2020
$PackSpecification: z.object({
21-
kind: z.literal("pack-specification"),
21+
id: z.string(),
2222
version: z.number().int(),
2323
postage: z.object({
2424
id: z.string(),
2525
}),
2626
}),
2727
$Supplier: z.object({
28-
kind: z.literal("supplier"),
28+
id: z.string(),
2929
dailyCapacity: z.number().int(),
3030
}),
3131
$SupplierAllocation: z.object({
32-
kind: z.literal("supplier-allocation"),
32+
id: z.string(),
3333
allocationPercentage: z.number().min(0).max(100),
3434
}),
3535
$SupplierPack: z.object({
36-
kind: z.literal("supplier-pack"),
36+
id: z.string(),
3737
approval: z.enum(["APPROVED", "DRAFT"]),
3838
}),
3939
};
@@ -59,28 +59,28 @@ describe("validateConfigStore", () => {
5959
const validRecords = [
6060
makeRecord("channel", "channel-1", "LETTER"),
6161
makeRecord("volume-group", "vg-1", {
62-
kind: "volume-group",
62+
id: "vg-1",
6363
name: "VG 1",
6464
}),
6565
makeRecord("letter-variant", "lv-1", {
66-
kind: "letter-variant",
66+
id: "lv-1",
6767
packSpecificationIds: ["pack-spec-1"],
6868
}),
6969
makeRecord("pack-specification", "pack-spec-1", {
70-
kind: "pack-specification",
70+
id: "pack-spec-1",
7171
version: 1,
7272
postage: { id: "postage-1" },
7373
}),
7474
makeRecord("supplier", "sup-1", {
75-
kind: "supplier",
75+
id: "sup-1",
7676
dailyCapacity: 100,
7777
}),
7878
makeRecord("supplier-allocation", "alloc-1", {
79-
kind: "supplier-allocation",
79+
id: "alloc-1",
8080
allocationPercentage: 100,
8181
}),
8282
makeRecord("supplier-pack", "sp-1", {
83-
kind: "supplier-pack",
83+
id: "sp-1",
8484
approval: "APPROVED",
8585
}),
8686
];
@@ -92,6 +92,13 @@ describe("validateConfigStore", () => {
9292
...record,
9393
id: `${record.id}-${i}`,
9494
sourceFilePath: record.sourceFilePath.replace(".json", `-${i}.json`),
95+
data:
96+
typeof record.data === "string"
97+
? record.data
98+
: {
99+
...(record.data as Record<string, unknown>),
100+
id: `${record.id}-${i}`,
101+
},
95102
})),
96103
).flat(),
97104
});
@@ -115,11 +122,11 @@ describe("validateConfigStore", () => {
115122
rootPath: "/tmp",
116123
records: [
117124
makeRecord("supplier", "sup-1", {
118-
kind: "supplier",
125+
id: "sup-1",
119126
dailyCapacity: "not-a-number",
120127
}),
121128
makeRecord("pack-specification", "pack-spec-1", {
122-
kind: "pack-specification",
129+
id: "pack-spec-1",
123130
version: "bad-version",
124131
postage: {},
125132
}),
@@ -146,7 +153,7 @@ describe("validateConfigStore", () => {
146153
rootPath: "/tmp",
147154
records: [
148155
makeRecord("letter-variant", "lv-1", {
149-
kind: "letter-variant",
156+
id: "lv-1",
150157
packSpecificationIds: [123],
151158
}),
152159
],
@@ -161,7 +168,7 @@ describe("validateConfigStore", () => {
161168
rootPath: "/tmp",
162169
records: [
163170
makeRecord("supplier", "sup-1", {
164-
kind: "supplier",
171+
id: "sup-1",
165172
dailyCapacity: 100,
166173
}),
167174
],

0 commit comments

Comments
 (0)