Skip to content

Commit

Permalink
chore: add tests for bridge selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
infiniteflower committed Oct 2, 2024
1 parent ea07b02 commit f4e0114
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/jest/mock-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,8 @@ export const createBridgeMockStore = (
extensionSupport: false,
srcNetworkAllowlist: [],
destNetworkAllowlist: [],
approvalGasMultiplier: {},
bridgeGasMultiplier: {},
...featureFlagOverrides,
},
...bridgeStateOverrides,
Expand Down
57 changes: 57 additions & 0 deletions ui/ducks/bridge/selectors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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({});
});
});
});

0 comments on commit f4e0114

Please sign in to comment.