From 37aff618302d0a0c209b9561dae442e6a0086c38 Mon Sep 17 00:00:00 2001 From: Dev Singh Date: Tue, 11 Nov 2025 17:00:11 -0600 Subject: [PATCH] Update linkry edge redirect unit tests --- tests/unit/linkryEdgeFunction/main.test.ts | 32 ++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/tests/unit/linkryEdgeFunction/main.test.ts b/tests/unit/linkryEdgeFunction/main.test.ts index d380ece2..e0971f94 100644 --- a/tests/unit/linkryEdgeFunction/main.test.ts +++ b/tests/unit/linkryEdgeFunction/main.test.ts @@ -86,7 +86,7 @@ describe("CloudFront Lambda@Edge Handler", () => { }); describe("Successful redirect from DynamoDB", () => { - it("should return 302 redirect when link is found in DynamoDB", async () => { + it("should return 302 redirect when link is found in DynamoDB for go.acm", async () => { const redirectUrl = "https://example.com/target"; dynamoMock.on(QueryCommand).resolves({ Items: [ @@ -98,7 +98,35 @@ describe("CloudFront Lambda@Edge Handler", () => { ], }); - const event = createEvent("/test-link"); + const event = createEvent("/test-link", "go.acm.illinois.edu"); + const result = await handler(event); + assertIsResponse(result); + + expect(result).toEqual({ + status: "302", + statusDescription: "Found", + headers: { + location: [{ key: "Location", value: redirectUrl }], + "cache-control": [ + { key: "Cache-Control", value: "public, max-age=30" }, + ], + }, + }); + }); + + it("should return 302 redirect when link is found in DynamoDB for acm.gg", async () => { + const redirectUrl = "https://example.com/target"; + dynamoMock.on(QueryCommand).resolves({ + Items: [ + { + slug: { S: "testgg" }, + access: { S: "OWNER#user123" }, + redirect: { S: redirectUrl }, + }, + ], + }); + + const event = createEvent("/testgg", "acm.gg"); const result = await handler(event); assertIsResponse(result);