2018-05-24 21:57:33 +02:00
|
|
|
import assert from 'assert'
|
|
|
|
import proxyquire from 'proxyquire'
|
|
|
|
|
|
|
|
const {
|
|
|
|
getTitleKey,
|
|
|
|
} = proxyquire('../send-header.selectors', {
|
|
|
|
'../send.selectors': {
|
|
|
|
getSelectedToken: (mockState) => mockState.t,
|
|
|
|
getSendEditingTransactionId: (mockState) => mockState.e,
|
2019-07-31 21:56:44 +02:00
|
|
|
getSendTo: (mockState) => mockState.to,
|
2018-05-24 21:57:33 +02:00
|
|
|
},
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('send-header selectors', function () {
|
2018-05-24 21:57:33 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('getTitleKey()', function () {
|
|
|
|
it('should return the correct key when "to" is empty', function () {
|
2019-07-31 21:56:44 +02:00
|
|
|
assert.equal(getTitleKey({ e: 1, t: true, to: '' }), 'addRecipient')
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should return the correct key when getSendEditingTransactionId is truthy', function () {
|
2019-07-31 21:56:44 +02:00
|
|
|
assert.equal(getTitleKey({ e: 1, t: true, to: '0x123' }), 'edit')
|
2018-05-24 21:57:33 +02:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should return the correct key when getSendEditingTransactionId is falsy and getSelectedToken is truthy', function () {
|
2019-07-31 21:56:44 +02:00
|
|
|
assert.equal(getTitleKey({ e: null, t: 'abc', to: '0x123' }), 'sendTokens')
|
2018-05-24 21:57:33 +02:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should return the correct key when getSendEditingTransactionId is falsy and getSelectedToken is falsy', function () {
|
2019-07-31 21:56:44 +02:00
|
|
|
assert.equal(getTitleKey({ e: null, to: '0x123' }), 'sendETH')
|
2018-05-24 21:57:33 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|