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.
55 lines
1.3 KiB
55 lines
1.3 KiB
import React from 'react';
|
|
import thunk from 'redux-thunk';
|
|
import configureMockStore from 'redux-mock-store';
|
|
import { fireEvent } from '@testing-library/react';
|
|
import { renderWithProvider } from '../../../../test/lib/render-helpers';
|
|
import TokenCell from '.';
|
|
|
|
describe('Token Cell', () => {
|
|
const mockState = {
|
|
metamask: {
|
|
currentCurrency: 'usd',
|
|
selectedAddress: '0xAddress',
|
|
contractExchangeRates: {
|
|
'0xAnotherToken': 0.015,
|
|
},
|
|
conversionRate: 7.0,
|
|
preferences: {},
|
|
provider: {
|
|
chainId: '0x1',
|
|
ticker: 'ETH',
|
|
type: 'mainnet',
|
|
},
|
|
},
|
|
};
|
|
|
|
const mockStore = configureMockStore([thunk])(mockState);
|
|
|
|
const props = {
|
|
address: '0xAnotherToken',
|
|
symbol: 'TEST',
|
|
string: '5.000',
|
|
currentCurrency: 'usd',
|
|
onClick: jest.fn(),
|
|
};
|
|
|
|
it('should match snapshot', () => {
|
|
const { container } = renderWithProvider(
|
|
<TokenCell {...props} />,
|
|
mockStore,
|
|
);
|
|
|
|
expect(container).toMatchSnapshot();
|
|
});
|
|
|
|
it('calls onClick when clicked', () => {
|
|
const { queryByTestId } = renderWithProvider(
|
|
<TokenCell {...props} />,
|
|
mockStore,
|
|
);
|
|
|
|
fireEvent.click(queryByTestId('token-button'));
|
|
|
|
expect(props.onClick).toHaveBeenCalled();
|
|
});
|
|
});
|
|
|