A Metamask fork with Infura removed and default networks editable
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.
ciphermask/ui/components/app/token-cell/token-cell.test.js

56 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 '.';
6 years ago
describe('Token Cell', () => {
const mockState = {
6 years ago
metamask: {
currentCurrency: 'usd',
selectedAddress: '0xAddress',
contractExchangeRates: {
'0xAnotherToken': 0.015,
},
conversionRate: 7.0,
preferences: {},
provider: {
chainId: '0x1',
ticker: 'ETH',
type: 'mainnet',
},
6 years ago
},
};
6 years ago
const mockStore = configureMockStore([thunk])(mockState);
6 years ago
const props = {
address: '0xAnotherToken',
symbol: 'TEST',
string: '5.000',
currentCurrency: 'usd',
onClick: jest.fn(),
};
it('should match snapshot', () => {
const { container } = renderWithProvider(
<TokenCell {...props} />,
mockStore,
);
6 years ago
expect(container).toMatchSnapshot();
});
it('calls onClick when clicked', () => {
const { queryByTestId } = renderWithProvider(
<TokenCell {...props} />,
mockStore,
);
6 years ago
fireEvent.click(queryByTestId('token-button'));
6 years ago
expect(props.onClick).toHaveBeenCalled();
});
});