mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Fix handleGasPriceSelection function parameters (#9865)
* Fix related unit tests
This commit is contained in:
commit
ed27c359c6
@ -32,7 +32,8 @@ const mockGasPriceButtonGroupProps = {
|
|||||||
gasEstimateType: GAS_ESTIMATE_TYPES.AVERAGE,
|
gasEstimateType: GAS_ESTIMATE_TYPES.AVERAGE,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
handleGasPriceSelection: (newPrice) => console.log('NewPrice: ', newPrice),
|
handleGasPriceSelection: ({ gasPrice }) =>
|
||||||
|
console.log('NewPrice: ', gasPrice),
|
||||||
noButtonActiveByDefault: true,
|
noButtonActiveByDefault: true,
|
||||||
showCheck: true,
|
showCheck: true,
|
||||||
}
|
}
|
||||||
|
@ -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)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -94,10 +94,10 @@ export default class GasPriceButtonGroup extends Component {
|
|||||||
return (
|
return (
|
||||||
<Button
|
<Button
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
handleGasPriceSelection(
|
handleGasPriceSelection({
|
||||||
priceInHexWei,
|
gasPrice: priceInHexWei,
|
||||||
renderableGasInfo.gasEstimateType,
|
gasEstimateType: renderableGasInfo.gasEstimateType,
|
||||||
)
|
})
|
||||||
}
|
}
|
||||||
key={`gas-price-button-${index}`}
|
key={`gas-price-button-${index}`}
|
||||||
>
|
>
|
||||||
|
@ -73,13 +73,13 @@ describe('GasPriceButtonGroup Component', function () {
|
|||||||
defaultActiveButtonIndex,
|
defaultActiveButtonIndex,
|
||||||
noButtonActiveByDefault,
|
noButtonActiveByDefault,
|
||||||
} = wrapper.props()
|
} = wrapper.props()
|
||||||
assert.equal(className, 'gas-price-button-group')
|
assert.strictEqual(className, 'gas-price-button-group')
|
||||||
assert.equal(defaultActiveButtonIndex, 2)
|
assert.strictEqual(defaultActiveButtonIndex, 2)
|
||||||
assert.equal(noButtonActiveByDefault, true)
|
assert.strictEqual(noButtonActiveByDefault, true)
|
||||||
})
|
})
|
||||||
|
|
||||||
function renderButtonArgsTest(i, mockPropsAndFlags) {
|
function renderButtonArgsTest(i, mockPropsAndFlags) {
|
||||||
assert.deepEqual(
|
assert.deepStrictEqual(
|
||||||
GasPriceButtonGroup.prototype.renderButton.getCall(i).args,
|
GasPriceButtonGroup.prototype.renderButton.getCall(i).args,
|
||||||
[
|
[
|
||||||
{ ...mockGasPriceButtonGroupProps.gasButtonInfo[i] },
|
{ ...mockGasPriceButtonGroupProps.gasButtonInfo[i] },
|
||||||
@ -90,7 +90,10 @@ describe('GasPriceButtonGroup Component', function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
it('should call this.renderButton 3 times, with the correct args', function () {
|
it('should call this.renderButton 3 times, with the correct args', function () {
|
||||||
assert.equal(GasPriceButtonGroup.prototype.renderButton.callCount, 3)
|
assert.strictEqual(
|
||||||
|
GasPriceButtonGroup.prototype.renderButton.callCount,
|
||||||
|
3,
|
||||||
|
)
|
||||||
renderButtonArgsTest(0, mockButtonPropsAndFlags)
|
renderButtonArgsTest(0, mockButtonPropsAndFlags)
|
||||||
renderButtonArgsTest(1, mockButtonPropsAndFlags)
|
renderButtonArgsTest(1, mockButtonPropsAndFlags)
|
||||||
renderButtonArgsTest(2, mockButtonPropsAndFlags)
|
renderButtonArgsTest(2, mockButtonPropsAndFlags)
|
||||||
@ -100,7 +103,7 @@ describe('GasPriceButtonGroup Component', function () {
|
|||||||
wrapper.setProps({ buttonDataLoading: true })
|
wrapper.setProps({ buttonDataLoading: true })
|
||||||
assert(wrapper.is('div'))
|
assert(wrapper.is('div'))
|
||||||
assert(wrapper.hasClass('gas-price-button-group__loading-container'))
|
assert(wrapper.hasClass('gas-price-button-group__loading-container'))
|
||||||
assert.equal(wrapper.text(), 'loading')
|
assert.strictEqual(wrapper.text(), 'loading')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -119,30 +122,34 @@ describe('GasPriceButtonGroup Component', function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should render a button', function () {
|
it('should render a button', function () {
|
||||||
assert.equal(wrappedRenderButtonResult.type(), 'button')
|
assert.strictEqual(wrappedRenderButtonResult.type(), 'button')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should call the correct method when clicked', function () {
|
it('should call the correct method when clicked', function () {
|
||||||
assert.equal(
|
assert.strictEqual(
|
||||||
mockGasPriceButtonGroupProps.handleGasPriceSelection.callCount,
|
mockGasPriceButtonGroupProps.handleGasPriceSelection.callCount,
|
||||||
0,
|
0,
|
||||||
)
|
)
|
||||||
wrappedRenderButtonResult.props().onClick()
|
wrappedRenderButtonResult.props().onClick()
|
||||||
assert.equal(
|
assert.strictEqual(
|
||||||
mockGasPriceButtonGroupProps.handleGasPriceSelection.callCount,
|
mockGasPriceButtonGroupProps.handleGasPriceSelection.callCount,
|
||||||
1,
|
1,
|
||||||
)
|
)
|
||||||
assert.deepEqual(
|
assert.deepStrictEqual(
|
||||||
mockGasPriceButtonGroupProps.handleGasPriceSelection.getCall(0).args,
|
mockGasPriceButtonGroupProps.handleGasPriceSelection.getCall(0).args,
|
||||||
[
|
[
|
||||||
mockGasPriceButtonGroupProps.gasButtonInfo[0].priceInHexWei,
|
{
|
||||||
mockGasPriceButtonGroupProps.gasButtonInfo[0].gasEstimateType,
|
gasPrice:
|
||||||
|
mockGasPriceButtonGroupProps.gasButtonInfo[0].priceInHexWei,
|
||||||
|
gasEstimateType:
|
||||||
|
mockGasPriceButtonGroupProps.gasButtonInfo[0].gasEstimateType,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should call this.renderButtonContent with the correct args', function () {
|
it('should call this.renderButtonContent with the correct args', function () {
|
||||||
assert.equal(
|
assert.strictEqual(
|
||||||
GasPriceButtonGroup.prototype.renderButtonContent.callCount,
|
GasPriceButtonGroup.prototype.renderButtonContent.callCount,
|
||||||
1,
|
1,
|
||||||
)
|
)
|
||||||
@ -153,7 +160,7 @@ describe('GasPriceButtonGroup Component', function () {
|
|||||||
gasEstimateType,
|
gasEstimateType,
|
||||||
} = mockGasPriceButtonGroupProps.gasButtonInfo[0]
|
} = mockGasPriceButtonGroupProps.gasButtonInfo[0]
|
||||||
const { showCheck, className } = mockGasPriceButtonGroupProps
|
const { showCheck, className } = mockGasPriceButtonGroupProps
|
||||||
assert.deepEqual(
|
assert.deepStrictEqual(
|
||||||
GasPriceButtonGroup.prototype.renderButtonContent.getCall(0).args,
|
GasPriceButtonGroup.prototype.renderButtonContent.getCall(0).args,
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
@ -184,11 +191,11 @@ describe('GasPriceButtonGroup Component', function () {
|
|||||||
const wrappedRenderButtonContentResult = shallow(
|
const wrappedRenderButtonContentResult = shallow(
|
||||||
renderButtonContentResult,
|
renderButtonContentResult,
|
||||||
)
|
)
|
||||||
assert.equal(
|
assert.strictEqual(
|
||||||
wrappedRenderButtonContentResult.childAt(0).children().length,
|
wrappedRenderButtonContentResult.childAt(0).children().length,
|
||||||
1,
|
1,
|
||||||
)
|
)
|
||||||
assert.equal(
|
assert.strictEqual(
|
||||||
wrappedRenderButtonContentResult.find('.someClass__label').text(),
|
wrappedRenderButtonContentResult.find('.someClass__label').text(),
|
||||||
'slow',
|
'slow',
|
||||||
)
|
)
|
||||||
@ -206,11 +213,11 @@ describe('GasPriceButtonGroup Component', function () {
|
|||||||
const wrappedRenderButtonContentResult = shallow(
|
const wrappedRenderButtonContentResult = shallow(
|
||||||
renderButtonContentResult,
|
renderButtonContentResult,
|
||||||
)
|
)
|
||||||
assert.equal(
|
assert.strictEqual(
|
||||||
wrappedRenderButtonContentResult.childAt(0).children().length,
|
wrappedRenderButtonContentResult.childAt(0).children().length,
|
||||||
1,
|
1,
|
||||||
)
|
)
|
||||||
assert.equal(
|
assert.strictEqual(
|
||||||
wrappedRenderButtonContentResult
|
wrappedRenderButtonContentResult
|
||||||
.find('.someClass__primary-currency')
|
.find('.someClass__primary-currency')
|
||||||
.text(),
|
.text(),
|
||||||
@ -230,11 +237,11 @@ describe('GasPriceButtonGroup Component', function () {
|
|||||||
const wrappedRenderButtonContentResult = shallow(
|
const wrappedRenderButtonContentResult = shallow(
|
||||||
renderButtonContentResult,
|
renderButtonContentResult,
|
||||||
)
|
)
|
||||||
assert.equal(
|
assert.strictEqual(
|
||||||
wrappedRenderButtonContentResult.childAt(0).children().length,
|
wrappedRenderButtonContentResult.childAt(0).children().length,
|
||||||
1,
|
1,
|
||||||
)
|
)
|
||||||
assert.equal(
|
assert.strictEqual(
|
||||||
wrappedRenderButtonContentResult
|
wrappedRenderButtonContentResult
|
||||||
.find('.someClass__secondary-currency')
|
.find('.someClass__secondary-currency')
|
||||||
.text(),
|
.text(),
|
||||||
@ -254,11 +261,11 @@ describe('GasPriceButtonGroup Component', function () {
|
|||||||
const wrappedRenderButtonContentResult = shallow(
|
const wrappedRenderButtonContentResult = shallow(
|
||||||
renderButtonContentResult,
|
renderButtonContentResult,
|
||||||
)
|
)
|
||||||
assert.equal(
|
assert.strictEqual(
|
||||||
wrappedRenderButtonContentResult.childAt(0).children().length,
|
wrappedRenderButtonContentResult.childAt(0).children().length,
|
||||||
1,
|
1,
|
||||||
)
|
)
|
||||||
assert.equal(
|
assert.strictEqual(
|
||||||
wrappedRenderButtonContentResult
|
wrappedRenderButtonContentResult
|
||||||
.find('.someClass__time-estimate')
|
.find('.someClass__time-estimate')
|
||||||
.text(),
|
.text(),
|
||||||
@ -277,7 +284,10 @@ describe('GasPriceButtonGroup Component', function () {
|
|||||||
const wrappedRenderButtonContentResult = shallow(
|
const wrappedRenderButtonContentResult = shallow(
|
||||||
renderButtonContentResult,
|
renderButtonContentResult,
|
||||||
)
|
)
|
||||||
assert.equal(wrappedRenderButtonContentResult.find('.fa-check').length, 1)
|
assert.strictEqual(
|
||||||
|
wrappedRenderButtonContentResult.find('.fa-check').length,
|
||||||
|
1,
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render all elements if all args passed', function () {
|
it('should render all elements if all args passed', function () {
|
||||||
@ -296,7 +306,7 @@ describe('GasPriceButtonGroup Component', function () {
|
|||||||
const wrappedRenderButtonContentResult = shallow(
|
const wrappedRenderButtonContentResult = shallow(
|
||||||
renderButtonContentResult,
|
renderButtonContentResult,
|
||||||
)
|
)
|
||||||
assert.equal(wrappedRenderButtonContentResult.children().length, 5)
|
assert.strictEqual(wrappedRenderButtonContentResult.children().length, 5)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render no elements if all args passed', function () {
|
it('should render no elements if all args passed', function () {
|
||||||
@ -307,7 +317,7 @@ describe('GasPriceButtonGroup Component', function () {
|
|||||||
const wrappedRenderButtonContentResult = shallow(
|
const wrappedRenderButtonContentResult = shallow(
|
||||||
renderButtonContentResult,
|
renderButtonContentResult,
|
||||||
)
|
)
|
||||||
assert.equal(wrappedRenderButtonContentResult.children().length, 0)
|
assert.strictEqual(wrappedRenderButtonContentResult.children().length, 0)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -101,7 +101,7 @@ export default class SendGasRow extends Component {
|
|||||||
className="gas-price-button-group--small"
|
className="gas-price-button-group--small"
|
||||||
showCheck={false}
|
showCheck={false}
|
||||||
{...gasPriceButtonGroupProps}
|
{...gasPriceButtonGroupProps}
|
||||||
handleGasPriceSelection={async (...args) => {
|
handleGasPriceSelection={async (opts) => {
|
||||||
metricsEvent({
|
metricsEvent({
|
||||||
eventOpts: {
|
eventOpts: {
|
||||||
category: 'Transactions',
|
category: 'Transactions',
|
||||||
@ -109,7 +109,7 @@ export default class SendGasRow extends Component {
|
|||||||
name: 'Changed Gas Button',
|
name: 'Changed Gas Button',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
await gasPriceButtonGroupProps.handleGasPriceSelection(...args)
|
await gasPriceButtonGroupProps.handleGasPriceSelection(opts)
|
||||||
if (maxModeOn) {
|
if (maxModeOn) {
|
||||||
this.setMaxAmount()
|
this.setMaxAmount()
|
||||||
}
|
}
|
||||||
@ -134,7 +134,7 @@ export default class SendGasRow extends Component {
|
|||||||
<div>
|
<div>
|
||||||
<AdvancedGasInputs
|
<AdvancedGasInputs
|
||||||
updateCustomGasPrice={(newGasPrice) =>
|
updateCustomGasPrice={(newGasPrice) =>
|
||||||
setGasPrice(newGasPrice, gasLimit)
|
setGasPrice({ gasPrice: newGasPrice, gasLimit })
|
||||||
}
|
}
|
||||||
updateCustomGasLimit={(newGasLimit) =>
|
updateCustomGasLimit={(newGasLimit) =>
|
||||||
setGasLimit(newGasLimit, gasPrice)
|
setGasLimit(newGasLimit, gasPrice)
|
||||||
|
@ -89,11 +89,11 @@ function mapDispatchToProps(dispatch) {
|
|||||||
return {
|
return {
|
||||||
showCustomizeGasModal: () =>
|
showCustomizeGasModal: () =>
|
||||||
dispatch(showModal({ name: 'CUSTOMIZE_GAS', hideBasic: true })),
|
dispatch(showModal({ name: 'CUSTOMIZE_GAS', hideBasic: true })),
|
||||||
setGasPrice: (newPrice, gasLimit) => {
|
setGasPrice: ({ gasPrice, gasLimit }) => {
|
||||||
dispatch(setGasPrice(newPrice))
|
dispatch(setGasPrice(gasPrice))
|
||||||
dispatch(setCustomGasPrice(newPrice))
|
dispatch(setCustomGasPrice(gasPrice))
|
||||||
if (gasLimit) {
|
if (gasLimit) {
|
||||||
dispatch(setGasTotal(calcGasTotal(gasLimit, newPrice)))
|
dispatch(setGasTotal(calcGasTotal(gasLimit, gasPrice)))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setGasLimit: (newLimit, gasPrice) => {
|
setGasLimit: (newLimit, gasPrice) => {
|
||||||
|
@ -58,7 +58,7 @@ describe('send-gas-row container', function () {
|
|||||||
it('should dispatch an action', function () {
|
it('should dispatch an action', function () {
|
||||||
mapDispatchToPropsObject.showCustomizeGasModal()
|
mapDispatchToPropsObject.showCustomizeGasModal()
|
||||||
assert(dispatchSpy.calledOnce)
|
assert(dispatchSpy.calledOnce)
|
||||||
assert.deepEqual(actionSpies.showModal.getCall(0).args[0], {
|
assert.deepStrictEqual(actionSpies.showModal.getCall(0).args[0], {
|
||||||
name: 'CUSTOMIZE_GAS',
|
name: 'CUSTOMIZE_GAS',
|
||||||
hideBasic: true,
|
hideBasic: true,
|
||||||
})
|
})
|
||||||
@ -67,16 +67,22 @@ describe('send-gas-row container', function () {
|
|||||||
|
|
||||||
describe('setGasPrice()', function () {
|
describe('setGasPrice()', function () {
|
||||||
it('should dispatch an action', function () {
|
it('should dispatch an action', function () {
|
||||||
mapDispatchToPropsObject.setGasPrice('mockNewPrice', 'mockLimit')
|
mapDispatchToPropsObject.setGasPrice({
|
||||||
|
gasPrice: 'mockNewPrice',
|
||||||
|
gasLimit: 'mockLimit',
|
||||||
|
})
|
||||||
assert(dispatchSpy.calledThrice)
|
assert(dispatchSpy.calledThrice)
|
||||||
assert(actionSpies.setGasPrice.calledOnce)
|
assert(actionSpies.setGasPrice.calledOnce)
|
||||||
assert.equal(actionSpies.setGasPrice.getCall(0).args[0], 'mockNewPrice')
|
assert.strictEqual(
|
||||||
assert.equal(
|
actionSpies.setGasPrice.getCall(0).args[0],
|
||||||
|
'mockNewPrice',
|
||||||
|
)
|
||||||
|
assert.strictEqual(
|
||||||
gasDuckSpies.setCustomGasPrice.getCall(0).args[0],
|
gasDuckSpies.setCustomGasPrice.getCall(0).args[0],
|
||||||
'mockNewPrice',
|
'mockNewPrice',
|
||||||
)
|
)
|
||||||
assert(actionSpies.setGasTotal.calledOnce)
|
assert(actionSpies.setGasTotal.calledOnce)
|
||||||
assert.equal(
|
assert.strictEqual(
|
||||||
actionSpies.setGasTotal.getCall(0).args[0],
|
actionSpies.setGasTotal.getCall(0).args[0],
|
||||||
'mockLimitmockNewPrice',
|
'mockLimitmockNewPrice',
|
||||||
)
|
)
|
||||||
@ -88,13 +94,16 @@ describe('send-gas-row container', function () {
|
|||||||
mapDispatchToPropsObject.setGasLimit('mockNewLimit', 'mockPrice')
|
mapDispatchToPropsObject.setGasLimit('mockNewLimit', 'mockPrice')
|
||||||
assert(dispatchSpy.calledThrice)
|
assert(dispatchSpy.calledThrice)
|
||||||
assert(actionSpies.setGasLimit.calledOnce)
|
assert(actionSpies.setGasLimit.calledOnce)
|
||||||
assert.equal(actionSpies.setGasLimit.getCall(0).args[0], 'mockNewLimit')
|
assert.strictEqual(
|
||||||
assert.equal(
|
actionSpies.setGasLimit.getCall(0).args[0],
|
||||||
|
'mockNewLimit',
|
||||||
|
)
|
||||||
|
assert.strictEqual(
|
||||||
gasDuckSpies.setCustomGasLimit.getCall(0).args[0],
|
gasDuckSpies.setCustomGasLimit.getCall(0).args[0],
|
||||||
'mockNewLimit',
|
'mockNewLimit',
|
||||||
)
|
)
|
||||||
assert(actionSpies.setGasTotal.calledOnce)
|
assert(actionSpies.setGasTotal.calledOnce)
|
||||||
assert.equal(
|
assert.strictEqual(
|
||||||
actionSpies.setGasTotal.getCall(0).args[0],
|
actionSpies.setGasTotal.getCall(0).args[0],
|
||||||
'mockNewLimitmockPrice',
|
'mockNewLimitmockPrice',
|
||||||
)
|
)
|
||||||
@ -134,24 +143,24 @@ describe('send-gas-row container', function () {
|
|||||||
const ownProps = { someOwnProp: 123 }
|
const ownProps = { someOwnProp: 123 }
|
||||||
const result = mergeProps(stateProps, dispatchProps, ownProps)
|
const result = mergeProps(stateProps, dispatchProps, ownProps)
|
||||||
|
|
||||||
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.setGasPrice.callCount, 0)
|
assert.strictEqual(dispatchProps.setGasPrice.callCount, 0)
|
||||||
result.gasPriceButtonGroupProps.handleGasPriceSelection()
|
result.gasPriceButtonGroupProps.handleGasPriceSelection()
|
||||||
assert.equal(dispatchProps.setGasPrice.callCount, 1)
|
assert.strictEqual(dispatchProps.setGasPrice.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)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -61,9 +61,9 @@ export default class GasModalPageContainer extends Component {
|
|||||||
<BasicTabContent
|
<BasicTabContent
|
||||||
gasPriceButtonGroupProps={{
|
gasPriceButtonGroupProps={{
|
||||||
...gasPriceButtonGroupProps,
|
...gasPriceButtonGroupProps,
|
||||||
handleGasPriceSelection: (gasPriceInHexWei, gasEstimateType) => {
|
handleGasPriceSelection: ({ gasPrice, gasEstimateType }) => {
|
||||||
this.setGasSpeedType(gasEstimateType)
|
this.setGasSpeedType(gasEstimateType)
|
||||||
this.props.setSwapsCustomizationModalPrice(gasPriceInHexWei)
|
this.props.setSwapsCustomizationModalPrice(gasPrice)
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
Loading…
Reference in New Issue
Block a user