Skip to content

Commit f413b15

Browse files
add extra test to check that statuses map is populated
1 parent f022bf9 commit f413b15

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

lambdas/api-handler/src/mappers/__tests__/letter-mapper.test.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,55 @@ describe("letter-mapper", () => {
5252
]);
5353
});
5454

55+
it("maps PostLetterRequest to UpdateLetterCommands and populates statuses map", () => {
56+
const request: PostLettersRequest = {
57+
data: [
58+
{
59+
id: "id1",
60+
type: "Letter",
61+
attributes: {
62+
status: "REJECTED",
63+
reasonCode: "123",
64+
reasonText: "Reason text",
65+
},
66+
},
67+
{ id: "id2", type: "Letter", attributes: { status: "ACCEPTED" } },
68+
{ id: "id3", type: "Letter", attributes: { status: "DELIVERED" } },
69+
],
70+
};
71+
const supplierId = "testSupplierId";
72+
const statusesMap = new Map<string, number>();
73+
const updateLetterCommands = mapToUpdateCommands(
74+
request,
75+
supplierId,
76+
statusesMap,
77+
);
78+
expect(updateLetterCommands).toEqual([
79+
{
80+
id: "id1",
81+
reasonCode: "123",
82+
reasonText: "Reason text",
83+
supplierId: "testSupplierId",
84+
status: "REJECTED",
85+
},
86+
{
87+
id: "id2",
88+
supplierId: "testSupplierId",
89+
status: "ACCEPTED",
90+
},
91+
{
92+
id: "id3",
93+
supplierId: "testSupplierId",
94+
status: "DELIVERED",
95+
},
96+
]);
97+
expect(Object.fromEntries(statusesMap)).toEqual({
98+
REJECTED: 1,
99+
ACCEPTED: 1,
100+
DELIVERED: 1,
101+
});
102+
});
103+
55104
it("maps an internal Letter to a PatchLetterResponse", () => {
56105
const date = new Date().toISOString();
57106
const letter: Letter = {

0 commit comments

Comments
 (0)