MyCrypto/spec/config/tokens.spec.ts
James Prado aabcd3f7a3 Use Network Symbol in Confirmation Modal (#1039)
* Set default unit to 'ETH' instead of 'ether'

* Use 'isEtherUnit()' everywhere

* Set default unit to empty string

* Update isEthUnit to isNetworkUnit

* Fix unit conversion for non-ethereum networks

* Set default network unit properly

* Fix tests

* fix typos

* Update isNetworkUnit selector

* Update isNetworkUnit

* Fix validationhelpers tests

* Add mock state to tests & Move isNetworkUnit to selectors

* Fix validation helper spec

* fix unit swap spec
2018-03-01 19:24:14 -06:00

43 lines
1.4 KiB
TypeScript

import { configuredStore } from 'store';
import TOKENS from 'config/tokens';
import { isValidETHAddress } from 'libs/validators';
configuredStore.getState();
describe('Tokens JSON', () => {
Object.keys(TOKENS).forEach(network => {
it(`${network} tokens array properly formatted`, () => {
const tokens = TOKENS[network];
const addressCollisionMap = {};
const symbolCollisionMap = {};
tokens.forEach(token => {
if (!isValidETHAddress(token.address)) {
throw Error(`Token ${token.symbol} has invalid contract address '${token.address}'`);
}
if (addressCollisionMap[token.address]) {
throw Error(
`Token ${token.symbol} has the same address as ${addressCollisionMap[token.address]}`
);
}
if (symbolCollisionMap[token.symbol]) {
throw Error(
`Symbol ${token.symbol} is repeated between tokens at ${token.address} and ${
symbolCollisionMap[token.symbol]
}`
);
}
if (
token.decimal < 0 ||
token.decimal > 18 ||
token.decimal === null ||
token.decimal === undefined
) {
throw Error(`Token ${token.symbol} has invalid decimal '${token.decimal}'`);
}
addressCollisionMap[token.address] = token.symbol;
symbolCollisionMap[token.symbol] = token.address;
});
});
});
});