1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-04 23:14:56 +01:00
metamask-extension/ui/app/pages/send/send-content/add-recipient/tests/add-recipient-container.test.js
Erik Marks 76a2a9bb8b
@metamask/eslint config@5.0.0 (#10358)
* @metamask/eslint-config@5.0.0
* Update eslintrc and prettierrc
* yarn lint:fix
2021-02-04 10:15:23 -08:00

68 lines
2.1 KiB
JavaScript

import assert from 'assert';
import proxyquire from 'proxyquire';
import sinon from 'sinon';
let mapStateToProps;
let mapDispatchToProps;
const actionSpies = {
updateSendTo: sinon.spy(),
};
proxyquire('../add-recipient.container.js', {
'react-redux': {
connect: (ms, md) => {
mapStateToProps = ms;
mapDispatchToProps = md;
return () => ({});
},
},
'../../../../selectors': {
getSendEnsResolution: (s) => `mockSendEnsResolution:${s}`,
getSendEnsResolutionError: (s) => `mockSendEnsResolutionError:${s}`,
getAddressBook: (s) => [{ name: `mockAddressBook:${s}` }],
getAddressBookEntry: (s) => `mockAddressBookEntry:${s}`,
accountsWithSendEtherInfoSelector: (s) => [
{ name: `account2:${s}` },
{ name: `account1:${s}` },
],
},
'../../../../store/actions': actionSpies,
});
describe('add-recipient container', function () {
describe('mapStateToProps()', function () {
it('should map the correct properties to props', function () {
assert.deepStrictEqual(mapStateToProps('mockState'), {
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()', function () {
describe('updateSendTo()', function () {
const dispatchSpy = sinon.spy();
const mapDispatchToPropsObject = mapDispatchToProps(dispatchSpy);
it('should dispatch an action', function () {
mapDispatchToPropsObject.updateSendTo('mockTo', 'mockNickname');
assert(dispatchSpy.calledOnce);
assert(actionSpies.updateSendTo.calledOnce);
assert.deepStrictEqual(actionSpies.updateSendTo.getCall(0).args, [
'mockTo',
'mockNickname',
]);
});
});
});
});