Fix more tests

This commit is contained in:
henrynguyen5 2018-02-07 21:24:56 -05:00
parent edcad4b7a9
commit 2009463f8d
5 changed files with 10 additions and 17 deletions

View File

@ -10,14 +10,7 @@ import { createMockRouteComponentProps } from '../utils/mockRouteComponentProps'
Enzyme.configure({ adapter: new Adapter() }); Enzyme.configure({ adapter: new Adapter() });
it('render snapshot', () => { it('render snapshot', () => {
const testNode = 'rop_mew'; const testStateConfig = {};
const testStateConfig = {
languageSelection: 'en',
nodeSelection: testNode,
node: NODES[testNode],
gasPriceGwei: 21,
offline: false
};
const testState = { const testState = {
wallet: {}, wallet: {},
balance: {}, balance: {},

View File

@ -5,7 +5,7 @@ import Swap from 'containers/Tabs/Swap';
import shallowWithStore from '../utils/shallowWithStore'; import shallowWithStore from '../utils/shallowWithStore';
import { createMockStore } from 'redux-test-utils'; import { createMockStore } from 'redux-test-utils';
import { INITIAL_STATE as swap } from 'reducers/swap'; 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 { RouteComponentProps } from 'react-router';
import { createMockRouteComponentProps } from '../utils/mockRouteComponentProps'; import { createMockRouteComponentProps } from '../utils/mockRouteComponentProps';
@ -22,7 +22,7 @@ const routeProps: RouteComponentProps<any> = createMockRouteComponentProps({
}); });
it('render snapshot', () => { it('render snapshot', () => {
const store = createMockStore({ swap, config }); const store = createMockStore({ swap, config: config(undefined as any, {} as any) });
const component = shallowWithStore(<Swap {...routeProps} />, store); const component = shallowWithStore(<Swap {...routeProps} />, store);
expect(component).toMatchSnapshot(); expect(component).toMatchSnapshot();

View File

@ -1,6 +1,5 @@
import { staticNetworks, makeExplorer } from 'reducers/config/networks/staticNetworks'; import { staticNetworks, makeExplorer } from 'reducers/config/networks/staticNetworks';
import { ethPlorer, ETHTokenExplorer, SecureWalletName, InsecureWalletName } from 'config/data'; import { ethPlorer, ETHTokenExplorer, SecureWalletName, InsecureWalletName } from 'config/data';
import { StaticNetworkConfig } from 'types/network';
import { import {
ETH_DEFAULT, ETH_DEFAULT,
ETH_TREZOR, ETH_TREZOR,

View File

@ -172,7 +172,7 @@ Object {
"action": Object { "action": Object {
"payload": Web3Wallet { "payload": Web3Wallet {
"address": "0xe2EdC95134bbD88443bc6D55b809F7d0C2f0C854", "address": "0xe2EdC95134bbD88443bc6D55b809F7d0C2f0C854",
"network": "ETH", "network": undefined,
}, },
"type": "WALLET_SET", "type": "WALLET_SET",
}, },

View File

@ -16,7 +16,7 @@ import { changeNodeIntent, web3UnsetNode } from 'actions/config';
import { INode } from 'libs/nodes/INode'; import { INode } from 'libs/nodes/INode';
import { N_FACTOR } from 'config'; import { N_FACTOR } from 'config';
import { apply, call, fork, put, select, take, cancel } from 'redux-saga/effects'; 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 { getWalletInst, getWalletConfigTokens } from 'selectors/wallet';
import { import {
updateAccountBalance, updateAccountBalance,
@ -38,6 +38,7 @@ import { showNotification } from 'actions/notifications';
import translate from 'translations'; import translate from 'translations';
import { IFullWallet, fromV3 } from 'ethereumjs-wallet'; import { IFullWallet, fromV3 } from 'ethereumjs-wallet';
import { Token } from 'types/network'; import { Token } from 'types/network';
import { initWeb3Node } from 'sagas/config/web3';
// init module // init module
configuredStore.getState(); configuredStore.getState();
const offline = false; const offline = false;
@ -339,13 +340,13 @@ describe('unlockWeb3*', () => {
expect(JSON.stringify(expected)).toEqual(JSON.stringify(result)); expect(JSON.stringify(expected)).toEqual(JSON.stringify(result));
}); });
it('should select getNodeLib', () => { it('should select getWeb3Node', () => {
expect(data.gen.next().value).toEqual(select(getNodeLib)); expect(data.gen.next().value).toEqual(select(getWeb3Node));
}); });
it('should throw & catch if node is not web3 node', () => { it('should throw & catch if node is not web3 node', () => {
data.clone = data.gen.clone(); 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( expect(data.clone.next().value).toEqual(
put(showNotification('danger', translate('Cannot use Web3 wallet without a Web3 node.'))) put(showNotification('danger', translate('Cannot use Web3 wallet without a Web3 node.')))
); );
@ -353,7 +354,7 @@ describe('unlockWeb3*', () => {
}); });
it('should apply nodeLib.getAccounts', () => { 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', () => { it('should throw & catch if no accounts found', () => {