aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/ui/add-token.spec.js
blob: ee52f775f150cb4c1c10203dc6e8d970a57244dd (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
const React = require('react')
const assert = require('assert')
const { createMockStore } = require('redux-test-utils')
const h = require('react-hyperscript')
const { shallowWithStore, mountWithStore } = require('../../lib/shallow-with-store')
const AddTokenScreen = require('../../../ui/app/add-token')

describe.only('Add Token Screen', function () {
  let addTokenComponent, store, component
  const mockState = {
    metamask: {
      identities: {
        '0x7d3517b0d011698406d6e0aed8453f0be2697926': {
          'address': '0x7d3517b0d011698406d6e0aed8453f0be2697926',
          'name': 'Add Token Name',
        },
      },
    },
  }
  beforeEach(function () {
    store = createMockStore(mockState)
    component = shallowWithStore(h(AddTokenScreen), store)
    addTokenComponent = component.dive()
  })

  describe('#ValidateInputs', function () {

    it('Default State', function () {
      addTokenComponent.instance().validateInputs()
      const state = addTokenComponent.state()
      assert.equal(state.warning, 'Address is invalid.')
    })

    it('Address is a Metamask Identity', function () {
      addTokenComponent.setState({
        address: '0x7d3517b0d011698406d6e0aed8453f0be2697926',
      })
      addTokenComponent.instance().validateInputs()
      const state = addTokenComponent.state()
      assert.equal(state.warning, 'Personal address detected. Input the token contract address.')
    })

  })
})