Skip to content

Commit

Permalink
Improve send slice tests (#11091)
Browse files Browse the repository at this point in the history
* Improve send slice tests
  • Loading branch information
tmashuang authored and brad-decker committed Jun 7, 2021
1 parent 9cc49b5 commit fbf0c6e
Show file tree
Hide file tree
Showing 8 changed files with 1,468 additions and 428 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
useAdvancedGasEstimation,
updateGasLimit,
updateGasPrice,
ASSET_TYPES,
} from '../../../../ducks/send';

let mapDispatchToProps;
Expand Down Expand Up @@ -60,7 +59,7 @@ jest.mock('../../../../ducks/send', () => ({
useAdvancedGasEstimation: jest.fn(),
updateGasLimit: jest.fn(),
updateGasPrice: jest.fn(),
getSendAsset: jest.fn(() => ({ type: ASSET_TYPES.NATIVE })),
getSendAsset: jest.fn(() => ({ type: 'NATIVE' })),
}));

require('./gas-modal-page-container.container');
Expand Down Expand Up @@ -251,7 +250,7 @@ describe('gas-modal-page-container container', () => {
'mockNewLimit',
'mockNewPrice',
]);
expect(dispatchProps.useAdvancedGasEstimation.callCount).toStrictEqual(0);
expect(dispatchProps.useAdvancedGasEstimation.callCount).toStrictEqual(1);
expect(dispatchProps.cancelAndClose.callCount).toStrictEqual(1);

expect(dispatchProps.updateCustomGasPrice.callCount).toStrictEqual(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ const mergeProps = (stateProps, dispatchProps, ownProps) => {
transaction,
} = stateProps;
const {
useAdvancedGasEstimation: dispatchUseAdvancedGasEstimation,
setGasData: dispatchSetGasData,
updateConfirmTxGasAndCalculate: dispatchUpdateConfirmTxGasAndCalculate,
createSpeedUpTransaction: dispatchCreateSpeedUpTransaction,
Expand Down Expand Up @@ -272,7 +273,7 @@ const mergeProps = (stateProps, dispatchProps, ownProps) => {
dispatchCancelAndClose();
} else {
dispatchSetGasData(gasLimit, gasPrice);
dispatchProps.useAdvancedGasEstimation();
dispatchUseAdvancedGasEstimation();
dispatchCancelAndClose();
}
},
Expand Down
2 changes: 0 additions & 2 deletions ui/ducks/metamask/metamask.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,11 @@ describe('MetaMask Reducers', () => {
{},
{
type: actionConstants.SHOW_ACCOUNT_DETAIL,
value: 'test address',
},
);

expect(state.isUnlocked).toStrictEqual(true);
expect(state.isInitialized).toStrictEqual(true);
expect(state.selectedAddress).toStrictEqual('test address');
});

it('sets account label', () => {
Expand Down
7 changes: 3 additions & 4 deletions ui/ducks/send/send.js
Original file line number Diff line number Diff line change
Expand Up @@ -938,10 +938,9 @@ const slice = createSlice({
// the gasPrice in our slice. We call into the caseReducer
// updateGasPrice to also tap into the appropriate follow up checks
// and gasTotal calculation.
slice.caseReducers.updateGasPrice(
state,
getGasPriceInHexWei(action.value.average ?? '0x0'),
);
slice.caseReducers.updateGasPrice(state, {
payload: getGasPriceInHexWei(action.value.average ?? '0x0'),
});
})
.addCase(BASIC_GAS_ESTIMATE_STATUS, (state, action) => {
// When we fetch gas prices we should temporarily set the form invalid
Expand Down
Loading

0 comments on commit fbf0c6e

Please sign in to comment.