MyCrypto/spec/selectors/transaction/broadcast.spec.ts
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

64 lines
1.9 KiB
TypeScript

import {
getTransactionStatus,
currentTransactionFailed,
currentTransactionBroadcasting,
currentTransactionBroadcasted,
getCurrentTransactionStatus
} from 'selectors/transaction';
import { getInitialState } from '../helpers';
describe('broadcast selector', () => {
const state = getInitialState();
state.transaction = {
...state.transaction,
broadcast: {
...state.transaction.broadcast,
testIndexingHash1: {
broadcastedHash: 'testBroadcastedHash',
broadcastSuccessful: true,
isBroadcasting: false,
serializedTransaction: new Buffer([1, 2, 3])
},
testIndexingHash2: {
broadcastedHash: 'testBroadcastedHash',
broadcastSuccessful: true,
isBroadcasting: false,
serializedTransaction: new Buffer([1, 2, 3])
}
},
sign: {
...state.transaction.sign,
indexingHash: 'testIndexingHash1',
pending: false
}
};
it('should check getTransactionState with an indexing hash', () => {
expect(getTransactionStatus(state, 'testIndexingHash1')).toEqual(
state.transaction.broadcast.testIndexingHash1
);
});
it('should check getCurrentTransactionStatus', () => {
expect(getCurrentTransactionStatus(state)).toEqual(
state.transaction.broadcast.testIndexingHash2
);
});
it('should check currentTransactionFailed', () => {
expect(currentTransactionFailed(state)).toEqual(false);
});
it('should check currentTransactionBroadcasting', () => {
expect(currentTransactionBroadcasting(state)).toEqual(false);
});
it('should check currentTransactionBroadcasted', () => {
expect(currentTransactionBroadcasted(state)).toEqual(true);
});
it('should return false on getCurrentTransactionStatus if no index hash present', () => {
state.transaction.sign.indexingHash = null;
expect(getCurrentTransactionStatus(state)).toEqual(false);
});
});