From f4e0114cb0d03e10449ae2f988c8fd739a9c25f5 Mon Sep 17 00:00:00 2001 From: IF <139582705+infiniteflower@users.noreply.github.com> Date: Wed, 2 Oct 2024 16:29:20 -0400 Subject: [PATCH] chore: add tests for bridge selectors --- test/jest/mock-store.js | 2 ++ ui/ducks/bridge/selectors.test.ts | 57 +++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/test/jest/mock-store.js b/test/jest/mock-store.js index 14af0584c1f4..7e559db4451e 100644 --- a/test/jest/mock-store.js +++ b/test/jest/mock-store.js @@ -681,6 +681,8 @@ export const createBridgeMockStore = ( extensionSupport: false, srcNetworkAllowlist: [], destNetworkAllowlist: [], + approvalGasMultiplier: {}, + bridgeGasMultiplier: {}, ...featureFlagOverrides, }, ...bridgeStateOverrides, diff --git a/ui/ducks/bridge/selectors.test.ts b/ui/ducks/bridge/selectors.test.ts index cf27790aa943..e223dbef556a 100644 --- a/ui/ducks/bridge/selectors.test.ts +++ b/ui/ducks/bridge/selectors.test.ts @@ -8,6 +8,8 @@ import { ALLOWED_BRIDGE_CHAIN_IDS } from '../../../shared/constants/bridge'; import { mockNetworkState } from '../../../test/stub/networks'; import { getAllBridgeableNetworks, + getApprovalGasMultipliers, + getBridgeGasMultipliers, getFromAmount, getFromChain, getFromChains, @@ -491,4 +493,59 @@ describe('Bridge selectors', () => { expect(result).toStrictEqual([{ address: '0x00', symbol: 'TEST' }]); }); }); + + describe('getApprovalGasMultipliers', () => { + it('returns approval gas multipliers when present', () => { + const state = createBridgeMockStore( + { + approvalGasMultiplier: { + [CHAIN_IDS.MAINNET]: 1.1, + [CHAIN_IDS.LINEA_MAINNET]: 1.2, + }, + }, + {}, + {}, + {}, + ); + const result = getApprovalGasMultipliers(state as never); + expect(result).toEqual({ + [CHAIN_IDS.MAINNET]: 1.1, + [CHAIN_IDS.LINEA_MAINNET]: 1.2, + }); + }); + + it('returns an empty object when approval gas multipliers are not present', () => { + const state = createBridgeMockStore(); + const result = getApprovalGasMultipliers(state as never); + expect(result).toEqual({}); + }); + }); + + describe('getBridgeGasMultipliers', () => { + it('should return bridge gas multipliers when present', () => { + const state = createBridgeMockStore( + { + bridgeGasMultiplier: { + [CHAIN_IDS.MAINNET]: 1.1, + [CHAIN_IDS.LINEA_MAINNET]: 1.2, + }, + }, + {}, + {}, + {}, + ); + + const result = getBridgeGasMultipliers(state as never); + expect(result).toEqual({ + [CHAIN_IDS.MAINNET]: 1.1, + [CHAIN_IDS.LINEA_MAINNET]: 1.2, + }); + }); + + it('should return an empty object when bridge gas multipliers are not present', () => { + const state = createBridgeMockStore(); + const result = getBridgeGasMultipliers(state as never); + expect(result).toEqual({}); + }); + }); });