mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-12 04:37:13 +01:00
72 lines
2.0 KiB
JavaScript
72 lines
2.0 KiB
JavaScript
import sinon from 'sinon';
|
|
|
|
import {
|
|
setCustomGasPrice,
|
|
setCustomGasLimit,
|
|
} from '../../../../ducks/gas/gas.duck';
|
|
|
|
import { updateGasPrice, updateGasLimit } from '../../../../ducks/send';
|
|
|
|
let mapDispatchToProps;
|
|
|
|
jest.mock('react-redux', () => ({
|
|
connect: (_, md) => {
|
|
mapDispatchToProps = md;
|
|
return () => ({});
|
|
},
|
|
}));
|
|
|
|
jest.mock('../../../../ducks/send', () => {
|
|
const original = jest.requireActual('../../../../ducks/send');
|
|
return {
|
|
...original,
|
|
getSendMaxModeState: (s) => `mockMaxModeOn:${s}`,
|
|
updateGasPrice: jest.fn(),
|
|
updateGasLimit: jest.fn(),
|
|
};
|
|
});
|
|
|
|
jest.mock('../../../../ducks/gas/gas.duck', () => ({
|
|
setCustomGasPrice: jest.fn(),
|
|
setCustomGasLimit: jest.fn(),
|
|
}));
|
|
|
|
jest.mock('../../send.utils.js', () => ({
|
|
isBalanceSufficient: ({ amount, gasTotal, balance, conversionRate }) =>
|
|
`${amount}:${gasTotal}:${balance}:${conversionRate}`,
|
|
|
|
calcGasTotal: (gasLimit, gasPrice) => gasLimit + gasPrice,
|
|
}));
|
|
|
|
require('./send-gas-row.container');
|
|
|
|
describe('send-gas-row container', () => {
|
|
describe('mapDispatchToProps()', () => {
|
|
let dispatchSpy;
|
|
let mapDispatchToPropsObject;
|
|
|
|
beforeEach(() => {
|
|
dispatchSpy = sinon.spy();
|
|
mapDispatchToPropsObject = mapDispatchToProps(dispatchSpy);
|
|
});
|
|
|
|
describe('updateGasPrice()', () => {
|
|
it('should dispatch an action', () => {
|
|
mapDispatchToPropsObject.updateGasPrice('mockNewPrice');
|
|
expect(dispatchSpy.calledTwice).toStrictEqual(true);
|
|
expect(updateGasPrice).toHaveBeenCalled();
|
|
expect(setCustomGasPrice).toHaveBeenCalledWith('mockNewPrice');
|
|
});
|
|
});
|
|
|
|
describe('updateGasLimit()', () => {
|
|
it('should dispatch an action', () => {
|
|
mapDispatchToPropsObject.updateGasLimit('mockNewLimit');
|
|
expect(dispatchSpy.calledTwice).toStrictEqual(true);
|
|
expect(updateGasLimit).toHaveBeenCalled();
|
|
expect(setCustomGasLimit).toHaveBeenCalledWith('mockNewLimit');
|
|
});
|
|
});
|
|
});
|
|
});
|