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.
65 lines
2.0 KiB
65 lines
2.0 KiB
4 years ago
|
import sinon from 'sinon';
|
||
5 years ago
|
|
||
4 years ago
|
import { updateSendTo } from '../../../../store/actions';
|
||
|
|
||
4 years ago
|
let mapStateToProps;
|
||
|
let mapDispatchToProps;
|
||
5 years ago
|
|
||
4 years ago
|
jest.mock('react-redux', () => ({
|
||
|
connect: (ms, md) => {
|
||
|
mapStateToProps = ms;
|
||
|
mapDispatchToProps = md;
|
||
|
return () => ({});
|
||
5 years ago
|
},
|
||
4 years ago
|
}));
|
||
|
|
||
4 years ago
|
jest.mock('../../../../selectors', () => ({
|
||
4 years ago
|
getSendEnsResolution: (s) => `mockSendEnsResolution:${s}`,
|
||
|
getSendEnsResolutionError: (s) => `mockSendEnsResolutionError:${s}`,
|
||
|
getAddressBook: (s) => [{ name: `mockAddressBook:${s}` }],
|
||
|
getAddressBookEntry: (s) => `mockAddressBookEntry:${s}`,
|
||
|
accountsWithSendEtherInfoSelector: () => [
|
||
|
{ name: `account1:mockState` },
|
||
|
{ name: `account2:mockState` },
|
||
|
],
|
||
|
}));
|
||
|
|
||
4 years ago
|
jest.mock('../../../../store/actions', () => ({
|
||
4 years ago
|
updateSendTo: jest.fn(),
|
||
|
}));
|
||
|
|
||
|
require('./add-recipient.container.js');
|
||
5 years ago
|
|
||
4 years ago
|
describe('add-recipient container', () => {
|
||
|
describe('mapStateToProps()', () => {
|
||
|
it('should map the correct properties to props', () => {
|
||
|
expect(mapStateToProps('mockState')).toStrictEqual({
|
||
5 years ago
|
addressBook: [{ name: 'mockAddressBook:mockState' }],
|
||
|
contacts: [{ name: 'mockAddressBook:mockState' }],
|
||
|
ensResolution: 'mockSendEnsResolution:mockState',
|
||
|
ensResolutionError: 'mockSendEnsResolutionError:mockState',
|
||
4 years ago
|
ownedAccounts: [
|
||
|
{ name: `account1:mockState` },
|
||
|
{ name: `account2:mockState` },
|
||
|
],
|
||
5 years ago
|
addressBookEntryName: undefined,
|
||
|
nonContacts: [],
|
||
4 years ago
|
});
|
||
|
});
|
||
|
});
|
||
5 years ago
|
|
||
4 years ago
|
describe('mapDispatchToProps()', () => {
|
||
|
describe('updateSendTo()', () => {
|
||
4 years ago
|
const dispatchSpy = sinon.spy();
|
||
|
const mapDispatchToPropsObject = mapDispatchToProps(dispatchSpy);
|
||
5 years ago
|
|
||
4 years ago
|
it('should dispatch an action', () => {
|
||
4 years ago
|
mapDispatchToPropsObject.updateSendTo('mockTo', 'mockNickname');
|
||
4 years ago
|
expect(dispatchSpy.calledOnce).toStrictEqual(true);
|
||
|
expect(updateSendTo).toHaveBeenCalled();
|
||
|
expect(updateSendTo).toHaveBeenCalledWith('mockTo', 'mockNickname');
|
||
4 years ago
|
});
|
||
|
});
|
||
|
});
|
||
|
});
|