@@ -219,6 +219,57 @@ describe('api/request', () => {
219219 request . cancel ( signatureIdentity , { refundAddress : bitcoinAddress } ) ,
220220 ) . rejects . toThrowError ( 'Cannot add refund information without payment network' ) ;
221221 } ) ;
222+
223+ it ( 'returns allowance revocation calldata when payer cancels recurring payment' , async ( ) => {
224+ const request = new Request ( '1' , mockRequestLogic , currencyManager ) ;
225+ const result = await request . cancel ( signatureIdentity , undefined , {
226+ isRecurringPayment : true ,
227+ isPayerCancel : true ,
228+ recurringPaymentInfo : {
229+ tokenAddress : '0x9FBDa871d559710256a2502A2517b794B482Db40' ,
230+ network : 'private' ,
231+ } ,
232+ } ) ;
233+
234+ expect ( result . allowanceRevocationCalldata ) . toBeDefined ( ) ;
235+ expect ( typeof result . allowanceRevocationCalldata ) . toBe ( 'string' ) ;
236+ expect ( result . allowanceRevocationCalldata ?. startsWith ( '0x' ) ) . toBe ( true ) ;
237+ } ) ;
238+
239+ it ( 'does not return allowance revocation calldata when payee cancels recurring payment' , async ( ) => {
240+ const request = new Request ( '1' , mockRequestLogic , currencyManager ) ;
241+ const result = await request . cancel ( signatureIdentity , undefined , {
242+ isRecurringPayment : true ,
243+ isPayerCancel : false ,
244+ recurringPaymentInfo : {
245+ tokenAddress : '0x9FBDa871d559710256a2502A2517b794B482Db40' ,
246+ network : 'private' ,
247+ } ,
248+ } ) ;
249+
250+ expect ( result . allowanceRevocationCalldata ) . toBeUndefined ( ) ;
251+ } ) ;
252+
253+ it ( 'does not return allowance revocation calldata for non-recurring payment cancellation' , async ( ) => {
254+ const request = new Request ( '1' , mockRequestLogic , currencyManager ) ;
255+ const result = await request . cancel ( signatureIdentity ) ;
256+
257+ expect ( result . allowanceRevocationCalldata ) . toBeUndefined ( ) ;
258+ } ) ;
259+
260+ it ( 'does not return allowance revocation calldata when isRecurringPayment is false' , async ( ) => {
261+ const request = new Request ( '1' , mockRequestLogic , currencyManager ) ;
262+ const result = await request . cancel ( signatureIdentity , undefined , {
263+ isRecurringPayment : false ,
264+ isPayerCancel : true ,
265+ recurringPaymentInfo : {
266+ tokenAddress : '0x9FBDa871d559710256a2502A2517b794B482Db40' ,
267+ network : 'private' ,
268+ } ,
269+ } ) ;
270+
271+ expect ( result . allowanceRevocationCalldata ) . toBeUndefined ( ) ;
272+ } ) ;
222273 } ) ;
223274
224275 describe ( 'increaseExpectedAmountRequest' , ( ) => {
0 commit comments