1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-27 12:56:01 +01:00
metamask-extension/ui/app/components/app/token-cell/token-cell.test.js

76 lines
1.8 KiB
JavaScript
Raw Normal View History

2018-09-24 18:28:04 +02:00
import React from 'react'
import assert from 'assert'
import thunk from 'redux-thunk'
import { Provider } from 'react-redux'
import configureMockStore from 'redux-mock-store'
import { mount } from 'enzyme'
import sinon from 'sinon'
2018-09-24 18:28:04 +02:00
import TokenCell from '.'
import Identicon from '../../ui/identicon'
2018-09-24 18:28:04 +02:00
describe('Token Cell', function () {
2018-09-24 18:28:04 +02:00
let wrapper
const state = {
metamask: {
currentCurrency: 'usd',
selectedAddress: '0xAddress',
contractExchangeRates: {
'0xAnotherToken': 0.015,
},
conversionRate: 7.00,
},
appState: {
sidebar: {
isOpen: true,
},
},
}
const middlewares = [thunk]
const mockStore = configureMockStore(middlewares)
const store = mockStore(state)
let onClick
beforeEach(function () {
onClick = sinon.stub()
2018-09-24 18:28:04 +02:00
wrapper = mount(
<Provider store={store}>
<TokenCell
address="0xAnotherToken"
symbol="TEST"
string="5.000"
currentCurrency="usd"
image="./test-image"
onClick={onClick}
2018-09-24 18:28:04 +02:00
/>
</Provider>
)
})
afterEach(function () {
sinon.restore()
})
it('renders Identicon with props from token cell', function () {
2018-09-24 18:28:04 +02:00
assert.equal(wrapper.find(Identicon).prop('address'), '0xAnotherToken')
assert.equal(wrapper.find(Identicon).prop('image'), './test-image')
})
it('renders token balance and symbol', function () {
assert.equal(wrapper.find('.list-item__heading').text(), '5.000 TEST ')
2018-09-24 18:28:04 +02:00
})
it('renders converted fiat amount', function () {
assert.equal(wrapper.find('.list-item__subheading').text(), '$0.52 USD')
2018-09-24 18:28:04 +02:00
})
it('calls onClick when clicked', function () {
assert.ok(!onClick.called)
wrapper.simulate('click')
assert.ok(onClick.called)
})
2018-09-24 18:28:04 +02:00
})