Fix gas-modal-page-container gas price selection call

feature/default_network_editable
Erik Marks 4 years ago
parent 8c6c944d14
commit 406f06dae8
  1. 3
      ui/app/components/app/gas-customization/gas-modal-page-container/gas-modal-page-container.container.js
  2. 123
      ui/app/components/app/gas-customization/gas-modal-page-container/tests/gas-modal-page-container-container.test.js

@ -321,7 +321,8 @@ const mergeProps = (stateProps, dispatchProps, ownProps) => {
}, },
gasPriceButtonGroupProps: { gasPriceButtonGroupProps: {
...gasPriceButtonGroupProps, ...gasPriceButtonGroupProps,
handleGasPriceSelection: otherDispatchProps.updateCustomGasPrice, handleGasPriceSelection: ({ gasPrice }) =>
otherDispatchProps.updateCustomGasPrice(gasPrice),
}, },
cancelAndClose: () => { cancelAndClose: () => {
dispatchCancelAndClose() dispatchCancelAndClose()

@ -274,7 +274,7 @@ describe('gas-modal-page-container container', function () {
let result let result
tests.forEach(({ mockState, mockOwnProps, expectedResult }) => { tests.forEach(({ mockState, mockOwnProps, expectedResult }) => {
result = mapStateToProps(mockState, mockOwnProps) result = mapStateToProps(mockState, mockOwnProps)
assert.deepEqual(result, expectedResult) assert.deepStrictEqual(result, expectedResult)
}) })
}) })
}) })
@ -316,7 +316,7 @@ describe('gas-modal-page-container container', function () {
mapDispatchToPropsObject.updateCustomGasPrice('ffff') mapDispatchToPropsObject.updateCustomGasPrice('ffff')
assert(dispatchSpy.calledOnce) assert(dispatchSpy.calledOnce)
assert(gasActionSpies.setCustomGasPrice.calledOnce) assert(gasActionSpies.setCustomGasPrice.calledOnce)
assert.equal( assert.strictEqual(
gasActionSpies.setCustomGasPrice.getCall(0).args[0], gasActionSpies.setCustomGasPrice.getCall(0).args[0],
'0xffff', '0xffff',
) )
@ -326,7 +326,7 @@ describe('gas-modal-page-container container', function () {
mapDispatchToPropsObject.updateCustomGasPrice('0xffff') mapDispatchToPropsObject.updateCustomGasPrice('0xffff')
assert(dispatchSpy.calledOnce) assert(dispatchSpy.calledOnce)
assert(gasActionSpies.setCustomGasPrice.calledOnce) assert(gasActionSpies.setCustomGasPrice.calledOnce)
assert.equal( assert.strictEqual(
gasActionSpies.setCustomGasPrice.getCall(0).args[0], gasActionSpies.setCustomGasPrice.getCall(0).args[0],
'0xffff', '0xffff',
) )
@ -338,7 +338,7 @@ describe('gas-modal-page-container container', function () {
mapDispatchToPropsObject.updateCustomGasLimit('0x10') mapDispatchToPropsObject.updateCustomGasLimit('0x10')
assert(dispatchSpy.calledOnce) assert(dispatchSpy.calledOnce)
assert(gasActionSpies.setCustomGasLimit.calledOnce) assert(gasActionSpies.setCustomGasLimit.calledOnce)
assert.equal( assert.strictEqual(
gasActionSpies.setCustomGasLimit.getCall(0).args[0], gasActionSpies.setCustomGasLimit.getCall(0).args[0],
'0x10', '0x10',
) )
@ -351,19 +351,19 @@ describe('gas-modal-page-container container', function () {
assert(dispatchSpy.calledTwice) assert(dispatchSpy.calledTwice)
assert(actionSpies.setGasPrice.calledOnce) assert(actionSpies.setGasPrice.calledOnce)
assert(actionSpies.setGasLimit.calledOnce) assert(actionSpies.setGasLimit.calledOnce)
assert.equal(actionSpies.setGasLimit.getCall(0).args[0], 'ffff') assert.strictEqual(actionSpies.setGasLimit.getCall(0).args[0], 'ffff')
assert.equal(actionSpies.setGasPrice.getCall(0).args[0], 'aaaa') assert.strictEqual(actionSpies.setGasPrice.getCall(0).args[0], 'aaaa')
}) })
}) })
describe('updateConfirmTxGasAndCalculate()', function () { describe('updateConfirmTxGasAndCalculate()', function () {
it('should dispatch a updateGasAndCalculate action with the correct props', function () { it('should dispatch a updateGasAndCalculate action with the correct props', function () {
mapDispatchToPropsObject.updateConfirmTxGasAndCalculate('ffff', 'aaaa') mapDispatchToPropsObject.updateConfirmTxGasAndCalculate('ffff', 'aaaa')
assert.equal(dispatchSpy.callCount, 3) assert.strictEqual(dispatchSpy.callCount, 3)
assert(actionSpies.setGasPrice.calledOnce) assert(actionSpies.setGasPrice.calledOnce)
assert(actionSpies.setGasLimit.calledOnce) assert(actionSpies.setGasLimit.calledOnce)
assert.equal(actionSpies.setGasLimit.getCall(0).args[0], 'ffff') assert.strictEqual(actionSpies.setGasLimit.getCall(0).args[0], 'ffff')
assert.equal(actionSpies.setGasPrice.getCall(0).args[0], 'aaaa') assert.strictEqual(actionSpies.setGasPrice.getCall(0).args[0], 'aaaa')
}) })
}) })
}) })
@ -410,37 +410,45 @@ describe('gas-modal-page-container container', function () {
it('should return the expected props when isConfirm is true', function () { it('should return the expected props when isConfirm is true', function () {
const result = mergeProps(stateProps, dispatchProps, ownProps) const result = mergeProps(stateProps, dispatchProps, ownProps)
assert.equal(result.isConfirm, true) assert.strictEqual(result.isConfirm, true)
assert.equal(result.someOtherStateProp, 'baz') assert.strictEqual(result.someOtherStateProp, 'baz')
assert.equal( assert.strictEqual(
result.gasPriceButtonGroupProps.someGasPriceButtonGroupProp, result.gasPriceButtonGroupProps.someGasPriceButtonGroupProp,
'foo', 'foo',
) )
assert.equal( assert.strictEqual(
result.gasPriceButtonGroupProps.anotherGasPriceButtonGroupProp, result.gasPriceButtonGroupProps.anotherGasPriceButtonGroupProp,
'bar', 'bar',
) )
assert.equal(result.someOwnProp, 123) assert.strictEqual(result.someOwnProp, 123)
assert.equal(dispatchProps.updateConfirmTxGasAndCalculate.callCount, 0) assert.strictEqual(
assert.equal(dispatchProps.setGasData.callCount, 0) dispatchProps.updateConfirmTxGasAndCalculate.callCount,
assert.equal(dispatchProps.hideGasButtonGroup.callCount, 0) 0,
assert.equal(dispatchProps.hideModal.callCount, 0) )
assert.strictEqual(dispatchProps.setGasData.callCount, 0)
assert.strictEqual(dispatchProps.hideGasButtonGroup.callCount, 0)
assert.strictEqual(dispatchProps.hideModal.callCount, 0)
result.onSubmit() result.onSubmit()
assert.equal(dispatchProps.updateConfirmTxGasAndCalculate.callCount, 1) assert.strictEqual(
assert.equal(dispatchProps.setGasData.callCount, 0) dispatchProps.updateConfirmTxGasAndCalculate.callCount,
assert.equal(dispatchProps.hideGasButtonGroup.callCount, 0) 1,
assert.equal(dispatchProps.hideModal.callCount, 1) )
assert.strictEqual(dispatchProps.setGasData.callCount, 0)
assert.strictEqual(dispatchProps.hideGasButtonGroup.callCount, 0)
assert.strictEqual(dispatchProps.hideModal.callCount, 1)
assert.equal(dispatchProps.updateCustomGasPrice.callCount, 0) assert.strictEqual(dispatchProps.updateCustomGasPrice.callCount, 0)
result.gasPriceButtonGroupProps.handleGasPriceSelection() result.gasPriceButtonGroupProps.handleGasPriceSelection({
assert.equal(dispatchProps.updateCustomGasPrice.callCount, 1) gasPrice: '0x0',
})
assert.strictEqual(dispatchProps.updateCustomGasPrice.callCount, 1)
assert.equal(dispatchProps.someOtherDispatchProp.callCount, 0) assert.strictEqual(dispatchProps.someOtherDispatchProp.callCount, 0)
result.someOtherDispatchProp() result.someOtherDispatchProp()
assert.equal(dispatchProps.someOtherDispatchProp.callCount, 1) assert.strictEqual(dispatchProps.someOtherDispatchProp.callCount, 1)
}) })
it('should return the expected props when isConfirm is false', function () { it('should return the expected props when isConfirm is false', function () {
@ -450,41 +458,49 @@ describe('gas-modal-page-container container', function () {
ownProps, ownProps,
) )
assert.equal(result.isConfirm, false) assert.strictEqual(result.isConfirm, false)
assert.equal(result.someOtherStateProp, 'baz') assert.strictEqual(result.someOtherStateProp, 'baz')
assert.equal( assert.strictEqual(
result.gasPriceButtonGroupProps.someGasPriceButtonGroupProp, result.gasPriceButtonGroupProps.someGasPriceButtonGroupProp,
'foo', 'foo',
) )
assert.equal( assert.strictEqual(
result.gasPriceButtonGroupProps.anotherGasPriceButtonGroupProp, result.gasPriceButtonGroupProps.anotherGasPriceButtonGroupProp,
'bar', 'bar',
) )
assert.equal(result.someOwnProp, 123) assert.strictEqual(result.someOwnProp, 123)
assert.equal(dispatchProps.updateConfirmTxGasAndCalculate.callCount, 0) assert.strictEqual(
assert.equal(dispatchProps.setGasData.callCount, 0) dispatchProps.updateConfirmTxGasAndCalculate.callCount,
assert.equal(dispatchProps.hideGasButtonGroup.callCount, 0) 0,
assert.equal(dispatchProps.cancelAndClose.callCount, 0) )
assert.strictEqual(dispatchProps.setGasData.callCount, 0)
assert.strictEqual(dispatchProps.hideGasButtonGroup.callCount, 0)
assert.strictEqual(dispatchProps.cancelAndClose.callCount, 0)
result.onSubmit('mockNewLimit', 'mockNewPrice') result.onSubmit('mockNewLimit', 'mockNewPrice')
assert.equal(dispatchProps.updateConfirmTxGasAndCalculate.callCount, 0) assert.strictEqual(
assert.equal(dispatchProps.setGasData.callCount, 1) dispatchProps.updateConfirmTxGasAndCalculate.callCount,
assert.deepEqual(dispatchProps.setGasData.getCall(0).args, [ 0,
)
assert.strictEqual(dispatchProps.setGasData.callCount, 1)
assert.deepStrictEqual(dispatchProps.setGasData.getCall(0).args, [
'mockNewLimit', 'mockNewLimit',
'mockNewPrice', 'mockNewPrice',
]) ])
assert.equal(dispatchProps.hideGasButtonGroup.callCount, 1) assert.strictEqual(dispatchProps.hideGasButtonGroup.callCount, 1)
assert.equal(dispatchProps.cancelAndClose.callCount, 1) assert.strictEqual(dispatchProps.cancelAndClose.callCount, 1)
assert.equal(dispatchProps.updateCustomGasPrice.callCount, 0) assert.strictEqual(dispatchProps.updateCustomGasPrice.callCount, 0)
result.gasPriceButtonGroupProps.handleGasPriceSelection() result.gasPriceButtonGroupProps.handleGasPriceSelection({
assert.equal(dispatchProps.updateCustomGasPrice.callCount, 1) gasPrice: '0x0',
})
assert.strictEqual(dispatchProps.updateCustomGasPrice.callCount, 1)
assert.equal(dispatchProps.someOtherDispatchProp.callCount, 0) assert.strictEqual(dispatchProps.someOtherDispatchProp.callCount, 0)
result.someOtherDispatchProp() result.someOtherDispatchProp()
assert.equal(dispatchProps.someOtherDispatchProp.callCount, 1) assert.strictEqual(dispatchProps.someOtherDispatchProp.callCount, 1)
}) })
it('should dispatch the expected actions from obSubmit when isConfirm is false and isSpeedUp is true', function () { it('should dispatch the expected actions from obSubmit when isConfirm is false and isSpeedUp is true', function () {
@ -496,13 +512,16 @@ describe('gas-modal-page-container container', function () {
result.onSubmit() result.onSubmit()
assert.equal(dispatchProps.updateConfirmTxGasAndCalculate.callCount, 0) assert.strictEqual(
assert.equal(dispatchProps.setGasData.callCount, 0) dispatchProps.updateConfirmTxGasAndCalculate.callCount,
assert.equal(dispatchProps.hideGasButtonGroup.callCount, 0) 0,
assert.equal(dispatchProps.cancelAndClose.callCount, 1) )
assert.strictEqual(dispatchProps.setGasData.callCount, 0)
assert.strictEqual(dispatchProps.hideGasButtonGroup.callCount, 0)
assert.strictEqual(dispatchProps.cancelAndClose.callCount, 1)
assert.equal(dispatchProps.createSpeedUpTransaction.callCount, 1) assert.strictEqual(dispatchProps.createSpeedUpTransaction.callCount, 1)
assert.equal(dispatchProps.hideSidebar.callCount, 1) assert.strictEqual(dispatchProps.hideSidebar.callCount, 1)
}) })
}) })
}) })

Loading…
Cancel
Save