MyCrypto/spec/reducers/deterministicWallets.spec.ts
James Prado aabcd3f7a3 Use Network Symbol in Confirmation Modal (#1039)
* Set default unit to 'ETH' instead of 'ether'

* Use 'isEtherUnit()' everywhere

* Set default unit to empty string

* Update isEthUnit to isNetworkUnit

* Fix unit conversion for non-ethereum networks

* Set default network unit properly

* Fix tests

* fix typos

* Update isNetworkUnit selector

* Update isNetworkUnit

* Fix validationhelpers tests

* Add mock state to tests & Move isNetworkUnit to selectors

* Fix validation helper spec

* fix unit swap spec
2018-03-01 19:24:14 -06:00

67 lines
1.7 KiB
TypeScript

import { configuredStore } from 'store';
import { deterministicWallets, INITIAL_STATE } from 'reducers/deterministicWallets';
import * as dWalletActions from 'actions/deterministicWallets';
import { TokenValue } from 'libs/units';
configuredStore.getState();
describe('deterministicWallets reducer', () => {
const tokenValues: dWalletActions.ITokenValues = {
OMG: {
value: TokenValue('0'),
decimal: 16
}
};
const wallet: dWalletActions.DeterministicWalletData = {
index: 0,
address: 'address',
value: TokenValue('0'),
tokenValues
};
it('should handle DW_SET_WALLETS', () => {
const wallets = [wallet];
expect(
deterministicWallets(undefined, dWalletActions.setDeterministicWallets(wallets))
).toEqual({
...INITIAL_STATE,
wallets
});
});
it('should handle DW_SET_DESIRED_TOKEN', () => {
const desiredToken = 'OMG';
expect(deterministicWallets(undefined, dWalletActions.setDesiredToken(desiredToken))).toEqual({
...INITIAL_STATE,
desiredToken
});
});
it('should handle DW_UPDATE_WALLET', () => {
const wallet1 = {
...wallet,
address: 'wallet1'
};
const wallet2 = {
...wallet,
address: 'wallet2'
};
const wallets = [wallet1, wallet2];
const state = deterministicWallets(undefined, dWalletActions.setDeterministicWallets(wallets));
const wallet2Update = {
...wallet,
index: 100,
address: 'wallet2',
value: TokenValue('100')
};
expect(
deterministicWallets(state, dWalletActions.updateDeterministicWallet(wallet2Update))
).toEqual({
...INITIAL_STATE,
wallets: [wallet1, wallet2Update]
});
});
});