Skip to content

Commit 98dec4d

Browse files
committed
add test
1 parent e615d86 commit 98dec4d

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

tests/actions/UserTest.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@ import type {OnyxKey} from '@src/ONYXKEYS';
77
import ONYXKEYS from '@src/ONYXKEYS';
88
import type {NewLogin} from '@src/types/onyx';
99
import * as UserActions from '../../src/libs/actions/User';
10+
import redirectToSignIn from '../../src/libs/actions/SignInRedirect';
1011
import waitForBatchedUpdates from '../utils/waitForBatchedUpdates';
1112

1213
jest.mock('@libs/API');
14+
jest.mock('../../src/libs/actions/SignInRedirect');
15+
1316
const mockAPI = API as jest.Mocked<typeof API>;
1417

1518
describe('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

Comments
 (0)