A Metamask fork with Infura removed and default networks editable
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
ciphermask/ui/pages/send/send-content/send-gas-row/send-gas-row.container.test.js

71 lines
2.0 KiB

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');
});
});
});
});