Skip to content

Commit

Permalink
improve test
Browse files Browse the repository at this point in the history
  • Loading branch information
adonesky1 committed Aug 28, 2024
1 parent 2cf7859 commit 4c93640
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ async function addEthereumChainHandler(
} else {
networkClientId = existingNetwork.id ?? existingNetwork.type;
const currentRpcUrl = getCurrentRpcUrl();

if (
currentChainIdForDomain === chainId &&
currentRpcUrl === firstValidRPCUrl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
CHAIN_IDS,
NETWORK_TYPES,
} from '../../../../../shared/constants/network';
import * as chainUtils from './ethereum-chain-utils';
import addEthereumChain from './add-ethereum-chain';

const NON_INFURA_CHAIN_ID = '0x123456789';
Expand Down Expand Up @@ -543,33 +542,36 @@ describe('addEthereumChainHandler', () => {
);
});

it('should add result set to null to response object if the requested rpcUrl (and chainId) is currently selected', async () => {
jest.spyOn(chainUtils, 'findExistingNetwork').mockReturnValue({
chainId: '0x1',
rpcUrl: 'https://mainnet.infura.io/v3/',
ticker: 'ETH',
});
it.only('should add result set to null to response object if the requested rpcUrl (and chainId) is currently selected', async () => {
const CURRENT_RPC_CONFIG = createMockNonInfuraConfiguration();

const mocks = makeMocks({
permissionsFeatureFlagIsActive: false,
overrides: {
getCurrentChainIdForDomain: jest.fn().mockReturnValue('0x1'),
getCurrentChainIdForDomain: jest
.fn()
.mockReturnValue(CURRENT_RPC_CONFIG.chainId),
findNetworkConfigurationBy: jest
.fn()
.mockReturnValue(CURRENT_RPC_CONFIG),
getCurrentRpcUrl: jest.fn().mockReturnValue(CURRENT_RPC_CONFIG.rpcUrl),
},
});
const res = {};

await addEthereumChainHandler(
{
origin: 'example.com',
params: [
{
chainId: CHAIN_IDS.MAINNET,
chainName: 'Ethereum Mainnet',
rpcUrls: ['https://mainnet.infura.io/v3/'],
chainId: CURRENT_RPC_CONFIG.chainId,
chainName: 'Custom Network',
rpcUrls: [CURRENT_RPC_CONFIG.rpcUrl],
nativeCurrency: {
symbol: 'ETH',
symbol: CURRENT_RPC_CONFIG.ticker,
decimals: 18,
},
blockExplorerUrls: ['https://etherscan.io'],
blockExplorerUrls: ['https://custom.blockexplorer'],
},
],
},
Expand Down

0 comments on commit 4c93640

Please sign in to comment.