@@ -7,9 +7,12 @@ import type {OnyxKey} from '@src/ONYXKEYS';
77import ONYXKEYS from '@src/ONYXKEYS' ;
88import type { NewLogin } from '@src/types/onyx' ;
99import * as UserActions from '../../src/libs/actions/User' ;
10+ import redirectToSignIn from '../../src/libs/actions/SignInRedirect' ;
1011import waitForBatchedUpdates from '../utils/waitForBatchedUpdates' ;
1112
1213jest . mock ( '@libs/API' ) ;
14+ jest . mock ( '../../src/libs/actions/SignInRedirect' ) ;
15+
1316const mockAPI = API as jest . Mocked < typeof API > ;
1417
1518describe ( 'actions/User' , ( ) => {
@@ -880,7 +883,7 @@ describe('actions/User', () => {
880883 const login = { partnerID, partnerUserID} as NewLogin ;
881884
882885 // When revokeDevice is called
883- UserActions . revokeDevice ( login , undefined ) ;
886+ UserActions . revokeDevice ( login , 'a' ) ;
884887 await waitForBatchedUpdates ( ) ;
885888
886889 // Then API.write should be called with correct command and parameters
@@ -933,5 +936,22 @@ describe('actions/User', () => {
933936 } ,
934937 } ) ;
935938 } ) ;
939+
940+ it ( 'should call redirectToSignIn when the device belongs to the current user' , async ( ) => {
941+ // Given a device to revoke that belongs to the current user
942+ const partnerID = CONST . PARTNER_ID . IPHONE ;
943+ const partnerUserID = 'device_123' ;
944+ const autoGeneratedLogin = 'device_123' ;
945+ const login = { partnerID, partnerUserID} as NewLogin ;
946+
947+ ( mockAPI . write as jest . Mock ) . mockResolvedValue ( null ) ;
948+
949+ // When revokeDevice is called
950+ UserActions . revokeDevice ( login , autoGeneratedLogin ) ;
951+ await waitForBatchedUpdates ( ) ;
952+
953+ // Then redirectToSignIn should be called
954+ expect ( redirectToSignIn ) . toHaveBeenCalled ( ) ;
955+ } ) ;
936956 } ) ;
937957} ) ;
0 commit comments