@@ -103,13 +103,78 @@ describe("ACSP Verifiy a client send confirmation email", async () => {
103103 it ( "should return 200 on successful email send" , async ( ) => {
104104 sinon . stub ( mockValues . requestClient , "httpPost" ) . resolves ( mockValues . mockSendEmail [ 200 ] ) ;
105105 const ofService : AcspService = new AcspService ( mockValues . requestClient ) ;
106- const data = await ofService . sendIdentityVerificationEmail ( mockValues . mockClientVerificationEmail ) ;
106+ const data = await ofService . sendIdentityVerificationEmail ( mockValues . mockClientVerificationEmail , { application_type : "verification" } ) ;
107107 expect ( data . status ) . to . equal ( 200 ) ;
108108 } )
109+
109110 it ( "should return 500 if email fails" , async ( ) => {
110111 sinon . stub ( mockValues . requestClient , "httpPost" ) . resolves ( mockValues . mockSendEmail [ 500 ] ) ;
111112 const ofService : AcspService = new AcspService ( mockValues . requestClient ) ;
112- const data = await ofService . sendIdentityVerificationEmail ( mockValues . mockClientVerificationEmail ) ;
113+ const data = await ofService . sendIdentityVerificationEmail ( mockValues . mockClientVerificationEmail , { application_type : "verification" } ) ;
113114 expect ( data . status ) . to . equal ( 500 ) ;
114115 } )
115- } )
116+
117+ it ( "should call correct URL with verification query parameter" , async ( ) => {
118+ const httpPostStub = sinon . stub ( mockValues . requestClient , "httpPost" ) . resolves ( mockValues . mockSendEmail [ 200 ] ) ;
119+ const ofService : AcspService = new AcspService ( mockValues . requestClient ) ;
120+
121+ await ofService . sendIdentityVerificationEmail (
122+ mockValues . mockClientVerificationEmail ,
123+ { application_type : "verification" }
124+ ) ;
125+
126+ expect ( httpPostStub . calledWith (
127+ "/acsp-api/verify-client-identity/send-identity-verification-email?application_type=verification" ,
128+ mockValues . mockClientVerificationEmail
129+ ) ) . to . be . true ;
130+ } )
131+
132+ it ( "should call URL without query parameter when application_type is not provided" , async ( ) => {
133+ const httpPostStub = sinon . stub ( mockValues . requestClient , "httpPost" ) . resolves ( mockValues . mockSendEmail [ 200 ] ) ;
134+ const ofService : AcspService = new AcspService ( mockValues . requestClient ) ;
135+
136+ await ofService . sendIdentityVerificationEmail ( mockValues . mockClientVerificationEmail ) ;
137+
138+ expect ( httpPostStub . calledWith (
139+ "/acsp-api/verify-client-identity/send-identity-verification-email" ,
140+ mockValues . mockClientVerificationEmail
141+ ) ) . to . be . true ;
142+ } )
143+ } ) ;
144+
145+ describe ( "ACSP Reverify a client send confirmation email" , async ( ) => {
146+ it ( "should return 200 on successful reverification email send" , async ( ) => {
147+ sinon . stub ( mockValues . requestClient , "httpPost" ) . resolves ( mockValues . mockSendEmail [ 200 ] ) ;
148+ const ofService : AcspService = new AcspService ( mockValues . requestClient ) ;
149+ const data = await ofService . sendIdentityVerificationEmail (
150+ mockValues . mockClientVerificationEmail ,
151+ { application_type : "reverification" }
152+ ) ;
153+ expect ( data . status ) . to . equal ( 200 ) ;
154+ } )
155+
156+ it ( "should return 500 if reverification email fails" , async ( ) => {
157+ sinon . stub ( mockValues . requestClient , "httpPost" ) . resolves ( mockValues . mockSendEmail [ 500 ] ) ;
158+ const ofService : AcspService = new AcspService ( mockValues . requestClient ) ;
159+ const data = await ofService . sendIdentityVerificationEmail (
160+ mockValues . mockClientVerificationEmail ,
161+ { application_type : "reverification" }
162+ ) ;
163+ expect ( data . status ) . to . equal ( 500 ) ;
164+ } )
165+
166+ it ( "should call correct URL with reverification query parameter" , async ( ) => {
167+ const httpPostStub = sinon . stub ( mockValues . requestClient , "httpPost" ) . resolves ( mockValues . mockSendEmail [ 200 ] ) ;
168+ const ofService : AcspService = new AcspService ( mockValues . requestClient ) ;
169+
170+ await ofService . sendIdentityVerificationEmail (
171+ mockValues . mockClientVerificationEmail ,
172+ { application_type : "reverification" }
173+ ) ;
174+
175+ expect ( httpPostStub . calledWith (
176+ "/acsp-api/verify-client-identity/send-identity-verification-email?application_type=reverification" ,
177+ mockValues . mockClientVerificationEmail
178+ ) ) . to . be . true ;
179+ } )
180+ } ) ;
0 commit comments