From 2fe4b0b96447c05eed4effb4946c6f41228e8d1b Mon Sep 17 00:00:00 2001 From: Prithpal Sooriya Date: Mon, 16 Sep 2024 16:06:01 +0100 Subject: [PATCH] test: remove unused test (#4703) ## Explanation We have a mock and a test that is not used anymore. It still passed the CI, but actually doesn't test anything. ## References ## Changelog ### `@metamask/profile-sync-controller` - **REMOVED**: unused mock function. ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [x] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [x] I've highlighted breaking changes using the "BREAKING" category above as appropriate --- .../UserStorageController.test.ts | 29 +++++++------------ 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/packages/profile-sync-controller/src/controllers/user-storage/UserStorageController.test.ts b/packages/profile-sync-controller/src/controllers/user-storage/UserStorageController.test.ts index c6e40da885..9942c72138 100644 --- a/packages/profile-sync-controller/src/controllers/user-storage/UserStorageController.test.ts +++ b/packages/profile-sync-controller/src/controllers/user-storage/UserStorageController.test.ts @@ -22,6 +22,7 @@ import { MOCK_STORAGE_KEY, MOCK_STORAGE_KEY_SIGNATURE, } from './__fixtures__/mockStorage'; +import * as AccountsUserStorageModule from './accounts/user-storage'; import encryption from './encryption/encryption'; import type { GetUserStorageAllFeatureEntriesResponse, @@ -1185,6 +1186,11 @@ describe('user-storage/user-storage-controller - saveInternalAccountToUserStorag }; }; + const mapInternalAccountToUserStorageAccountMock = jest.spyOn( + AccountsUserStorageModule, + 'mapInternalAccountToUserStorageAccount', + ); + const { messengerMocks } = await arrangeMocks(); const controller = new UserStorageController({ messenger: messengerMocks.messenger, @@ -1202,9 +1208,7 @@ describe('user-storage/user-storage-controller - saveInternalAccountToUserStorag MOCK_INTERNAL_ACCOUNTS.ONE[0] as InternalAccount, ); - expect( - messengerMocks.mockAccountsGetAccountByAddress, - ).not.toHaveBeenCalled(); + expect(mapInternalAccountToUserStorageAccountMock).not.toHaveBeenCalled(); }); it('returns void if account syncing feature flag is disabled', async () => { @@ -1431,10 +1435,6 @@ function mockUserStorageMessenger(options?: { const mockAccountsUpdateAccountMetadata = jest.fn().mockResolvedValue(true); - const mockAccountsGetAccountByAddress = jest - .fn() - .mockResolvedValue(MOCK_INTERNAL_ACCOUNTS.ONE[0]); - jest.spyOn(messenger, 'call').mockImplementation((...args) => { // Creates the correct typed call params for mocks type CallParams = { @@ -1512,17 +1512,9 @@ function mockUserStorageMessenger(options?: { return mockAccountsUpdateAccountMetadata(args.slice(1)); } - if (actionType === 'AccountsController:getAccountByAddress') { - return mockAccountsGetAccountByAddress(); - } - - const exhaustedMessengerMocks = (action: never) => { - throw new Error( - `MOCK_FAIL - unsupported messenger call: ${action as string}`, - ); - }; - - return exhaustedMessengerMocks(actionType); + throw new Error( + `MOCK_FAIL - unsupported messenger call: ${actionType as string}`, + ); }); return { @@ -1539,7 +1531,6 @@ function mockUserStorageMessenger(options?: { mockAuthPerformSignOut, mockKeyringAddNewAccount, mockAccountsUpdateAccountMetadata, - mockAccountsGetAccountByAddress, mockAccountsListAccounts, }; }