2018-03-02 01:24:14 +00:00
|
|
|
import { configuredStore } from 'store';
|
2018-01-15 09:57:09 +00:00
|
|
|
import { deterministicWallets, INITIAL_STATE } from 'reducers/deterministicWallets';
|
2017-11-17 21:12:27 +00:00
|
|
|
import * as dWalletActions from 'actions/deterministicWallets';
|
|
|
|
import { TokenValue } from 'libs/units';
|
2018-03-02 01:24:14 +00:00
|
|
|
configuredStore.getState();
|
2017-11-17 21:12:27 +00:00
|
|
|
|
|
|
|
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(
|
2018-01-15 09:57:09 +00:00
|
|
|
deterministicWallets(undefined, dWalletActions.setDeterministicWallets(wallets))
|
2017-11-17 21:12:27 +00:00
|
|
|
).toEqual({
|
|
|
|
...INITIAL_STATE,
|
|
|
|
wallets
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should handle DW_SET_DESIRED_TOKEN', () => {
|
|
|
|
const desiredToken = 'OMG';
|
2018-01-15 09:57:09 +00:00
|
|
|
expect(deterministicWallets(undefined, dWalletActions.setDesiredToken(desiredToken))).toEqual({
|
2017-11-17 21:12:27 +00:00
|
|
|
...INITIAL_STATE,
|
|
|
|
desiredToken
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should handle DW_UPDATE_WALLET', () => {
|
|
|
|
const wallet1 = {
|
|
|
|
...wallet,
|
|
|
|
address: 'wallet1'
|
|
|
|
};
|
|
|
|
const wallet2 = {
|
|
|
|
...wallet,
|
|
|
|
address: 'wallet2'
|
|
|
|
};
|
|
|
|
const wallets = [wallet1, wallet2];
|
2018-01-15 09:57:09 +00:00
|
|
|
const state = deterministicWallets(undefined, dWalletActions.setDeterministicWallets(wallets));
|
2017-11-17 21:12:27 +00:00
|
|
|
|
|
|
|
const wallet2Update = {
|
|
|
|
...wallet,
|
|
|
|
index: 100,
|
|
|
|
address: 'wallet2',
|
|
|
|
value: TokenValue('100')
|
|
|
|
};
|
|
|
|
|
|
|
|
expect(
|
2018-01-15 09:57:09 +00:00
|
|
|
deterministicWallets(state, dWalletActions.updateDeterministicWallet(wallet2Update))
|
2017-11-17 21:12:27 +00:00
|
|
|
).toEqual({
|
|
|
|
...INITIAL_STATE,
|
|
|
|
wallets: [wallet1, wallet2Update]
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|