2018-10-17 01:03:29 +02:00
|
|
|
import assert from 'assert'
|
|
|
|
import proxyquire from 'proxyquire'
|
|
|
|
|
|
|
|
let mapStateToProps, mergeProps
|
|
|
|
|
|
|
|
proxyquire('../currency-input.container.js', {
|
|
|
|
'react-redux': {
|
|
|
|
connect: (ms, md, mp) => {
|
|
|
|
mapStateToProps = ms
|
|
|
|
mergeProps = mp
|
|
|
|
return () => ({})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('CurrencyInput container', () => {
|
|
|
|
describe('mapStateToProps()', () => {
|
|
|
|
it('should return the correct props', () => {
|
|
|
|
const mockState = {
|
|
|
|
metamask: {
|
|
|
|
conversionRate: 280.45,
|
|
|
|
currentCurrency: 'usd',
|
2018-10-26 10:26:43 +02:00
|
|
|
nativeCurrency: 'ETH',
|
2018-10-17 01:03:29 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.deepEqual(mapStateToProps(mockState), {
|
|
|
|
conversionRate: 280.45,
|
|
|
|
currentCurrency: 'usd',
|
2018-10-26 10:26:43 +02:00
|
|
|
nativeCurrency: 'ETH',
|
2018-10-17 01:03:29 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('mergeProps()', () => {
|
|
|
|
it('should return the correct props', () => {
|
|
|
|
const mockStateProps = {
|
|
|
|
conversionRate: 280.45,
|
|
|
|
currentCurrency: 'usd',
|
2018-10-26 10:26:43 +02:00
|
|
|
nativeCurrency: 'ETH',
|
2018-10-17 01:03:29 +02:00
|
|
|
}
|
|
|
|
const mockDispatchProps = {}
|
|
|
|
|
|
|
|
assert.deepEqual(mergeProps(mockStateProps, mockDispatchProps, { useFiat: true }), {
|
|
|
|
conversionRate: 280.45,
|
|
|
|
currentCurrency: 'usd',
|
2018-10-26 10:26:43 +02:00
|
|
|
nativeCurrency: 'ETH',
|
2018-10-17 01:03:29 +02:00
|
|
|
useFiat: true,
|
2019-02-06 16:14:17 +01:00
|
|
|
nativeSuffix: 'ETH',
|
|
|
|
fiatSuffix: 'USD',
|
2018-10-17 01:03:29 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
assert.deepEqual(mergeProps(mockStateProps, mockDispatchProps, {}), {
|
|
|
|
conversionRate: 280.45,
|
|
|
|
currentCurrency: 'usd',
|
2018-10-26 10:26:43 +02:00
|
|
|
nativeCurrency: 'ETH',
|
2019-02-06 16:14:17 +01:00
|
|
|
nativeSuffix: 'ETH',
|
|
|
|
fiatSuffix: 'USD',
|
2018-10-17 01:03:29 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|