1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-04 23:14:56 +01:00
metamask-extension/ui/pages/send/send-content/send-amount-row/send-amount-row.container.test.js

94 lines
2.6 KiB
JavaScript
Raw Normal View History

import sinon from 'sinon';
import {
updateSendErrors,
setMaxModeTo,
updateSendAmount,
} from '../../../../ducks/send/send.duck';
let mapDispatchToProps;
jest.mock('react-redux', () => ({
connect: (_, md) => {
mapDispatchToProps = md;
return () => ({});
2018-06-29 19:19:40 +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,
}),
}));
jest.mock('../../../../ducks/send/send.duck', () => ({
updateSendErrors: jest.fn(),
setMaxModeTo: jest.fn(),
updateSendAmount: jest.fn(),
}));
require('./send-amount-row.container.js');
describe('send-amount-row container', () => {
describe('mapDispatchToProps()', () => {
let dispatchSpy;
let mapDispatchToPropsObject;
beforeEach(() => {
dispatchSpy = sinon.spy();
mapDispatchToPropsObject = mapDispatchToProps(dispatchSpy);
});
describe('setMaxModeTo()', () => {
it('should dispatch an action', () => {
mapDispatchToPropsObject.setMaxModeTo('mockBool');
expect(dispatchSpy.calledOnce).toStrictEqual(true);
expect(setMaxModeTo).toHaveBeenCalled();
expect(setMaxModeTo).toHaveBeenCalledWith('mockBool');
});
});
describe('updateSendAmount()', () => {
it('should dispatch an action', () => {
mapDispatchToPropsObject.updateSendAmount('mockAmount');
expect(dispatchSpy.calledOnce).toStrictEqual(true);
expect(updateSendAmount).toHaveBeenCalled();
expect(updateSendAmount).toHaveBeenCalledWith('mockAmount');
});
});
describe('updateGasFeeError()', () => {
it('should dispatch an action', () => {
mapDispatchToPropsObject.updateGasFeeError({ some: 'data' });
expect(dispatchSpy.calledOnce).toStrictEqual(true);
expect(updateSendErrors).toHaveBeenCalled();
expect(updateSendErrors).toHaveBeenCalledWith({
some: 'data',
mockGasFeeErrorChange: true,
});
});
});
2018-06-29 19:19:40 +02:00
describe('updateSendAmountError()', () => {
it('should dispatch an action', () => {
mapDispatchToPropsObject.updateSendAmountError({ some: 'data' });
expect(dispatchSpy.calledOnce).toStrictEqual(true);
expect(updateSendErrors).toHaveBeenCalled();
expect(updateSendErrors).toHaveBeenCalledWith({
some: 'data',
mockChange: true,
});
});
});
});
});