diff --git a/src/utils/ConfigHelper.ts b/src/utils/ConfigHelper.ts index f49575f7..ebcb0360 100644 --- a/src/utils/ConfigHelper.ts +++ b/src/utils/ConfigHelper.ts @@ -1,7 +1,7 @@ import Config from '../models/Config' export interface ConfigHelperConfig extends Config { - chainId?: number + chainId: 1 | 4 | number network: 'mainnet' | 'rinkeby' | 'development' | string } diff --git a/test/unit/utils/ConfigHelper.test.ts b/test/unit/utils/ConfigHelper.test.ts new file mode 100644 index 00000000..a36962ac --- /dev/null +++ b/test/unit/utils/ConfigHelper.test.ts @@ -0,0 +1,23 @@ +import { assert } from 'chai' +import { ConfigHelper } from '../../../src/lib' + +describe('ConfigHelper', () => { + it('should get config based on network name', () => { + const network = 'rinkeby' + const config = new ConfigHelper().getConfig(network) + assert(config.network === network) + }) + + it('should get config based on network name, and add passed Infura ID', () => { + const network = 'rinkeby' + const infuraId = 'helloInfura' + const config = new ConfigHelper().getConfig(network, infuraId) + assert(config.nodeUri.includes(infuraId)) + }) + + it('should get config based on chain ID', () => { + const chainId = 4 + const config = new ConfigHelper().getConfigById(chainId) + assert(config.chainId === chainId) + }) +})