Skip to content

Commit 9a8022a

Browse files
committed
fix unit tests
1 parent e26565a commit 9a8022a

File tree

5 files changed

+8
-9
lines changed

5 files changed

+8
-9
lines changed

src/api/components/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { FastifySchema } from "fastify";
21
import { z } from "zod";
32

43
export const ts = z.coerce

src/api/routes/ics.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const icalPlugin: FastifyPluginAsync = async (fastify, _options) => {
6363
} satisfies FastifyZodOpenApiSchema),
6464
},
6565
async (request, reply) => {
66-
const host = request.params.host || "ACM";
66+
const host = request.params.host;
6767
let queryParams: QueryCommandInput = {
6868
TableName: genericConfig.EventsDynamoTableName,
6969
};
@@ -151,7 +151,7 @@ const icalPlugin: FastifyPluginAsync = async (fastify, _options) => {
151151
rawEvent.description
152152
: `Host: ${rawEvent.host}\n\n` + rawEvent.description,
153153
timezone: "America/Chicago",
154-
organizer: generateHostName(host),
154+
organizer: generateHostName(host || "ACM"),
155155
id: rawEvent.id,
156156
});
157157

tests/unit/eventPost.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ test("Sad path: Prevent empty body request", async () => {
7676
error: true,
7777
name: "ValidationError",
7878
id: 104,
79-
message: `Required at "title"; Required at "description"; Required at "start"; Required at "location"; Required at "host"`,
79+
message: "body/ Expected object, received null",
8080
});
8181
});
8282
test("Sad path: Prevent specifying repeatEnds on non-repeating events", async () => {
@@ -106,7 +106,7 @@ test("Sad path: Prevent specifying repeatEnds on non-repeating events", async ()
106106
error: true,
107107
name: "ValidationError",
108108
id: 104,
109-
message: "repeats is required when repeatEnds is defined",
109+
message: "body/ repeats is required when repeatEnds is defined",
110110
});
111111
});
112112

@@ -137,7 +137,8 @@ test("Sad path: Prevent specifying unknown repeat frequencies", async () => {
137137
error: true,
138138
name: "ValidationError",
139139
id: 104,
140-
message: `Invalid enum value. Expected 'weekly' | 'biweekly', received 'forever_and_ever' at "repeats"`,
140+
message:
141+
"body/repeats Invalid enum value. Expected 'weekly' | 'biweekly', received 'forever_and_ever'",
141142
});
142143
});
143144

tests/unit/ical.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ test("Test getting ACM-wide iCal calendar", async () => {
3333
test("Test getting non-existent iCal calendar fails", async () => {
3434
const date = new Date(2024, 7, 22, 15, 51, 48); // August 22, 2024, at 15:51:48 (3:51:48 PM)
3535
vi.setSystemTime(date);
36-
ddbMock.on(ScanCommand).resolves({
37-
Items: dynamoTableData as any,
38-
});
36+
ddbMock.on(ScanCommand).rejects();
3937
const response = await app.inject({
4038
method: "GET",
4139
url: "/api/v1/ical/invalid",

tests/unit/vitest.setup.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import "zod-openapi/extend";
12
import { vi, afterEach } from "vitest";
23
import { allAppRoles, AppRoles } from "../../src/common/roles.js";
34
import { DynamoDBClient, QueryCommand } from "@aws-sdk/client-dynamodb";

0 commit comments

Comments
 (0)