@@ -66,24 +66,34 @@ describe("vc receipt status middleware tests", () => {
6666 expect ( ( req . session as any ) . journey ) . to . equal ( "journey/next" ) ;
6767 } ) ;
6868
69+ it ( "pollVcReceiptStatus should return CLIENT_ERROR status if appVcReceived returns 400" , async ( ) => {
70+ const error = { response : { status : 400 } } ;
71+ appVcReceivedStub . rejects ( error ) ;
72+
73+ await middleware . pollVcReceiptStatus ( req as Request , res as Response , next ) ;
74+
75+ expect ( res . status ) . to . have . been . calledWith ( 400 ) ;
76+ expect ( res . json ) . to . have . been . calledWith ( { status : "CLIENT_ERROR" } ) ;
77+ } ) ;
78+
6979 it ( "pollVcReceiptStatus should return an error when appVcReceived does not return journey response" , async ( ) => {
7080 appVcReceivedStub . resolves ( { data : { } } ) ;
7181 isJourneyResponse . returns ( false ) ;
7282
7383 await middleware . pollVcReceiptStatus ( req as Request , res as Response , next ) ;
7484
7585 expect ( res . status ) . to . have . been . calledWith ( 500 ) ;
76- expect ( res . json ) . to . have . been . calledWith ( { status : "ERROR " } ) ;
86+ expect ( res . json ) . to . have . been . calledWith ( { status : "SERVER_ERROR " } ) ;
7787 } ) ;
7888
79- it ( "pollVcReceiptStatus should return ERROR status if appVcReceived throws non 404 error" , async ( ) => {
89+ it ( "pollVcReceiptStatus should return SERVER_ERROR status if appVcReceived throws non 400-499 error" , async ( ) => {
8090 const error = new Error ( "Test error" ) ;
8191 appVcReceivedStub . rejects ( error ) ;
8292
8393 await middleware . pollVcReceiptStatus ( req as Request , res as Response , next ) ;
8494
8595 expect ( res . status ) . to . have . been . calledWith ( 500 ) ;
86- expect ( res . json ) . to . have . been . calledWith ( { status : "ERROR " } ) ;
96+ expect ( res . json ) . to . have . been . calledWith ( { status : "SERVER_ERROR " } ) ;
8797 } ) ;
8898
8999 it ( "pollVcReceiptStatus should return COMPLETED status when query param snapshotTest is true" , async ( ) => {
0 commit comments