2021-02-04 19:15:23 +01:00
|
|
|
import sinon from 'sinon';
|
2018-05-05 17:11:53 +02:00
|
|
|
|
2021-06-10 19:53:15 +02:00
|
|
|
import {
|
|
|
|
updateSendErrors,
|
|
|
|
setMaxModeTo,
|
|
|
|
updateSendAmount,
|
|
|
|
} from '../../../../ducks/send/send.duck';
|
2018-05-05 17:11:53 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
let mapDispatchToProps;
|
|
|
|
|
|
|
|
jest.mock('react-redux', () => ({
|
|
|
|
connect: (_, md) => {
|
|
|
|
mapDispatchToProps = md;
|
|
|
|
return () => ({});
|
2018-06-29 19:19:40 +02:00
|
|
|
},
|
2021-04-15 20:01:46 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
jest.mock('../../../../selectors/send.js', () => ({
|
|
|
|
sendAmountIsInError: (s) => `mockInError:${s}`,
|
|
|
|
}));
|
|
|
|
|
|
|
|
jest.mock('../../send.utils', () => ({
|
|
|
|
getAmountErrorObject: (mockDataObject) => ({
|
|
|
|
...mockDataObject,
|
|
|
|
mockChange: true,
|
|
|
|
}),
|
|
|
|
getGasFeeErrorObject: (mockDataObject) => ({
|
|
|
|
...mockDataObject,
|
|
|
|
mockGasFeeErrorChange: true,
|
|
|
|
}),
|
|
|
|
}));
|
|
|
|
|
2021-04-28 21:53:59 +02:00
|
|
|
jest.mock('../../../../ducks/send/send.duck', () => ({
|
2021-04-15 20:01:46 +02:00
|
|
|
updateSendErrors: jest.fn(),
|
2021-06-10 19:53:15 +02:00
|
|
|
setMaxModeTo: jest.fn(),
|
|
|
|
updateSendAmount: jest.fn(),
|
2021-04-15 20:01:46 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
require('./send-amount-row.container.js');
|
2018-05-05 17:11:53 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
describe('send-amount-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-04-15 20:01:46 +02:00
|
|
|
describe('setMaxModeTo()', () => {
|
|
|
|
it('should dispatch an action', () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
mapDispatchToPropsObject.setMaxModeTo('mockBool');
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(dispatchSpy.calledOnce).toStrictEqual(true);
|
|
|
|
expect(setMaxModeTo).toHaveBeenCalled();
|
|
|
|
expect(setMaxModeTo).toHaveBeenCalledWith('mockBool');
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|
2018-05-05 17:11:53 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
describe('updateSendAmount()', () => {
|
|
|
|
it('should dispatch an action', () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
mapDispatchToPropsObject.updateSendAmount('mockAmount');
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(dispatchSpy.calledOnce).toStrictEqual(true);
|
|
|
|
expect(updateSendAmount).toHaveBeenCalled();
|
|
|
|
expect(updateSendAmount).toHaveBeenCalledWith('mockAmount');
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|
2018-05-05 17:11:53 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
describe('updateGasFeeError()', () => {
|
|
|
|
it('should dispatch an action', () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
mapDispatchToPropsObject.updateGasFeeError({ some: 'data' });
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(dispatchSpy.calledOnce).toStrictEqual(true);
|
|
|
|
expect(updateSendErrors).toHaveBeenCalled();
|
|
|
|
expect(updateSendErrors).toHaveBeenCalledWith({
|
|
|
|
some: 'data',
|
|
|
|
mockGasFeeErrorChange: true,
|
|
|
|
});
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|
2018-06-29 19:19:40 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
describe('updateSendAmountError()', () => {
|
|
|
|
it('should dispatch an action', () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
mapDispatchToPropsObject.updateSendAmountError({ some: 'data' });
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(dispatchSpy.calledOnce).toStrictEqual(true);
|
|
|
|
expect(updateSendErrors).toHaveBeenCalled();
|
|
|
|
expect(updateSendErrors).toHaveBeenCalledWith({
|
|
|
|
some: 'data',
|
|
|
|
mockChange: true,
|
|
|
|
});
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|