2019-07-31 21:56:44 +02:00
|
|
|
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 () => ({})
|
|
|
|
},
|
|
|
|
},
|
2020-05-04 21:06:28 +02:00
|
|
|
'../../../../selectors': {
|
2019-07-31 21:56:44 +02:00
|
|
|
getSendEnsResolution: (s) => `mockSendEnsResolution:${s}`,
|
|
|
|
getSendEnsResolutionError: (s) => `mockSendEnsResolutionError:${s}`,
|
|
|
|
getAddressBook: (s) => [{ name: `mockAddressBook:${s}` }],
|
|
|
|
getAddressBookEntry: (s) => `mockAddressBookEntry:${s}`,
|
2020-11-07 00:16:51 +01:00
|
|
|
accountsWithSendEtherInfoSelector: (s) => [
|
|
|
|
{ name: `account2:${s}` },
|
|
|
|
{ name: `account1:${s}` },
|
|
|
|
],
|
2019-07-31 21:56:44 +02:00
|
|
|
},
|
|
|
|
'../../../../store/actions': actionSpies,
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('add-recipient container', function () {
|
|
|
|
describe('mapStateToProps()', function () {
|
|
|
|
it('should map the correct properties to props', function () {
|
2020-12-03 16:46:22 +01:00
|
|
|
assert.deepStrictEqual(mapStateToProps('mockState'), {
|
2019-07-31 21:56:44 +02:00
|
|
|
addressBook: [{ name: 'mockAddressBook:mockState' }],
|
|
|
|
contacts: [{ name: 'mockAddressBook:mockState' }],
|
|
|
|
ensResolution: 'mockSendEnsResolution:mockState',
|
|
|
|
ensResolutionError: 'mockSendEnsResolutionError:mockState',
|
2020-11-07 00:16:51 +01:00
|
|
|
ownedAccounts: [
|
|
|
|
{ name: `account1:mockState` },
|
|
|
|
{ name: `account2:mockState` },
|
|
|
|
],
|
2019-07-31 21:56:44 +02:00
|
|
|
addressBookEntryName: undefined,
|
|
|
|
nonContacts: [],
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('mapDispatchToProps()', function () {
|
|
|
|
describe('updateSendTo()', function () {
|
|
|
|
const dispatchSpy = sinon.spy()
|
|
|
|
const mapDispatchToPropsObject = mapDispatchToProps(dispatchSpy)
|
2019-07-31 21:56:44 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should dispatch an action', function () {
|
2019-07-31 21:56:44 +02:00
|
|
|
mapDispatchToPropsObject.updateSendTo('mockTo', 'mockNickname')
|
|
|
|
assert(dispatchSpy.calledOnce)
|
|
|
|
assert(actionSpies.updateSendTo.calledOnce)
|
2020-12-03 16:46:22 +01:00
|
|
|
assert.deepStrictEqual(actionSpies.updateSendTo.getCall(0).args, [
|
2020-11-03 00:41:28 +01:00
|
|
|
'mockTo',
|
|
|
|
'mockNickname',
|
|
|
|
])
|
2019-07-31 21:56:44 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|