diff options
author | Dan Miller <danjm.com@gmail.com> | 2018-10-26 13:50:36 +0800 |
---|---|---|
committer | Dan Miller <danjm.com@gmail.com> | 2018-12-04 11:36:22 +0800 |
commit | e3f015c88f30fb4243ebbb3d2f109be8f3d68196 (patch) | |
tree | 62f96055f085624acf1a5fe91365f207daee2f0a /ui/app/components/gas-customization/gas-modal-page-container/tests | |
parent | 9b9a2cc2e00618167d5fac8103e928fc16153b2d (diff) | |
download | tangerine-wallet-browser-e3f015c88f30fb4243ebbb3d2f109be8f3d68196.tar.gz tangerine-wallet-browser-e3f015c88f30fb4243ebbb3d2f109be8f3d68196.tar.zst tangerine-wallet-browser-e3f015c88f30fb4243ebbb3d2f109be8f3d68196.zip |
Adds speed up slide-in gas customization sidebar
Diffstat (limited to 'ui/app/components/gas-customization/gas-modal-page-container/tests')
2 files changed, 60 insertions, 7 deletions
diff --git a/ui/app/components/gas-customization/gas-modal-page-container/tests/gas-modal-page-container-component.test.js b/ui/app/components/gas-customization/gas-modal-page-container/tests/gas-modal-page-container-component.test.js index 61871f5f3..16f4b8cd7 100644 --- a/ui/app/components/gas-customization/gas-modal-page-container/tests/gas-modal-page-container-component.test.js +++ b/ui/app/components/gas-customization/gas-modal-page-container/tests/gas-modal-page-container-component.test.js @@ -68,6 +68,7 @@ describe('GasModalPageContainer Component', function () { currentTimeEstimate={'1 min 31 sec'} customGasPriceInHex={'mockCustomGasPriceInHex'} customGasLimitInHex={'mockCustomGasLimitInHex'} + insufficientBalance={false} />, { context: { t: (str1, str2) => str2 ? str1 + str2 : str1 } }) }) diff --git a/ui/app/components/gas-customization/gas-modal-page-container/tests/gas-modal-page-container-container.test.js b/ui/app/components/gas-customization/gas-modal-page-container/tests/gas-modal-page-container-container.test.js index 54fbfb66c..1ed28f33e 100644 --- a/ui/app/components/gas-customization/gas-modal-page-container/tests/gas-modal-page-container-container.test.js +++ b/ui/app/components/gas-customization/gas-modal-page-container/tests/gas-modal-page-container-container.test.js @@ -44,14 +44,16 @@ proxyquire('../gas-modal-page-container.container.js', { '../../../ducks/gas.duck': gasActionSpies, '../../../ducks/confirm-transaction.duck': confirmTransactionActionSpies, '../../../ducks/send.duck': sendActionSpies, + '../../../selectors.js': { + getCurrentEthBalance: (state) => state.metamask.balance || '0x0', + }, }) describe('gas-modal-page-container container', () => { describe('mapStateToProps()', () => { - it('should map the correct properties to props', () => { - const mockState2 = { + const baseMockState = { appState: { modal: { modalState: { @@ -92,9 +94,7 @@ describe('gas-modal-page-container container', () => { }, }, } - const result2 = mapStateToProps(mockState2) - - assert.deepEqual(result2, { + const baseExpectedResult = { isConfirm: true, customGasPrice: 4.294967295, customGasLimit: 2863311530, @@ -116,13 +116,40 @@ describe('gas-modal-page-container container', () => { }, hideBasic: true, infoRowProps: { - originalTotalFiat: '22.58', - originalTotalEth: '0.451569 ETH', + originalTotalFiat: '637.41', + originalTotalEth: '12.748189 ETH', newTotalFiat: '637.41', newTotalEth: '12.748189 ETH', sendAmount: '0.45036 ETH', transactionFee: '12.297829 ETH', }, + insufficientBalance: true, + isSpeedUp: false, + txId: 34, + } + const baseMockOwnProps = { transaction: { id: 34 } } + const tests = [ + { mockState: baseMockState, expectedResult: baseExpectedResult, mockOwnProps: baseMockOwnProps }, + { + mockState: Object.assign({}, baseMockState, { + metamask: { ...baseMockState.metamask, balance: '0xfffffffffffffffffffff' }, + }), + expectedResult: Object.assign({}, baseExpectedResult, { insufficientBalance: false }), + mockOwnProps: baseMockOwnProps, + }, + { + mockState: baseMockState, + mockOwnProps: Object.assign({}, baseMockOwnProps, { + transaction: { id: 34, status: 'submitted' }, + }), + expectedResult: Object.assign({}, baseExpectedResult, { isSpeedUp: true }), + }, + ] + + let result + tests.forEach(({ mockState, mockOwnProps, expectedResult}) => { + result = mapStateToProps(mockState, mockOwnProps) + assert.deepEqual(result, expectedResult) }) }) @@ -230,9 +257,21 @@ describe('gas-modal-page-container container', () => { setGasData: sinon.spy(), updateConfirmTxGasAndCalculate: sinon.spy(), someOtherDispatchProp: sinon.spy(), + createSpeedUpTransaction: sinon.spy(), + hideSidebar: sinon.spy(), } ownProps = { someOwnProp: 123 } }) + + afterEach(() => { + dispatchProps.updateCustomGasPrice.resetHistory() + dispatchProps.hideGasButtonGroup.resetHistory() + dispatchProps.setGasData.resetHistory() + dispatchProps.updateConfirmTxGasAndCalculate.resetHistory() + dispatchProps.someOtherDispatchProp.resetHistory() + dispatchProps.createSpeedUpTransaction.resetHistory() + dispatchProps.hideSidebar.resetHistory() + }) it('should return the expected props when isConfirm is true', () => { const result = mergeProps(stateProps, dispatchProps, ownProps) @@ -289,6 +328,19 @@ describe('gas-modal-page-container container', () => { result.someOtherDispatchProp() assert.equal(dispatchProps.someOtherDispatchProp.callCount, 1) }) + + it('should dispatch the expected actions from obSubmit when isConfirm is false and isSpeedUp is true', () => { + const result = mergeProps(Object.assign({}, stateProps, { isSpeedUp: true, isConfirm: false }), dispatchProps, ownProps) + + result.onSubmit() + + assert.equal(dispatchProps.updateConfirmTxGasAndCalculate.callCount, 0) + assert.equal(dispatchProps.setGasData.callCount, 0) + assert.equal(dispatchProps.hideGasButtonGroup.callCount, 0) + + assert.equal(dispatchProps.createSpeedUpTransaction.callCount, 1) + assert.equal(dispatchProps.hideSidebar.callCount, 1) + }) }) }) |