Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve send slice tests #11091

Merged
merged 4 commits into from
May 25, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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