aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/ui/app/components/identicon.spec.js
blob: a2f8d82464ae72bee6ac13ecd17ad0c94e98c1aa (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
import React from 'react'
import assert from 'assert'
import thunk from 'redux-thunk'
import configureMockStore from 'redux-mock-store'
import { mount } from 'enzyme'

import IdenticonComponent from '../../../../../ui/app/components/identicon'

describe('Identicon Component', () => {

  const state = {
    metamask: {
      useBlockie: false,
    },
  }

  const middlewares = [thunk]
  const mockStore = configureMockStore(middlewares)
  const store = mockStore(state)

  it('renders default eth_logo identicon with no props', () => {
    const wrapper = mount(<IdenticonComponent store={store}/>)
    assert.equal(wrapper.find('img.balance-icon').prop('src'), './images/eth_logo.svg')
  })

  it('renders custom image and add className props', () => {
    const wrapper = mount(<IdenticonComponent store={store} className={'test-image'} image={'test-image'} />)
    assert.equal(wrapper.find('img.test-image').prop('className'), 'test-image identicon')
    assert.equal(wrapper.find('img.test-image').prop('src'), 'test-image')
  })

  it('renders div with address prop', () => {
    const wrapper = mount(<IdenticonComponent store={store} className={'test-address'} address={'0xTest'} />)
    assert.equal(wrapper.find('div.test-address').prop('className'), 'test-address identicon')
  })
})