Skip to content

Commit

Permalink
Merge branch 'main' of github.com:MetaMask/core into notify/clean-up-…
Browse files Browse the repository at this point in the history
…sdk-connect-snap
  • Loading branch information
Prithpal-Sooriya committed Sep 16, 2024
2 parents 18ed33d + 2fe4b0b commit 72e5cfa
Showing 1 changed file with 10 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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 () => {
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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 {
Expand All @@ -1539,7 +1531,6 @@ function mockUserStorageMessenger(options?: {
mockAuthPerformSignOut,
mockKeyringAddNewAccount,
mockAccountsUpdateAccountMetadata,
mockAccountsGetAccountByAddress,
mockAccountsListAccounts,
};
}
Expand Down

0 comments on commit 72e5cfa

Please sign in to comment.