Skip to content

Commit ae978ee

Browse files
committed
mock cloudfront KV correctly
1 parent 09e23f0 commit ae978ee

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/unit/linkry.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import {
1313
GetSecretValueCommand,
1414
SecretsManagerClient,
1515
} from "@aws-sdk/client-secrets-manager";
16+
import { CloudFrontKeyValueStoreClient } from "@aws-sdk/client-cloudfront-keyvaluestore";
17+
1618
import { secretJson, secretObject } from "./secret.testdata.js";
1719
import supertest from "supertest";
1820

@@ -21,6 +23,16 @@ const smMock = mockClient(SecretsManagerClient);
2123
const jwt_secret = secretObject["jwt_key"];
2224
vi.stubEnv("JwtSigningKey", jwt_secret);
2325

26+
// Mock the Cloudfront KV client to prevent the actual Cloudfront KV call
27+
// aws-sdk-client-mock doesn't support Cloudfront KV Client API
28+
vi.mock("../../src/api/functions/cloudfrontKvStore.js", async () => {
29+
return {
30+
setKey: vi.fn(),
31+
deleteKey: vi.fn(),
32+
getKey: vi.fn().mockResolvedValue("https://www.acm.illinois.edu"),
33+
};
34+
});
35+
2436
const app = await init();
2537

2638
(app as any).nodeCache.flushAll();

0 commit comments

Comments
 (0)