aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/pages/send/send-header/tests/send-header-selectors.test.js
blob: e0c6a3ab311c79d350d9f0bd81a6c7e0424999be (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
import assert from 'assert'
import proxyquire from 'proxyquire'

const {
  getTitleKey,
  getSubtitleParams,
} = proxyquire('../send-header.selectors', {
  '../send.selectors': {
    getSelectedToken: (mockState) => mockState.t,
    getSendEditingTransactionId: (mockState) => mockState.e,
  },
})

describe('send-header selectors', () => {

  describe('getTitleKey()', () => {
    it('should return the correct key when getSendEditingTransactionId is truthy', () => {
      assert.equal(getTitleKey({ e: 1, t: true }), 'edit')
    })

    it('should return the correct key when getSendEditingTransactionId is falsy and getSelectedToken is truthy', () => {
      assert.equal(getTitleKey({ e: null, t: 'abc' }), 'sendTokens')
    })

    it('should return the correct key when getSendEditingTransactionId is falsy and getSelectedToken is falsy', () => {
      assert.equal(getTitleKey({ e: null }), 'sendETH')
    })
  })

  describe('getSubtitleParams()', () => {
    it('should return the correct params when getSendEditingTransactionId is truthy', () => {
      assert.deepEqual(getSubtitleParams({ e: 1, t: true }), [ 'editingTransaction' ])
    })

    it('should return the correct params when getSendEditingTransactionId is falsy and getSelectedToken is truthy', () => {
      assert.deepEqual(
        getSubtitleParams({ e: null, t: { symbol: 'ABC' } }),
        [ 'onlySendTokensToAccountAddress', [ 'ABC' ] ]
      )
    })

    it('should return the correct params when getSendEditingTransactionId is falsy and getSelectedToken is falsy', () => {
      assert.deepEqual(getSubtitleParams({ e: null }), [ 'onlySendToEtherAddress' ])
    })
  })

})