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

56 lines
1.3 KiB
JavaScript
Raw Normal View History

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 '.';
2018-09-24 18:28:04 +02:00
describe('Token Cell', () => {
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,
preferences: {},
provider: {
chainId: '0x1',
ticker: 'ETH',
type: 'mainnet',
},
2018-09-24 18:28:04 +02:00
},
};
2018-09-24 18:28:04 +02:00
const mockStore = configureMockStore([thunk])(mockState);
2018-09-24 18:28:04 +02:00
const props = {
address: '0xAnotherToken',
symbol: 'TEST',
string: '5.000',
currentCurrency: 'usd',
onClick: jest.fn(),
};
it('should match snapshot', () => {
const { container } = renderWithProvider(
<TokenCell {...props} />,
mockStore,
);
2018-09-24 18:28:04 +02:00
expect(container).toMatchSnapshot();
});
it('calls onClick when clicked', () => {
const { queryByTestId } = renderWithProvider(
<TokenCell {...props} />,
mockStore,
);
2018-09-24 18:28:04 +02:00
fireEvent.click(queryByTestId('token-button'));
2018-09-24 18:28:04 +02:00
expect(props.onClick).toHaveBeenCalled();
});
});