aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/currency-input/tests/currency-input.container.test.js
blob: 10f530efff10fe958e81fafe498887adb7df8e6b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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',
      })
    })
  })
})