2021-02-04 19:15:23 +01:00
|
|
|
import sinon from 'sinon';
|
2018-05-05 17:11:53 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
import {
|
|
|
|
setCustomGasPrice,
|
|
|
|
setCustomGasLimit,
|
|
|
|
} from '../../../../ducks/gas/gas.duck';
|
|
|
|
|
2021-06-23 23:35:25 +02:00
|
|
|
import { updateGasPrice, updateGasLimit } from '../../../../ducks/send';
|
2021-04-15 20:01:46 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
let mapDispatchToProps;
|
2018-05-05 17:11:53 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
jest.mock('react-redux', () => ({
|
2022-09-28 22:00:57 +02:00
|
|
|
connect: (_, md) => {
|
2021-04-15 20:01:46 +02:00
|
|
|
mapDispatchToProps = md;
|
|
|
|
return () => ({});
|
2019-02-06 01:24:28 +01:00
|
|
|
},
|
2021-04-15 20:01:46 +02:00
|
|
|
}));
|
|
|
|
|
2021-06-23 23:35:25 +02:00
|
|
|
jest.mock('../../../../ducks/send', () => {
|
|
|
|
const original = jest.requireActual('../../../../ducks/send');
|
|
|
|
return {
|
|
|
|
...original,
|
|
|
|
getSendMaxModeState: (s) => `mockMaxModeOn:${s}`,
|
|
|
|
updateGasPrice: jest.fn(),
|
|
|
|
updateGasLimit: jest.fn(),
|
|
|
|
};
|
|
|
|
});
|
2021-04-15 20:01:46 +02:00
|
|
|
|
2022-09-28 22:00:57 +02:00
|
|
|
jest.mock('../../../../ducks/gas/gas.duck', () => ({
|
|
|
|
setCustomGasPrice: jest.fn(),
|
|
|
|
setCustomGasLimit: jest.fn(),
|
|
|
|
}));
|
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
jest.mock('../../send.utils.js', () => ({
|
|
|
|
isBalanceSufficient: ({ amount, gasTotal, balance, conversionRate }) =>
|
|
|
|
`${amount}:${gasTotal}:${balance}:${conversionRate}`,
|
|
|
|
|
|
|
|
calcGasTotal: (gasLimit, gasPrice) => gasLimit + gasPrice,
|
|
|
|
}));
|
|
|
|
|
2022-07-27 21:32:17 +02:00
|
|
|
require('./send-gas-row.container');
|
2018-05-05 17:11:53 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
describe('send-gas-row container', () => {
|
|
|
|
describe('mapDispatchToProps()', () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
let dispatchSpy;
|
|
|
|
let mapDispatchToPropsObject;
|
2018-05-05 17:11:53 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
beforeEach(() => {
|
2021-02-04 19:15:23 +01:00
|
|
|
dispatchSpy = sinon.spy();
|
|
|
|
mapDispatchToPropsObject = mapDispatchToProps(dispatchSpy);
|
|
|
|
});
|
2018-05-05 17:11:53 +02:00
|
|
|
|
2021-06-23 23:35:25 +02:00
|
|
|
describe('updateGasPrice()', () => {
|
2021-04-15 20:01:46 +02:00
|
|
|
it('should dispatch an action', () => {
|
2021-06-23 23:35:25 +02:00
|
|
|
mapDispatchToPropsObject.updateGasPrice('mockNewPrice');
|
|
|
|
expect(dispatchSpy.calledTwice).toStrictEqual(true);
|
|
|
|
expect(updateGasPrice).toHaveBeenCalled();
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(setCustomGasPrice).toHaveBeenCalledWith('mockNewPrice');
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|
2019-02-06 01:24:28 +01:00
|
|
|
|
2021-06-23 23:35:25 +02:00
|
|
|
describe('updateGasLimit()', () => {
|
2021-04-15 20:01:46 +02:00
|
|
|
it('should dispatch an action', () => {
|
2021-06-23 23:35:25 +02:00
|
|
|
mapDispatchToPropsObject.updateGasLimit('mockNewLimit');
|
|
|
|
expect(dispatchSpy.calledTwice).toStrictEqual(true);
|
|
|
|
expect(updateGasLimit).toHaveBeenCalled();
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(setCustomGasLimit).toHaveBeenCalledWith('mockNewLimit');
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|