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.
95 lines
2.7 KiB
95 lines
2.7 KiB
4 years ago
|
import sinon from 'sinon';
|
||
7 years ago
|
|
||
4 years ago
|
import { setMaxModeTo, updateSendAmount } from '../../../../store/actions';
|
||
7 years ago
|
|
||
4 years ago
|
import { updateSendErrors } from '../../../../ducks/send/send.duck';
|
||
7 years ago
|
|
||
4 years ago
|
let mapDispatchToProps;
|
||
|
|
||
|
jest.mock('react-redux', () => ({
|
||
|
connect: (_, md) => {
|
||
|
mapDispatchToProps = md;
|
||
|
return () => ({});
|
||
7 years ago
|
},
|
||
4 years ago
|
}));
|
||
|
|
||
|
jest.mock('../../../../selectors/send.js', () => ({
|
||
|
sendAmountIsInError: (s) => `mockInError:${s}`,
|
||
|
}));
|
||
|
|
||
|
jest.mock('../../send.utils', () => ({
|
||
|
getAmountErrorObject: (mockDataObject) => ({
|
||
|
...mockDataObject,
|
||
|
mockChange: true,
|
||
|
}),
|
||
|
getGasFeeErrorObject: (mockDataObject) => ({
|
||
|
...mockDataObject,
|
||
|
mockGasFeeErrorChange: true,
|
||
|
}),
|
||
|
}));
|
||
|
|
||
4 years ago
|
jest.mock('../../../../store/actions', () => ({
|
||
4 years ago
|
setMaxModeTo: jest.fn(),
|
||
|
updateSendAmount: jest.fn(),
|
||
|
}));
|
||
|
|
||
4 years ago
|
jest.mock('../../../../ducks/send/send.duck', () => ({
|
||
4 years ago
|
updateSendErrors: jest.fn(),
|
||
|
}));
|
||
|
|
||
|
require('./send-amount-row.container.js');
|
||
7 years ago
|
|
||
4 years ago
|
describe('send-amount-row container', () => {
|
||
|
describe('mapDispatchToProps()', () => {
|
||
4 years ago
|
let dispatchSpy;
|
||
|
let mapDispatchToPropsObject;
|
||
7 years ago
|
|
||
4 years ago
|
beforeEach(() => {
|
||
4 years ago
|
dispatchSpy = sinon.spy();
|
||
|
mapDispatchToPropsObject = mapDispatchToProps(dispatchSpy);
|
||
|
});
|
||
7 years ago
|
|
||
4 years ago
|
describe('setMaxModeTo()', () => {
|
||
|
it('should dispatch an action', () => {
|
||
4 years ago
|
mapDispatchToPropsObject.setMaxModeTo('mockBool');
|
||
4 years ago
|
expect(dispatchSpy.calledOnce).toStrictEqual(true);
|
||
|
expect(setMaxModeTo).toHaveBeenCalled();
|
||
|
expect(setMaxModeTo).toHaveBeenCalledWith('mockBool');
|
||
4 years ago
|
});
|
||
|
});
|
||
7 years ago
|
|
||
4 years ago
|
describe('updateSendAmount()', () => {
|
||
|
it('should dispatch an action', () => {
|
||
4 years ago
|
mapDispatchToPropsObject.updateSendAmount('mockAmount');
|
||
4 years ago
|
expect(dispatchSpy.calledOnce).toStrictEqual(true);
|
||
|
expect(updateSendAmount).toHaveBeenCalled();
|
||
|
expect(updateSendAmount).toHaveBeenCalledWith('mockAmount');
|
||
4 years ago
|
});
|
||
|
});
|
||
7 years ago
|
|
||
4 years ago
|
describe('updateGasFeeError()', () => {
|
||
|
it('should dispatch an action', () => {
|
||
4 years ago
|
mapDispatchToPropsObject.updateGasFeeError({ some: 'data' });
|
||
4 years ago
|
expect(dispatchSpy.calledOnce).toStrictEqual(true);
|
||
|
expect(updateSendErrors).toHaveBeenCalled();
|
||
|
expect(updateSendErrors).toHaveBeenCalledWith({
|
||
|
some: 'data',
|
||
|
mockGasFeeErrorChange: true,
|
||
|
});
|
||
4 years ago
|
});
|
||
|
});
|
||
7 years ago
|
|
||
4 years ago
|
describe('updateSendAmountError()', () => {
|
||
|
it('should dispatch an action', () => {
|
||
4 years ago
|
mapDispatchToPropsObject.updateSendAmountError({ some: 'data' });
|
||
4 years ago
|
expect(dispatchSpy.calledOnce).toStrictEqual(true);
|
||
|
expect(updateSendErrors).toHaveBeenCalled();
|
||
|
expect(updateSendErrors).toHaveBeenCalledWith({
|
||
|
some: 'data',
|
||
|
mockChange: true,
|
||
|
});
|
||
4 years ago
|
});
|
||
|
});
|
||
|
});
|
||
|
});
|