From 2009463f8d9433b582e89989aba1cdf3c848a29d Mon Sep 17 00:00:00 2001 From: henrynguyen5 Date: Wed, 7 Feb 2018 21:24:56 -0500 Subject: [PATCH] Fix more tests --- spec/pages/SendTransaction.spec.tsx | 9 +-------- spec/pages/Swap.spec.tsx | 4 ++-- spec/reducers/config/networks/staticNetworks.spec.ts | 1 - spec/sagas/__snapshots__/wallet.spec.tsx.snap | 2 +- spec/sagas/wallet.spec.tsx | 11 ++++++----- 5 files changed, 10 insertions(+), 17 deletions(-) diff --git a/spec/pages/SendTransaction.spec.tsx b/spec/pages/SendTransaction.spec.tsx index d086b683..b6bf1c2d 100644 --- a/spec/pages/SendTransaction.spec.tsx +++ b/spec/pages/SendTransaction.spec.tsx @@ -10,14 +10,7 @@ import { createMockRouteComponentProps } from '../utils/mockRouteComponentProps' Enzyme.configure({ adapter: new Adapter() }); it('render snapshot', () => { - const testNode = 'rop_mew'; - const testStateConfig = { - languageSelection: 'en', - nodeSelection: testNode, - node: NODES[testNode], - gasPriceGwei: 21, - offline: false - }; + const testStateConfig = {}; const testState = { wallet: {}, balance: {}, diff --git a/spec/pages/Swap.spec.tsx b/spec/pages/Swap.spec.tsx index 3928b607..a738eac2 100644 --- a/spec/pages/Swap.spec.tsx +++ b/spec/pages/Swap.spec.tsx @@ -5,7 +5,7 @@ import Swap from 'containers/Tabs/Swap'; import shallowWithStore from '../utils/shallowWithStore'; import { createMockStore } from 'redux-test-utils'; import { INITIAL_STATE as swap } from 'reducers/swap'; -import { INITIAL_STATE as config } from 'reducers/config'; +import { config } from 'reducers/config'; import { RouteComponentProps } from 'react-router'; import { createMockRouteComponentProps } from '../utils/mockRouteComponentProps'; @@ -22,7 +22,7 @@ const routeProps: RouteComponentProps = createMockRouteComponentProps({ }); it('render snapshot', () => { - const store = createMockStore({ swap, config }); + const store = createMockStore({ swap, config: config(undefined as any, {} as any) }); const component = shallowWithStore(, store); expect(component).toMatchSnapshot(); diff --git a/spec/reducers/config/networks/staticNetworks.spec.ts b/spec/reducers/config/networks/staticNetworks.spec.ts index 4ce6d276..41ff0fc6 100644 --- a/spec/reducers/config/networks/staticNetworks.spec.ts +++ b/spec/reducers/config/networks/staticNetworks.spec.ts @@ -1,6 +1,5 @@ import { staticNetworks, makeExplorer } from 'reducers/config/networks/staticNetworks'; import { ethPlorer, ETHTokenExplorer, SecureWalletName, InsecureWalletName } from 'config/data'; -import { StaticNetworkConfig } from 'types/network'; import { ETH_DEFAULT, ETH_TREZOR, diff --git a/spec/sagas/__snapshots__/wallet.spec.tsx.snap b/spec/sagas/__snapshots__/wallet.spec.tsx.snap index bcdea4eb..1cebb6d4 100644 --- a/spec/sagas/__snapshots__/wallet.spec.tsx.snap +++ b/spec/sagas/__snapshots__/wallet.spec.tsx.snap @@ -172,7 +172,7 @@ Object { "action": Object { "payload": Web3Wallet { "address": "0xe2EdC95134bbD88443bc6D55b809F7d0C2f0C854", - "network": "ETH", + "network": undefined, }, "type": "WALLET_SET", }, diff --git a/spec/sagas/wallet.spec.tsx b/spec/sagas/wallet.spec.tsx index e1033100..664d4752 100644 --- a/spec/sagas/wallet.spec.tsx +++ b/spec/sagas/wallet.spec.tsx @@ -16,7 +16,7 @@ import { changeNodeIntent, web3UnsetNode } from 'actions/config'; import { INode } from 'libs/nodes/INode'; import { N_FACTOR } from 'config'; import { apply, call, fork, put, select, take, cancel } from 'redux-saga/effects'; -import { getNodeLib, getOffline } from 'selectors/config'; +import { getNodeLib, getOffline, getWeb3Node } from 'selectors/config'; import { getWalletInst, getWalletConfigTokens } from 'selectors/wallet'; import { updateAccountBalance, @@ -38,6 +38,7 @@ import { showNotification } from 'actions/notifications'; import translate from 'translations'; import { IFullWallet, fromV3 } from 'ethereumjs-wallet'; import { Token } from 'types/network'; +import { initWeb3Node } from 'sagas/config/web3'; // init module configuredStore.getState(); const offline = false; @@ -339,13 +340,13 @@ describe('unlockWeb3*', () => { expect(JSON.stringify(expected)).toEqual(JSON.stringify(result)); }); - it('should select getNodeLib', () => { - expect(data.gen.next().value).toEqual(select(getNodeLib)); + it('should select getWeb3Node', () => { + expect(data.gen.next().value).toEqual(select(getWeb3Node)); }); it('should throw & catch if node is not web3 node', () => { data.clone = data.gen.clone(); - expect(data.clone.next().value).toEqual(put(web3UnsetNode())); + expect(data.clone.next(nodeLib).value).toEqual(put(web3UnsetNode())); expect(data.clone.next().value).toEqual( put(showNotification('danger', translate('Cannot use Web3 wallet without a Web3 node.'))) ); @@ -353,7 +354,7 @@ describe('unlockWeb3*', () => { }); it('should apply nodeLib.getAccounts', () => { - expect(data.gen.next(nodeLib).value).toEqual(apply(nodeLib, nodeLib.getAccounts)); + expect(data.gen.next({ lib: nodeLib }).value).toEqual(apply(nodeLib, nodeLib.getAccounts)); }); it('should throw & catch if no accounts found', () => {