|
1 | 1 | import { Messenger } from '@metamask/base-controller'; |
2 | 2 | import { NetworkController } from '@metamask/network-controller'; |
| 3 | +// Mocha type definitions are conflicting with Jest |
| 4 | +import { it as jestIt } from '@jest/globals'; |
3 | 5 | import { |
| 6 | + TransactionMeta, |
| 7 | + TransactionType, |
4 | 8 | TransactionController, |
5 | 9 | TransactionControllerMessenger, |
6 | 10 | TransactionControllerOptions, |
| 11 | + TransactionStatus, |
7 | 12 | } from '@metamask/transaction-controller'; |
8 | 13 | import { |
9 | 14 | getTransactionControllerInitMessenger, |
@@ -188,4 +193,33 @@ describe('Transaction Controller Init', () => { |
188 | 193 |
|
189 | 194 | expect(pendingTransactions?.isResubmitEnabled?.()).toBe(false); |
190 | 195 | }); |
| 196 | + |
| 197 | + jestIt.each([ |
| 198 | + ['swap', TransactionType.swap, false], |
| 199 | + ['swapApproval', TransactionType.swapApproval, false], |
| 200 | + ['bridge', TransactionType.bridge, false], |
| 201 | + ['bridgeApproval', TransactionType.bridgeApproval, false], |
| 202 | + ['contractInteraction', TransactionType.contractInteraction, true], |
| 203 | + ])( |
| 204 | + 'disables automatic gas fee updates for %s transactions', |
| 205 | + (_label, type, gasFeeUpdateEnabled) => { |
| 206 | + const isAutomaticGasFeeUpdateEnabled = testConstructorOption( |
| 207 | + 'isAutomaticGasFeeUpdateEnabled', |
| 208 | + ); |
| 209 | + |
| 210 | + const tx: TransactionMeta = { |
| 211 | + id: '1', |
| 212 | + type, |
| 213 | + chainId: CHAIN_ID_MOCK, |
| 214 | + networkClientId: 'test-network', |
| 215 | + status: TransactionStatus.unapproved, |
| 216 | + time: Date.now(), |
| 217 | + txParams: { |
| 218 | + from: '0x0000000000000000000000000000000000000000', |
| 219 | + }, |
| 220 | + }; |
| 221 | + |
| 222 | + expect(isAutomaticGasFeeUpdateEnabled?.(tx)).toBe(gasFeeUpdateEnabled); |
| 223 | + }, |
| 224 | + ); |
191 | 225 | }); |
0 commit comments