11import { afterAll , expect , test , beforeEach , vi , describe } from "vitest" ;
22import init from "../../src/api/index.js" ;
33import { 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
515vi . 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