mirror of
https://github.com/status-im/MyCrypto.git
synced 2025-01-26 19:09:11 +00:00
cf9887f21f
* 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.
57 lines
1.6 KiB
TypeScript
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
|
|
);
|
|
});
|
|
});
|