aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/send/send-content/send-to-row/tests/send-to-row-selectors.test.js
blob: 0fa342d1ec1cb89e0986397960f85733933bf2c7 (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
import assert from 'assert'
import {
  getToDropdownOpen,
  getTokens,
  sendToIsInError,
} from '../send-to-row.selectors.js'

describe('send-to-row selectors', () => {

  describe('getToDropdownOpen()', () => {
    it('should return send.getToDropdownOpen', () => {
      const state = {
        send: {
          toDropdownOpen: false,
        },
      }

      assert.equal(getToDropdownOpen(state), false)
    })
  })

  describe('sendToIsInError()', () => {
    it('should return true if send.errors.to is truthy', () => {
      const state = {
        send: {
          errors: {
            to: 'abc',
          },
        },
      }

      assert.equal(sendToIsInError(state), true)
    })

    it('should return false if send.errors.to is falsy', () => {
      const state = {
        send: {
          errors: {
            to: null,
          },
        },
      }

      assert.equal(sendToIsInError(state), false)
    })
  })

  describe('getTokens()', () => {
    it('should return empty array if no tokens in state', () => {
      const state = {
        metamask: {
          tokens: [],
        },
      }

      assert.deepStrictEqual(getTokens(state), [])
    })
  })
})