Skip to content

Commit cfd83a5

Browse files
committed
fix unit tests
1 parent d397c68 commit cfd83a5

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

src/api/routes/events.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ const eventsPlugin: FastifyPluginAsyncZodOpenApi = async (
435435
}),
436436
];
437437
await Promise.all(postUpdatePromises);
438-
438+
reply.header("location", request.url);
439439
reply.status(201).send();
440440
} catch (e: unknown) {
441441
if (e instanceof Error) {

tests/unit/eventPost.test.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -498,9 +498,9 @@ describe("Event modification tests", async () => {
498498
const ourError = new Error("Nonexistent event.");
499499
ourError.name = "ConditionalCheckFailedException";
500500
ddbMock
501-
.on(UpdateItemCommand, {
501+
.on(PutItemCommand, {
502502
TableName: genericConfig.EventsDynamoTableName,
503-
Key: { id: { S: eventUuid } },
503+
Item: { id: { S: eventUuid } },
504504
})
505505
.rejects(ourError);
506506
const testJwt = createJwt();
@@ -509,7 +509,12 @@ describe("Event modification tests", async () => {
509509
.patch(`/api/v1/events/${eventUuid}`)
510510
.set("authorization", `Bearer ${testJwt}`)
511511
.send({
512-
paidEventId: "sp24_semiformal_2",
512+
description: "First test event",
513+
host: "Social Committee",
514+
location: "Siebel Center",
515+
start: "2024-09-25T18:00:00",
516+
title: "Event 1",
517+
featured: false,
513518
});
514519

515520
expect(response.statusCode).toBe(404);
@@ -531,19 +536,16 @@ describe("Event modification tests", async () => {
531536
};
532537
ddbMock.reset();
533538
ddbMock
534-
.on(UpdateItemCommand, {
539+
.on(PutItemCommand, {
535540
TableName: genericConfig.EventsDynamoTableName,
536-
Key: { id: { S: eventUuid } },
537541
})
538542
.resolves({ Attributes: marshall(event) });
539543
const testJwt = createJwt();
540544
await app.ready();
541545
const response = await supertest(app.server)
542546
.patch(`/api/v1/events/${eventUuid}`)
543547
.set("authorization", `Bearer ${testJwt}`)
544-
.send({
545-
paidEventId: "sp24_semiformal_2",
546-
});
548+
.send(event);
547549

548550
expect(response.statusCode).toBe(201);
549551
expect(response.header["location"]).toBeDefined();

0 commit comments

Comments
 (0)