mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-02 14:15:06 +01:00
798930afba
* Add Swap feature to CurrencyInput * Fix linter error * Fix and Add unit tests
63 lines
1.5 KiB
JavaScript
63 lines
1.5 KiB
JavaScript
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',
|
|
nativeCurrency: 'ETH',
|
|
},
|
|
}
|
|
|
|
assert.deepEqual(mapStateToProps(mockState), {
|
|
conversionRate: 280.45,
|
|
currentCurrency: 'usd',
|
|
nativeCurrency: 'ETH',
|
|
})
|
|
})
|
|
})
|
|
|
|
describe('mergeProps()', () => {
|
|
it('should return the correct props', () => {
|
|
const mockStateProps = {
|
|
conversionRate: 280.45,
|
|
currentCurrency: 'usd',
|
|
nativeCurrency: 'ETH',
|
|
}
|
|
const mockDispatchProps = {}
|
|
|
|
assert.deepEqual(mergeProps(mockStateProps, mockDispatchProps, { useFiat: true }), {
|
|
conversionRate: 280.45,
|
|
currentCurrency: 'usd',
|
|
nativeCurrency: 'ETH',
|
|
useFiat: true,
|
|
nativeSuffix: 'ETH',
|
|
fiatSuffix: 'USD',
|
|
})
|
|
|
|
assert.deepEqual(mergeProps(mockStateProps, mockDispatchProps, {}), {
|
|
conversionRate: 280.45,
|
|
currentCurrency: 'usd',
|
|
nativeCurrency: 'ETH',
|
|
nativeSuffix: 'ETH',
|
|
fiatSuffix: 'USD',
|
|
})
|
|
})
|
|
})
|
|
})
|