mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-04 23:14:56 +01:00
65 lines
2.0 KiB
JavaScript
65 lines
2.0 KiB
JavaScript
import sinon from 'sinon';
|
|
|
|
import { updateSendTo } from '../../../../store/actions';
|
|
|
|
let mapStateToProps;
|
|
let mapDispatchToProps;
|
|
|
|
jest.mock('react-redux', () => ({
|
|
connect: (ms, md) => {
|
|
mapStateToProps = ms;
|
|
mapDispatchToProps = md;
|
|
return () => ({});
|
|
},
|
|
}));
|
|
|
|
jest.mock('../../../../selectors', () => ({
|
|
getSendEnsResolution: (s) => `mockSendEnsResolution:${s}`,
|
|
getSendEnsResolutionError: (s) => `mockSendEnsResolutionError:${s}`,
|
|
getAddressBook: (s) => [{ name: `mockAddressBook:${s}` }],
|
|
getAddressBookEntry: (s) => `mockAddressBookEntry:${s}`,
|
|
accountsWithSendEtherInfoSelector: () => [
|
|
{ name: `account1:mockState` },
|
|
{ name: `account2:mockState` },
|
|
],
|
|
}));
|
|
|
|
jest.mock('../../../../store/actions', () => ({
|
|
updateSendTo: jest.fn(),
|
|
}));
|
|
|
|
require('./add-recipient.container.js');
|
|
|
|
describe('add-recipient container', () => {
|
|
describe('mapStateToProps()', () => {
|
|
it('should map the correct properties to props', () => {
|
|
expect(mapStateToProps('mockState')).toStrictEqual({
|
|
addressBook: [{ name: 'mockAddressBook:mockState' }],
|
|
contacts: [{ name: 'mockAddressBook:mockState' }],
|
|
ensResolution: 'mockSendEnsResolution:mockState',
|
|
ensResolutionError: 'mockSendEnsResolutionError:mockState',
|
|
ownedAccounts: [
|
|
{ name: `account1:mockState` },
|
|
{ name: `account2:mockState` },
|
|
],
|
|
addressBookEntryName: undefined,
|
|
nonContacts: [],
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('mapDispatchToProps()', () => {
|
|
describe('updateSendTo()', () => {
|
|
const dispatchSpy = sinon.spy();
|
|
const mapDispatchToPropsObject = mapDispatchToProps(dispatchSpy);
|
|
|
|
it('should dispatch an action', () => {
|
|
mapDispatchToPropsObject.updateSendTo('mockTo', 'mockNickname');
|
|
expect(dispatchSpy.calledOnce).toStrictEqual(true);
|
|
expect(updateSendTo).toHaveBeenCalled();
|
|
expect(updateSendTo).toHaveBeenCalledWith('mockTo', 'mockNickname');
|
|
});
|
|
});
|
|
});
|
|
});
|