2021-02-04 19:15:23 +01:00
|
|
|
import React from 'react';
|
|
|
|
import thunk from 'redux-thunk';
|
|
|
|
import configureMockStore from 'redux-mock-store';
|
2022-10-11 19:54:50 +02:00
|
|
|
import { fireEvent } from '@testing-library/react';
|
|
|
|
import { renderWithProvider } from '../../../../test/lib/render-helpers';
|
2021-02-04 19:15:23 +01:00
|
|
|
import TokenCell from '.';
|
2018-09-24 18:28:04 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
describe('Token Cell', () => {
|
2022-10-11 19:54:50 +02:00
|
|
|
const mockState = {
|
2018-09-24 18:28:04 +02:00
|
|
|
metamask: {
|
|
|
|
currentCurrency: 'usd',
|
|
|
|
selectedAddress: '0xAddress',
|
|
|
|
contractExchangeRates: {
|
|
|
|
'0xAnotherToken': 0.015,
|
|
|
|
},
|
2020-11-03 00:41:28 +01:00
|
|
|
conversionRate: 7.0,
|
2020-06-12 20:47:23 +02:00
|
|
|
preferences: {},
|
2023-05-02 17:53:20 +02:00
|
|
|
providerConfig: {
|
2021-02-23 17:27:32 +01:00
|
|
|
chainId: '0x1',
|
2020-06-12 20:47:23 +02:00
|
|
|
ticker: 'ETH',
|
|
|
|
type: 'mainnet',
|
|
|
|
},
|
2018-09-24 18:28:04 +02:00
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2018-09-24 18:28:04 +02:00
|
|
|
|
2022-10-11 19:54:50 +02:00
|
|
|
const mockStore = configureMockStore([thunk])(mockState);
|
2018-09-24 18:28:04 +02:00
|
|
|
|
2022-10-11 19:54:50 +02:00
|
|
|
const props = {
|
|
|
|
address: '0xAnotherToken',
|
|
|
|
symbol: 'TEST',
|
|
|
|
string: '5.000',
|
|
|
|
currentCurrency: 'usd',
|
|
|
|
onClick: jest.fn(),
|
|
|
|
};
|
2020-03-25 22:24:14 +01:00
|
|
|
|
2022-10-11 19:54:50 +02:00
|
|
|
it('should match snapshot', () => {
|
|
|
|
const { container } = renderWithProvider(
|
|
|
|
<TokenCell {...props} />,
|
|
|
|
mockStore,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2018-09-24 18:28:04 +02:00
|
|
|
|
2022-10-11 19:54:50 +02:00
|
|
|
expect(container).toMatchSnapshot();
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-03-25 22:24:14 +01:00
|
|
|
|
2022-10-11 19:54:50 +02:00
|
|
|
it('calls onClick when clicked', () => {
|
|
|
|
const { queryByTestId } = renderWithProvider(
|
|
|
|
<TokenCell {...props} />,
|
|
|
|
mockStore,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2018-09-24 18:28:04 +02:00
|
|
|
|
2023-06-01 23:14:38 +02:00
|
|
|
fireEvent.click(queryByTestId('multichain-token-list-button'));
|
2018-09-24 18:28:04 +02:00
|
|
|
|
2022-10-11 19:54:50 +02:00
|
|
|
expect(props.onClick).toHaveBeenCalled();
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|