2017-08-24 08:53:59 +00:00
|
|
|
import { wallet, INITIAL_STATE } from 'reducers/wallet';
|
|
|
|
import * as walletActions from 'actions/wallet';
|
|
|
|
import Big from 'bignumber.js';
|
|
|
|
|
|
|
|
describe('wallet reducer', () => {
|
|
|
|
it('should handle WALLET_SET', () => {
|
2017-10-25 02:17:26 +00:00
|
|
|
const doSomething = new Promise<string>(resolve => {
|
|
|
|
setTimeout(() => resolve('Success'), 1000);
|
|
|
|
});
|
|
|
|
|
|
|
|
const walletInstance = {
|
2017-11-08 18:16:43 +00:00
|
|
|
getAddressString: () => doSomething,
|
2017-10-30 19:10:25 +00:00
|
|
|
signRawTransaction: () => doSomething,
|
|
|
|
signMessage: () => doSomething
|
2017-10-25 02:17:26 +00:00
|
|
|
};
|
|
|
|
|
2017-08-24 08:53:59 +00:00
|
|
|
expect(wallet(undefined, walletActions.setWallet(walletInstance))).toEqual({
|
|
|
|
...INITIAL_STATE,
|
|
|
|
inst: walletInstance,
|
2017-09-12 22:15:23 +00:00
|
|
|
balance: null,
|
2017-08-24 08:53:59 +00:00
|
|
|
tokens: {}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should handle WALLET_SET_TOKEN_BALANCES', () => {
|
|
|
|
const tokenBalances = { OMG: new Big(20) };
|
|
|
|
expect(
|
|
|
|
wallet(undefined, walletActions.setTokenBalances(tokenBalances))
|
|
|
|
).toEqual({
|
|
|
|
...INITIAL_STATE,
|
|
|
|
tokens: tokenBalances
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|