Skip to content

Commit

Permalink
chore: add test for getAddTransactionRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
martahj committed Sep 12, 2024
1 parent b881549 commit b896b4b
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions app/scripts/metamask-controller.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,76 @@ describe('MetaMaskController', () => {
});
});

describe('#getAddTransactionRequest', () => {
it('formats the transaction for submission', () => {
const transactionParams = { from: '0xa', to: '0xb' };
const transactionOptions = { foo: true };
const result = metamaskController.getAddTransactionRequest({
transactionParams,
transactionOptions,
});
expect(result).toEqual(
expect.objectContaining({
internalAccounts:
metamaskController.accountsController.listAccounts(),
dappRequest: undefined,
networkClientId:
metamaskController.networkController.state
.selectedNetworkClientId,
selectedAccount:
metamaskController.accountsController.getAccountByAddress(
transactionParams.from,
),
transactionController: expect.objectContaining({}),
transactionOptions,
transactionParams,
userOperationController: expect.objectContaining({}),
chainId: '0x1',
ppomController: expect.objectContaining({}),
securityAlertsEnabled:
metamaskController.preferencesController.store.getState()
?.securityAlertsEnabled,
updateSecurityAlertResponse: expect.any,
}),
);
});
it('passes through any additional params to the object', () => {
const transactionParams = { from: '0xa', to: '0xb' };
const transactionOptions = { foo: true };
const result = metamaskController.getAddTransactionRequest({
transactionParams,
transactionOptions,
test: '123',
});

expect(result).toEqual(
expect.objectContaining({
internalAccounts:
metamaskController.accountsController.listAccounts(),
dappRequest: undefined,
networkClientId:
metamaskController.networkController.state
.selectedNetworkClientId,
selectedAccount:
metamaskController.accountsController.getAccountByAddress(
transactionParams.from,
),
transactionController: expect.objectContaining({}),
transactionOptions,
transactionParams,
userOperationController: expect.objectContaining({}),
chainId: '0x1',
ppomController: expect.objectContaining({}),
securityAlertsEnabled:
metamaskController.preferencesController.store.getState()
?.securityAlertsEnabled,
updateSecurityAlertResponse: expect.any,
test: '123',
}),
);
});
});

describe('submitPassword', () => {
it('removes any identities that do not correspond to known accounts.', async () => {
const fakeAddress = '0xbad0';
Expand Down

0 comments on commit b896b4b

Please sign in to comment.