Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions tests/unit/linkryEdgeFunction/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand All @@ -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);

Expand Down
Loading