@@ -38,6 +38,7 @@ import { getTestWallet } from '../../services/wallet/__mocks__/wallet.fixtures';
3838import { ConfirmationInterfaceKey } from '../../ui/confirmation/api' ;
3939import { ConfirmationUXController } from '../../ui/confirmation/controller' ;
4040import { logger } from '../../utils/logger' ;
41+ import { TrackTransactionHandler } from '../cronjob/trackTransaction' ;
4142
4243jest . mock ( '../../utils/logger' ) ;
4344jest . mock ( '@metamask/keyring-snap-sdk' , ( ) => ( {
@@ -48,6 +49,9 @@ describe('ChangeTrustOptHandler', () => {
4849 beforeEach ( ( ) => {
4950 jest . mocked ( emitSnapKeyringEvent ) . mockReset ( ) ;
5051 jest . mocked ( emitSnapKeyringEvent ) . mockResolvedValue ( undefined ) ;
52+ jest
53+ . spyOn ( TrackTransactionHandler , 'scheduleBackgroundEvent' )
54+ . mockResolvedValue ( undefined ) ;
5155 } ) ;
5256
5357 const accountId = '11111111-1111-4111-8111-111111111111' ;
@@ -247,6 +251,13 @@ describe('ChangeTrustOptHandler', () => {
247251 } ,
248252 } ,
249253 } ) ;
254+ expect (
255+ TrackTransactionHandler . scheduleBackgroundEvent ,
256+ ) . toHaveBeenCalledWith ( {
257+ txId : 'dGVzdC10eC1pZA==' ,
258+ scope,
259+ accountIds : [ account . id ] ,
260+ } ) ;
250261 } ) ;
251262
252263 it ( 'returns success early for opt-in when trustline already exists' , async ( ) => {
@@ -269,6 +280,9 @@ describe('ChangeTrustOptHandler', () => {
269280 expect ( signTransactionSpy ) . not . toHaveBeenCalled ( ) ;
270281 expect ( sendTransaction ) . not . toHaveBeenCalled ( ) ;
271282 expect ( savePendingKeyringTransaction ) . not . toHaveBeenCalled ( ) ;
283+ expect (
284+ TrackTransactionHandler . scheduleBackgroundEvent ,
285+ ) . not . toHaveBeenCalled ( ) ;
272286 } ) ;
273287
274288 it ( 'throws TrustlineNotFoundException for opt-out when trustline does not exist' , async ( ) => {
@@ -336,6 +350,13 @@ describe('ChangeTrustOptHandler', () => {
336350 } ,
337351 } ,
338352 } ) ;
353+ expect (
354+ TrackTransactionHandler . scheduleBackgroundEvent ,
355+ ) . toHaveBeenCalledWith ( {
356+ txId : 'dGVzdC10eC1pZA==' ,
357+ scope,
358+ accountIds : [ account . id ] ,
359+ } ) ;
339360 } ) ;
340361
341362 it ( 'throws UserRejectedRequestError when confirmation is rejected' , async ( ) => {
@@ -357,6 +378,9 @@ describe('ChangeTrustOptHandler', () => {
357378 expect ( sendTransaction ) . not . toHaveBeenCalled ( ) ;
358379 expect ( networkSendSpy ) . not . toHaveBeenCalled ( ) ;
359380 expect ( savePendingKeyringTransaction ) . not . toHaveBeenCalled ( ) ;
381+ expect (
382+ TrackTransactionHandler . scheduleBackgroundEvent ,
383+ ) . not . toHaveBeenCalled ( ) ;
360384 } ) ;
361385
362386 it ( 'continues successfully when saving pending transaction fails' , async ( ) => {
@@ -373,5 +397,6 @@ describe('ChangeTrustOptHandler', () => {
373397 transactionId : 'dGVzdC10eC1pZA==' ,
374398 } ) ;
375399 expect ( sendTransaction ) . toHaveBeenCalledTimes ( 1 ) ;
400+ expect ( TrackTransactionHandler . scheduleBackgroundEvent ) . toHaveBeenCalled ( ) ;
376401 } ) ;
377402} ) ;
0 commit comments