2018-03-02 01:24:14 +00:00
|
|
|
import { configuredStore } from 'store';
|
2018-02-12 20:43:07 +00:00
|
|
|
import { web3SetNode, web3UnsetNode } from 'actions/config';
|
|
|
|
import { staticNodes, INITIAL_STATE } from 'reducers/config/nodes/staticNodes';
|
|
|
|
import { Web3Service } from 'libs/nodes/web3';
|
2018-04-06 20:52:48 +00:00
|
|
|
import { StaticNodeConfig } from 'types/node';
|
2018-03-02 01:24:14 +00:00
|
|
|
configuredStore.getState();
|
2018-02-12 20:43:07 +00:00
|
|
|
|
|
|
|
const web3Id = 'web3';
|
2018-04-06 20:52:48 +00:00
|
|
|
const web3Node: StaticNodeConfig = {
|
2018-02-12 20:43:07 +00:00
|
|
|
isCustom: false,
|
|
|
|
network: 'ETH',
|
|
|
|
service: Web3Service,
|
|
|
|
lib: jest.fn() as any,
|
|
|
|
estimateGas: false,
|
|
|
|
hidden: true
|
|
|
|
};
|
|
|
|
|
|
|
|
const expectedState = {
|
2018-04-06 14:02:02 +00:00
|
|
|
initialState: staticNodes(undefined, {} as any),
|
2018-02-12 20:43:07 +00:00
|
|
|
setWeb3: { ...INITIAL_STATE, [web3Id]: web3Node },
|
|
|
|
unsetWeb3: { ...INITIAL_STATE }
|
|
|
|
};
|
|
|
|
|
|
|
|
const actions = {
|
|
|
|
web3SetNode: web3SetNode({ id: web3Id, config: web3Node }),
|
|
|
|
web3UnsetNode: web3UnsetNode()
|
|
|
|
};
|
|
|
|
|
|
|
|
describe('static nodes reducer', () => {
|
|
|
|
it('should handle setting the web3 node', () =>
|
|
|
|
expect(staticNodes(INITIAL_STATE, actions.web3SetNode)).toEqual(expectedState.setWeb3));
|
|
|
|
|
|
|
|
it('should handle unsetting the web3 node', () =>
|
|
|
|
expect(staticNodes(expectedState.setWeb3, actions.web3UnsetNode)).toEqual(
|
|
|
|
expectedState.unsetWeb3
|
|
|
|
));
|
|
|
|
});
|
|
|
|
|
|
|
|
export { actions as staticNodesActions, expectedState as staticNodesExpectedState };
|