You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.4 KiB
49 lines
1.4 KiB
4 years ago
|
import assert from 'assert';
|
||
4 years ago
|
import {
|
||
|
MAINNET_CHAIN_ID,
|
||
|
ROPSTEN_CHAIN_ID,
|
||
4 years ago
|
} from '../../shared/constants/network';
|
||
|
import getAccountLink from './account-link';
|
||
5 years ago
|
|
||
|
describe('Account link', function () {
|
||
|
describe('getAccountLink', function () {
|
||
|
it('should return the correct block explorer url for an account', function () {
|
||
|
const tests = [
|
||
|
{
|
||
|
expected: 'https://etherscan.io/address/0xabcd',
|
||
4 years ago
|
chainId: MAINNET_CHAIN_ID,
|
||
5 years ago
|
address: '0xabcd',
|
||
|
},
|
||
|
{
|
||
|
expected: 'https://ropsten.etherscan.io/address/0xdef0',
|
||
4 years ago
|
chainId: ROPSTEN_CHAIN_ID,
|
||
5 years ago
|
address: '0xdef0',
|
||
|
rpcPrefs: {},
|
||
|
},
|
||
|
{
|
||
|
// test handling of `blockExplorerUrl` for a custom RPC
|
||
|
expected: 'https://block.explorer/address/0xabcd',
|
||
4 years ago
|
chainId: '0x21',
|
||
5 years ago
|
address: '0xabcd',
|
||
|
rpcPrefs: {
|
||
|
blockExplorerUrl: 'https://block.explorer',
|
||
|
},
|
||
|
},
|
||
|
{
|
||
|
// test handling of trailing `/` in `blockExplorerUrl` for a custom RPC
|
||
|
expected: 'https://another.block.explorer/address/0xdef0',
|
||
4 years ago
|
chainId: '0x1f',
|
||
5 years ago
|
address: '0xdef0',
|
||
|
rpcPrefs: {
|
||
|
blockExplorerUrl: 'https://another.block.explorer/',
|
||
|
},
|
||
|
},
|
||
4 years ago
|
];
|
||
5 years ago
|
|
||
4 years ago
|
tests.forEach(({ expected, address, chainId, rpcPrefs }) => {
|
||
|
assert.equal(getAccountLink(address, chainId, rpcPrefs), expected);
|
||
4 years ago
|
});
|
||
|
});
|
||
|
});
|
||
|
});
|