From ba53d6ab6ae138f4c99ea58f9c01089e42089958 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Tue, 8 Sep 2020 19:10:34 +0200 Subject: [PATCH] add config helper test --- src/utils/ConfigHelper.ts | 2 +- test/unit/utils/ConfigHelper.test.ts | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 test/unit/utils/ConfigHelper.test.ts 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) + }) +})