Export needed variables

This commit is contained in:
henrynguyen5 2018-02-07 18:18:52 -05:00
parent dccd976043
commit d0c0dd541b
7 changed files with 33 additions and 17 deletions

View File

@ -72,3 +72,5 @@ describe('meta reducer', () => {
expectedState.settingLatestBlock
));
});
export { actions as metaActions, expectedState as metaExpectedState };

View File

@ -58,3 +58,5 @@ describe('custom networks reducer', () => {
customNetworks(expectedState.addSecondCustomNetwork, actions.removeFirstCustomNetwork)
).toEqual(expectedState.removeFirstCustomNetwork));
});
export { actions as customNetworksActions, expectedState as customNetworksExpectedState };

View File

@ -14,3 +14,5 @@ describe('selected network reducer', () => {
expectedState.nodeChange
));
});
export { actions as selectedNetworkActions, expectedState as selectedNetworkExpectedState };

View File

@ -146,3 +146,5 @@ describe('static networks reducer', () => {
JSON.stringify(expectedState.initialState)
));
});
export { expectedState as staticNetworksExpectedState };

View File

@ -2,7 +2,7 @@ import { addCustomNode, removeCustomNode } from 'actions/config';
import { CustomNodeConfig } from 'types/node';
import { customNodes } from 'reducers/config/nodes/customNodes';
const firstCustomNodeId = 'customNode1';
export const firstCustomNodeId = 'customNode1';
const firstCustomNode: CustomNodeConfig = {
isCustom: true,
id: firstCustomNodeId,
@ -20,7 +20,7 @@ const secondCustomNode: CustomNodeConfig = {
id: secondCustomNodeId
};
const expectedStates = {
const expectedState = {
initialState: {},
addFirstCustomNode: { [firstCustomNodeId]: firstCustomNode },
addSecondCustomNode: {
@ -41,15 +41,17 @@ describe('custom nodes reducer', () => {
expect(customNodes(undefined, {} as any)).toEqual({}));
it('should handle adding the first custom node', () =>
expect(customNodes(expectedStates.initialState, actions.addFirstCustomNode)).toEqual(
expectedStates.addFirstCustomNode
expect(customNodes(expectedState.initialState, actions.addFirstCustomNode)).toEqual(
expectedState.addFirstCustomNode
));
it('should handle adding a second custom node', () =>
expect(customNodes(expectedStates.addFirstCustomNode, actions.addSecondCustomNode)).toEqual(
expectedStates.addSecondCustomNode
expect(customNodes(expectedState.addFirstCustomNode, actions.addSecondCustomNode)).toEqual(
expectedState.addSecondCustomNode
));
it('should handle removing the first custom node', () =>
expect(customNodes(expectedStates.addSecondCustomNode, actions.removeFirstCustomNode)).toEqual(
expectedStates.removeFirstCustomNode
expect(customNodes(expectedState.addSecondCustomNode, actions.removeFirstCustomNode)).toEqual(
expectedState.removeFirstCustomNode
));
});
export { actions as customNodesActions, expectedState as customNodesExpectedState };

View File

@ -1,7 +1,7 @@
import { changeNodeIntent, changeNode } from 'actions/config';
import { State, selectedNode } from 'reducers/config/nodes/selectedNode';
export const expectedState: { [key: string]: State } = {
export const expectedState = {
initialState: { nodeId: 'eth_mew', pending: false },
nodeChange: { nodeId: 'nodeToChangeTo', pending: false },
nodeChangeIntent: { nodeId: 'eth_mew', pending: true }
@ -20,7 +20,9 @@ describe('selected node reducer', () => {
expect(selectedNode(undefined, actions.changeNode)).toEqual(expectedState.nodeChange));
it('should handle the intent to change a node', () =>
expect(selectedNode(expectedState.initialState, actions.changeNodeIntent)).toEqual(
expect(selectedNode(expectedState.initialState as State, actions.changeNodeIntent)).toEqual(
expectedState.nodeChangeIntent
));
});
export { actions as selectedNodeActions, expectedState as selectedNodeExpectedState };

View File

@ -5,7 +5,7 @@ import { Web3NodeConfig } from 'types/node';
import { networkIdToName } from 'libs/values';
import { Web3Service } from 'libs/nodes/web3';
const expectedInitialState = JSON.stringify({
const expectedInitialState = {
eth_mew: {
network: 'ETH',
isCustom: false,
@ -90,7 +90,7 @@ const expectedInitialState = JSON.stringify({
lib: new RPCNode('https://node.expanse.tech/'),
estimateGas: true
}
});
};
const web3Id = 'web3';
const web3NetworkId = 1;
@ -103,7 +103,7 @@ const web3Node: Web3NodeConfig = {
hidden: true
};
const expectedStates = {
const expectedState = {
initialState: expectedInitialState,
setWeb3: { ...INITIAL_STATE, [web3Id]: web3Node },
unsetWeb3: { ...INITIAL_STATE }
@ -117,12 +117,16 @@ const actions = {
describe('static nodes reducer', () => {
it('should return the inital state', () =>
// turn the JSON into a string because we're storing function in the state
expect(JSON.stringify(staticNodes(undefined, {} as any))).toEqual(expectedStates.initialState));
expect(JSON.stringify(staticNodes(undefined, {} as any))).toEqual(
JSON.stringify(expectedState.initialState)
));
it('should handle setting the web3 node', () =>
expect(staticNodes(INITIAL_STATE, actions.web3SetNode)).toEqual(expectedStates.setWeb3));
expect(staticNodes(INITIAL_STATE, actions.web3SetNode)).toEqual(expectedState.setWeb3));
it('should handle unsetting the web3 node', () =>
expect(staticNodes(expectedStates.setWeb3, actions.web3UnsetNode)).toEqual(
expectedStates.unsetWeb3
expect(staticNodes(expectedState.setWeb3, actions.web3UnsetNode)).toEqual(
expectedState.unsetWeb3
));
});
export { actions as staticNodesActions, expectedState as staticNodesExpectedState };