@@ -176,6 +176,25 @@ describe("extensions.message-handlers.ngpvan-optout", () => {
176176 } ) ;
177177 } ) ;
178178
179+ describe ( "when the alternate optOutReason is passed in the handlerContext object" , ( ) => {
180+ beforeEach ( async ( ) => {
181+ handlerContext = {
182+ optOutReason : "manual"
183+ }
184+ } ) ;
185+
186+ it ( "returns an empty object and DOES post to NGP VAN" , async ( ) => {
187+ const result = await VanOptOut . postMessageSave ( {
188+ handlerContext,
189+ organization,
190+ message
191+ } )
192+
193+ expect ( result ) . toEqual ( { } ) ;
194+ expect ( HttpRequest . default . mock . calls )
195+ } )
196+ } )
197+
179198 // Skipping as there is a world where we opt out someone
180199 // even when the message is not from them originally
181200 describe . skip ( "when the message is not from the contact" , ( ) => {
@@ -194,7 +213,27 @@ describe("extensions.message-handlers.ngpvan-optout", () => {
194213 } ) ;
195214
196215 expect ( result ) . toEqual ( { } ) ;
197- expect ( HttpRequest . default . mock . calls ) . toHaveLength ( 0 ) ;
216+ expect ( HttpRequest . default . mock . calls ) . toEqual (
217+ [
218+ [
219+ "https://api.securevan.com/v4/people/1234/canvassResponses" ,
220+ {
221+ "method" : "POST" ,
222+ "retries" : 1 ,
223+ "timeout" : 32000 ,
224+ "headers" : {
225+ "Authorization" : "*****" ,
226+ "accept" : "text/plain" ,
227+ "Content-Type" : "application/json"
228+ } ,
229+ "body" : `{"canvassContext":{"inputTypeId":11,"phone":{"dialingPrefix":"1"` +
230+ `,"phoneNumber":"123-456-7890","smsOptInStatus":"O"}},"resultCodeId":130}` ,
231+ "validStatuses" : [ 204 ] ,
232+ "compress" : false
233+ }
234+ ]
235+ ]
236+ ) ;
198237 } ) ;
199238 } ) ;
200239 } ) ;
0 commit comments