Skip to content

Commit 2cceb92

Browse files
committed
Merge branch 'main' into bump-to-yarn-v4
2 parents 7f59063 + 5761ee7 commit 2cceb92

File tree

77 files changed

+2031
-1357
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+2031
-1357
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,13 @@ linkStyle default opacity:0.5
161161
signature_controller --> keyring_controller;
162162
signature_controller --> logging_controller;
163163
signature_controller --> message_manager;
164+
transaction_controller --> accounts_controller;
164165
transaction_controller --> approval_controller;
165166
transaction_controller --> base_controller;
166167
transaction_controller --> controller_utils;
167168
transaction_controller --> gas_fee_controller;
168169
transaction_controller --> network_controller;
170+
transaction_controller --> eth_json_rpc_provider;
169171
user_operation_controller --> approval_controller;
170172
user_operation_controller --> base_controller;
171173
user_operation_controller --> controller_utils;

jest.config.packages.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,7 @@ module.exports = {
108108

109109
// "resetMocks" resets all mocks, including mocked modules, to jest.fn(),
110110
// between each test case.
111-
// TODO: Enable
112-
// resetMocks: true,
111+
resetMocks: true,
113112

114113
// Reset the module registry before running each individual test
115114
// resetModules: false,

jest.config.scripts.js

+6
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,17 @@ module.exports = {
5050
// // A preset that is used as a base for Jest's configuration
5151
// preset: 'ts-jest',
5252

53+
// "resetMocks" resets all mocks, including mocked modules, to jest.fn(),
54+
// between each test case.
55+
resetMocks: true,
56+
5357
// "restoreMocks" restores all mocks created using jest.spyOn to their
5458
// original implementations, between each test. It does not affect mocked
5559
// modules.
5660
restoreMocks: true,
5761

62+
setupFilesAfterEnv: ['./tests/scripts-setup.ts'],
63+
5864
// The test environment that will be used for testing
5965
testEnvironment: 'node',
6066

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@metamask/core-monorepo",
3-
"version": "161.0.0",
3+
"version": "165.0.0",
44
"private": true,
55
"description": "Monorepo for packages shared between MetaMask clients",
66
"repository": {

packages/accounts-controller/src/AccountsController.test.ts

+29-47
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,6 @@ function setupAccountsController({
315315
}
316316

317317
describe('AccountsController', () => {
318-
afterEach(() => {
319-
jest.resetAllMocks();
320-
});
321-
322318
describe('onSnapStateChange', () => {
323319
it('be used enable an account if the Snap is enabled and not blocked', async () => {
324320
const messenger = buildMessenger();
@@ -449,9 +445,6 @@ describe('AccountsController', () => {
449445
});
450446

451447
describe('onKeyringStateChange', () => {
452-
afterEach(() => {
453-
jest.clearAllMocks();
454-
});
455448
it('not update state when only keyring is unlocked without any keyrings', async () => {
456449
const messenger = buildMessenger();
457450
const { accountsController } = setupAccountsController({
@@ -1085,16 +1078,10 @@ describe('AccountsController', () => {
10851078
initialState: {
10861079
internalAccounts: {
10871080
accounts: {
1088-
'missing-account': {
1089-
id: 'missing-account',
1081+
'missing-account': createMockInternalAccount({
10901082
address: '0x999',
1091-
metadata: {
1092-
keyring: {
1093-
type: KeyringTypes.hd,
1094-
},
1095-
},
1096-
[mockAccount2.id]: mockAccount2WithoutLastSelected,
1097-
} as unknown as InternalAccount,
1083+
id: 'missing-account',
1084+
}),
10981085
[mockAccount.id]: mockAccountWithoutLastSelected,
10991086
[mockAccount2.id]: mockAccount2WithoutLastSelected,
11001087
},
@@ -1304,10 +1291,6 @@ describe('AccountsController', () => {
13041291
);
13051292
});
13061293

1307-
afterEach(() => {
1308-
jest.clearAllMocks();
1309-
});
1310-
13111294
it('update accounts with normal accounts', async () => {
13121295
mockUUID.mockReturnValueOnce('mock-id').mockReturnValueOnce('mock-id2');
13131296
const messenger = buildMessenger();
@@ -1861,6 +1844,32 @@ describe('AccountsController', () => {
18611844
'No EVM accounts',
18621845
);
18631846
});
1847+
1848+
it('handle the edge case of undefined accountId during onboarding', async () => {
1849+
const { accountsController } = setupAccountsController({
1850+
initialState: {
1851+
internalAccounts: {
1852+
accounts: {},
1853+
selectedAccount: '',
1854+
},
1855+
},
1856+
});
1857+
1858+
expect(accountsController.getSelectedAccount()).toStrictEqual({
1859+
id: '',
1860+
address: '',
1861+
options: {},
1862+
methods: [],
1863+
type: EthAccountType.Eoa,
1864+
metadata: {
1865+
name: '',
1866+
keyring: {
1867+
type: '',
1868+
},
1869+
importTime: 0,
1870+
},
1871+
});
1872+
});
18641873
});
18651874

18661875
describe('getSelectedMultichainAccount', () => {
@@ -2071,33 +2080,6 @@ describe('AccountsController', () => {
20712080
`Account Id "${accountId}" not found`,
20722081
);
20732082
});
2074-
2075-
it('handle the edge case of undefined accountId during onboarding', async () => {
2076-
const { accountsController } = setupAccountsController({
2077-
initialState: {
2078-
internalAccounts: {
2079-
accounts: { [mockAccount.id]: mockAccount },
2080-
selectedAccount: mockAccount.id,
2081-
},
2082-
},
2083-
});
2084-
2085-
// @ts-expect-error forcing undefined accountId
2086-
expect(accountsController.getAccountExpect(undefined)).toStrictEqual({
2087-
id: '',
2088-
address: '',
2089-
options: {},
2090-
methods: [],
2091-
type: EthAccountType.Eoa,
2092-
metadata: {
2093-
name: '',
2094-
keyring: {
2095-
type: '',
2096-
},
2097-
importTime: 0,
2098-
},
2099-
});
2100-
});
21012083
});
21022084

21032085
describe('setSelectedAccount', () => {

0 commit comments

Comments
 (0)