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

57 lines
1.6 KiB
TypeScript

import { INITIAL_STATE } from 'reducers/transaction';
import { broadcast, ITransactionStatus } from 'reducers/transaction/broadcast';
import * as txActions from 'actions/transaction';
const indexingHash = 'testingHash';
describe('broadcast reducer', () => {
const serializedTransaction = new Buffer('testSerialized');
const nextTxStatus: ITransactionStatus = {
broadcastedHash: null,
broadcastSuccessful: false,
isBroadcasting: true,
serializedTransaction
};
const nextState: any = {
...INITIAL_STATE,
[indexingHash]: nextTxStatus
};
it('should handle BROADCAST_TRANSACTION_QUEUED', () => {
expect(
broadcast(
INITIAL_STATE as any,
txActions.broadcastTransactionQueued({ indexingHash, serializedTransaction })
)
).toEqual(nextState);
});
it('should handle BROADCAST_TRANSACTION_SUCCESS', () => {
const broadcastedHash = 'testBroadcastHash';
const broadcastedState = {
...nextState,
[indexingHash]: {
...nextTxStatus,
broadcastedHash,
isBroadcasting: false,
broadcastSuccessful: true
}
};
expect(
broadcast(
nextState,
txActions.broadcastTransactionSucceeded({ indexingHash, broadcastedHash })
)
).toEqual(broadcastedState);
});
it('should handle BROADCAST_TRANSACTION_FAILURE', () => {
const failedBroadcastState = {
...nextState,
[indexingHash]: { ...nextTxStatus, isBroadcasting: false, broadcastSuccessful: false }
};
expect(broadcast(nextState, txActions.broadcastTransactionFailed({ indexingHash }))).toEqual(
failedBroadcastState
);
});
});