MyCrypto/spec/reducers/wallet.spec.ts

33 lines
927 B
TypeScript

import { wallet, INITIAL_STATE } from 'reducers/wallet';
import * as walletActions from 'actions/wallet';
import { TokenValue } from 'libs/units';
describe('wallet reducer', () => {
it('should handle WALLET_SET', () => {
const doSomething = new Promise<string>(resolve => {
setTimeout(() => resolve('Success'), 1000);
});
const walletInstance = {
getAddressString: () => doSomething,
signRawTransaction: () => doSomething,
signMessage: () => doSomething
};
expect(wallet(undefined, walletActions.setWallet(walletInstance))).toEqual({
...INITIAL_STATE,
inst: walletInstance
});
});
it('should handle WALLET_SET_TOKEN_BALANCES', () => {
const tokenBalances = { OMG: TokenValue('20') };
expect(
wallet(undefined, walletActions.setTokenBalances(tokenBalances))
).toEqual({
...INITIAL_STATE,
tokens: tokenBalances
});
});
});