You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
89 lines
2.0 KiB
89 lines
2.0 KiB
4 years ago
|
import React from 'react';
|
||
|
import thunk from 'redux-thunk';
|
||
|
import { Provider } from 'react-redux';
|
||
|
import configureMockStore from 'redux-mock-store';
|
||
|
import { mount } from 'enzyme';
|
||
|
import sinon from 'sinon';
|
||
|
import { MemoryRouter } from 'react-router-dom';
|
||
6 years ago
|
|
||
4 years ago
|
import Identicon from '../../ui/identicon';
|
||
|
import TokenCell from '.';
|
||
6 years ago
|
|
||
4 years ago
|
describe('Token Cell', () => {
|
||
4 years ago
|
let wrapper;
|
||
6 years ago
|
|
||
|
const state = {
|
||
|
metamask: {
|
||
|
currentCurrency: 'usd',
|
||
|
selectedAddress: '0xAddress',
|
||
|
contractExchangeRates: {
|
||
|
'0xAnotherToken': 0.015,
|
||
|
},
|
||
4 years ago
|
conversionRate: 7.0,
|
||
5 years ago
|
preferences: {},
|
||
|
provider: {
|
||
4 years ago
|
chainId: '0x1',
|
||
5 years ago
|
ticker: 'ETH',
|
||
|
type: 'mainnet',
|
||
|
},
|
||
6 years ago
|
},
|
||
4 years ago
|
};
|
||
6 years ago
|
|
||
4 years ago
|
const middlewares = [thunk];
|
||
|
const mockStore = configureMockStore(middlewares);
|
||
|
const store = mockStore(state);
|
||
6 years ago
|
|
||
4 years ago
|
let onClick;
|
||
5 years ago
|
|
||
4 years ago
|
beforeEach(() => {
|
||
4 years ago
|
onClick = sinon.stub();
|
||
6 years ago
|
wrapper = mount(
|
||
|
<Provider store={store}>
|
||
5 years ago
|
<MemoryRouter>
|
||
|
<TokenCell
|
||
|
address="0xAnotherToken"
|
||
|
symbol="TEST"
|
||
|
string="5.000"
|
||
|
currentCurrency="usd"
|
||
|
onClick={onClick}
|
||
|
/>
|
||
|
</MemoryRouter>
|
||
4 years ago
|
</Provider>,
|
||
4 years ago
|
);
|
||
|
});
|
||
6 years ago
|
|
||
4 years ago
|
afterEach(() => {
|
||
4 years ago
|
sinon.restore();
|
||
|
});
|
||
5 years ago
|
|
||
4 years ago
|
it('renders Identicon with props from token cell', () => {
|
||
|
expect(wrapper.find(Identicon).prop('address')).toStrictEqual(
|
||
4 years ago
|
'0xAnotherToken',
|
||
4 years ago
|
);
|
||
|
});
|
||
6 years ago
|
|
||
4 years ago
|
it('renders token balance', () => {
|
||
|
expect(wrapper.find('.asset-list-item__token-value').text()).toStrictEqual(
|
||
4 years ago
|
'5.000',
|
||
4 years ago
|
);
|
||
|
});
|
||
4 years ago
|
|
||
4 years ago
|
it('renders token symbol', () => {
|
||
|
expect(wrapper.find('.asset-list-item__token-symbol').text()).toStrictEqual(
|
||
4 years ago
|
'TEST',
|
||
4 years ago
|
);
|
||
|
});
|
||
6 years ago
|
|
||
4 years ago
|
it('renders converted fiat amount', () => {
|
||
|
expect(wrapper.find('.list-item__subheading').text()).toStrictEqual(
|
||
4 years ago
|
'$0.52 USD',
|
||
4 years ago
|
);
|
||
|
});
|
||
6 years ago
|
|
||
4 years ago
|
it('calls onClick when clicked', () => {
|
||
|
expect(!onClick.called).toStrictEqual(true);
|
||
4 years ago
|
wrapper.simulate('click');
|
||
4 years ago
|
expect(onClick.called).toStrictEqual(true);
|
||
4 years ago
|
});
|
||
|
});
|