Skip to content

Commit 6e39c96

Browse files
committed
fix unit test
1 parent 520a003 commit 6e39c96

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tests/unit/mobileWallet.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
import { afterAll, expect, test, beforeEach, vi, describe } from "vitest";
22
import init from "../../src/api/index.js";
33
import { EntraFetchError } from "../../src/common/errors/index.js";
4+
import {
5+
GetSecretValueCommand,
6+
SecretsManagerClient,
7+
} from "@aws-sdk/client-secrets-manager";
8+
import { SendMessageCommand, SQSClient } from "@aws-sdk/client-sqs";
9+
import { mockClient } from "aws-sdk-client-mock";
10+
import { secretJson } from "./secret.testdata.js";
11+
12+
const smMock = mockClient(SecretsManagerClient);
13+
const sqsMock = mockClient(SQSClient);
414

515
vi.mock("../../src/api/functions/membership.js", () => {
616
return {
@@ -64,10 +74,12 @@ describe("Mobile wallet pass issuance", async () => {
6474
await response.json();
6575
});
6676
test("Test that passes will be issued for members", async () => {
77+
sqsMock.on(SendMessageCommand).resolvesOnce({});
6778
const response = await app.inject({
6879
method: "POST",
6980
url: "/api/v1/mobileWallet/[email protected]",
7081
});
82+
expect(sqsMock.calls.length).toBe(1);
7183
expect(response.statusCode).toBe(202);
7284
});
7385
afterAll(async () => {
@@ -76,5 +88,8 @@ describe("Mobile wallet pass issuance", async () => {
7688
beforeEach(() => {
7789
(app as any).nodeCache.flushAll();
7890
vi.clearAllMocks();
91+
smMock.on(GetSecretValueCommand).resolves({
92+
SecretString: secretJson,
93+
});
7994
});
8095
});

0 commit comments

Comments
 (0)