aitrean cf9887f21f Outstanding tasks to Productionize Tx (#1194)
* Verify and complete all branching saga logic tests for transaction stack.

* Write reducer tests for refactored transaction stack.

* Add selector tests. Some files still need to be debugged.

* Add snapshot test for fields, additional seelector testing.

* Remove fields snapshots.

* Remove ABIs from the TestState json

* Use redux state instead of raw json in selector testing.

* Fix merge issues.

* Remove log

* Fix state values.

* Change test value to wei.

* Last touchup.

* Fix buffer shape, change Wei typo, use reasonable wei values.

* Last touch up.
2018-03-08 12:03:45 -06:00

69 lines
1.7 KiB
TypeScript

import { Wei } from 'libs/units';
import {
getCurrentValue,
getCurrentTo,
isEtherTransaction,
isValidCurrentTo,
isValidGasPrice,
isValidGasLimit,
getCurrentToAddressMessage
} from 'selectors/transaction';
import { getInitialState } from '../helpers';
describe('current selector', () => {
const state = getInitialState();
state.transaction = {
...state.transaction,
fields: {
...state.transaction.fields,
to: {
raw: '0x4bbeEB066eD09B7AEd07bF39EEe0460DFa261520',
value: new Buffer([0, 1, 2, 3])
},
gasLimit: {
raw: '21000',
value: Wei('21000')
},
gasPrice: {
raw: '1500',
value: Wei('1500')
}
},
meta: {
...state.transaction.meta,
unit: 'ETH',
previousUnit: 'ETH'
}
};
it('should get stored receiver address on getCurrentTo', () => {
expect(getCurrentTo(state)).toEqual(state.transaction.fields.to);
});
it('should get stored value on getCurrentValue', () => {
expect(getCurrentValue(state)).toEqual(state.transaction.fields.value);
});
it('should get message to the receiver', () => {
expect(getCurrentToAddressMessage(state)).toEqual({
msg: 'Thank you for donating to MyCrypto. TO THE MOON!'
});
});
it('should check isValidGasPrice', () => {
expect(isValidGasPrice(state)).toEqual(true);
});
it('should check isEtherTransaction', () => {
expect(isEtherTransaction(state)).toEqual(true);
});
it('should check isValidGasLimit', () => {
expect(isValidGasLimit(state)).toEqual(true);
});
it('should check isValidCurrentTo', () => {
expect(isValidCurrentTo(state)).toEqual(true);
});
});