2018-05-05 17:11:53 +02:00
|
|
|
import assert from 'assert'
|
|
|
|
import proxyquire from 'proxyquire'
|
|
|
|
import sinon from 'sinon'
|
|
|
|
|
|
|
|
let mapDispatchToProps
|
|
|
|
|
|
|
|
const actionSpies = {
|
|
|
|
setMaxModeTo: sinon.spy(),
|
|
|
|
updateSendAmount: sinon.spy(),
|
|
|
|
}
|
|
|
|
const duckActionSpies = {
|
|
|
|
updateSendErrors: sinon.spy(),
|
|
|
|
}
|
|
|
|
|
|
|
|
proxyquire('../send-amount-row.container.js', {
|
|
|
|
'react-redux': {
|
2019-12-08 04:10:47 +01:00
|
|
|
connect: (_, md) => {
|
2018-05-05 17:11:53 +02:00
|
|
|
mapDispatchToProps = md
|
|
|
|
return () => ({})
|
|
|
|
},
|
|
|
|
},
|
2020-05-04 21:06:28 +02:00
|
|
|
'../../../../selectors': { sendAmountIsInError: (s) => `mockInError:${s}` },
|
2018-06-29 19:19:40 +02:00
|
|
|
'../../send.utils': {
|
2020-11-03 00:41:28 +01:00
|
|
|
getAmountErrorObject: (mockDataObject) => ({
|
|
|
|
...mockDataObject,
|
|
|
|
mockChange: true,
|
|
|
|
}),
|
|
|
|
getGasFeeErrorObject: (mockDataObject) => ({
|
|
|
|
...mockDataObject,
|
|
|
|
mockGasFeeErrorChange: true,
|
|
|
|
}),
|
2018-06-29 19:19:40 +02:00
|
|
|
},
|
2019-04-17 21:15:13 +02:00
|
|
|
'../../../../store/actions': actionSpies,
|
|
|
|
'../../../../ducks/send/send.duck': duckActionSpies,
|
2018-05-05 17:11:53 +02:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('send-amount-row container', function () {
|
|
|
|
describe('mapDispatchToProps()', function () {
|
2018-05-05 17:11:53 +02:00
|
|
|
let dispatchSpy
|
|
|
|
let mapDispatchToPropsObject
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
beforeEach(function () {
|
2018-05-05 17:11:53 +02:00
|
|
|
dispatchSpy = sinon.spy()
|
|
|
|
mapDispatchToPropsObject = mapDispatchToProps(dispatchSpy)
|
2018-06-29 19:19:40 +02:00
|
|
|
duckActionSpies.updateSendErrors.resetHistory()
|
2018-05-05 17:11:53 +02:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('setMaxModeTo()', function () {
|
|
|
|
it('should dispatch an action', function () {
|
2018-05-05 17:11:53 +02:00
|
|
|
mapDispatchToPropsObject.setMaxModeTo('mockBool')
|
|
|
|
assert(dispatchSpy.calledOnce)
|
|
|
|
assert(actionSpies.setMaxModeTo.calledOnce)
|
2020-12-03 16:46:22 +01:00
|
|
|
assert.strictEqual(
|
|
|
|
actionSpies.setMaxModeTo.getCall(0).args[0],
|
|
|
|
'mockBool',
|
|
|
|
)
|
2018-05-05 17:11:53 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('updateSendAmount()', function () {
|
|
|
|
it('should dispatch an action', function () {
|
2018-05-05 17:11:53 +02:00
|
|
|
mapDispatchToPropsObject.updateSendAmount('mockAmount')
|
|
|
|
assert(dispatchSpy.calledOnce)
|
|
|
|
assert(actionSpies.updateSendAmount.calledOnce)
|
2020-12-03 16:46:22 +01:00
|
|
|
assert.strictEqual(
|
2018-05-05 17:11:53 +02:00
|
|
|
actionSpies.updateSendAmount.getCall(0).args[0],
|
2020-07-14 17:20:41 +02:00
|
|
|
'mockAmount',
|
2018-05-05 17:11:53 +02:00
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('updateGasFeeError()', function () {
|
|
|
|
it('should dispatch an action', function () {
|
2018-06-29 19:19:40 +02:00
|
|
|
mapDispatchToPropsObject.updateGasFeeError({ some: 'data' })
|
|
|
|
assert(dispatchSpy.calledOnce)
|
|
|
|
assert(duckActionSpies.updateSendErrors.calledOnce)
|
2020-12-03 16:46:22 +01:00
|
|
|
assert.deepStrictEqual(
|
|
|
|
duckActionSpies.updateSendErrors.getCall(0).args[0],
|
|
|
|
{
|
|
|
|
some: 'data',
|
|
|
|
mockGasFeeErrorChange: true,
|
|
|
|
},
|
|
|
|
)
|
2018-06-29 19:19:40 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('updateSendAmountError()', function () {
|
|
|
|
it('should dispatch an action', function () {
|
2018-05-05 17:11:53 +02:00
|
|
|
mapDispatchToPropsObject.updateSendAmountError({ some: 'data' })
|
|
|
|
assert(dispatchSpy.calledOnce)
|
|
|
|
assert(duckActionSpies.updateSendErrors.calledOnce)
|
2020-12-03 16:46:22 +01:00
|
|
|
assert.deepStrictEqual(
|
|
|
|
duckActionSpies.updateSendErrors.getCall(0).args[0],
|
|
|
|
{
|
|
|
|
some: 'data',
|
|
|
|
mockChange: true,
|
|
|
|
},
|
|
|
|
)
|
2018-05-05 17:11:53 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|