MyCrypto/spec/reducers/config.spec.ts
skubakdj c31490c8b4 Redux Reducer Tests (#390)
* set return type in resetWallet action creator

* update config reducer test

* update generateWallet reducer test

* update swap reducer test

* update wallet reducer test

* create customTokens reducer test

* create deterministicWallets reducer test

* create ens reducer test

* create notifications reducer test

* add crypto compare success/fail actions

* add rates reducer test

* remove unnecessary comments

* remove more comments

* remove duplicate import

* update wallet reducer test to use BN

* update dWallet reducer test to use BN

* update wallet reducer tests

* update rates reducer tests
2017-11-17 13:12:27 -08:00

80 lines
1.8 KiB
TypeScript

import { config, INITIAL_STATE } from 'reducers/config';
import * as configActions from 'actions/config';
import { NODES } from 'config/data';
describe('config reducer', () => {
it('should handle CONFIG_LANGUAGE_CHANGE', () => {
const language = 'en';
expect(config(undefined, configActions.changeLanguage(language))).toEqual({
...INITIAL_STATE,
languageSelection: language
});
});
it('should handle CONFIG_NODE_CHANGE', () => {
const node = Object.keys(NODES)[0];
expect(config(undefined, configActions.changeNode(node))).toEqual({
...INITIAL_STATE,
nodeSelection: node
});
});
it('should handle CONFIG_GAS_PRICE', () => {
const gasPrice = 20;
expect(config(undefined, configActions.changeGasPrice(gasPrice))).toEqual({
...INITIAL_STATE,
gasPriceGwei: gasPrice
});
});
it('should handle CONFIG_TOGGLE_OFFLINE', () => {
const offlineState = {
...INITIAL_STATE,
offline: true
};
const onlineState = {
...INITIAL_STATE,
offline: false
};
expect(config(offlineState, configActions.toggleOfflineConfig())).toEqual({
...offlineState,
offline: false
});
expect(config(onlineState, configActions.toggleOfflineConfig())).toEqual({
...onlineState,
offline: true
});
});
it('should handle CONFIG_FORCE_OFFLINE', () => {
const forceOfflineTrue = {
...INITIAL_STATE,
forceOffline: true
};
const forceOfflineFalse = {
...INITIAL_STATE,
forceOffline: false
};
expect(
config(forceOfflineTrue, configActions.forceOfflineConfig())
).toEqual({
...forceOfflineTrue,
forceOffline: false
});
expect(
config(forceOfflineFalse, configActions.forceOfflineConfig())
).toEqual({
...forceOfflineFalse,
forceOffline: true
});
});
});