1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-03 06:34:27 +01:00
metamask-extension/ui/components/app/token-cell/token-cell.test.js
Mark Stacey d1cea85f33
Rename provider to providerConfig (#18907)
* Rename `provider` to `providerConfig`

The network controller `provider` state has been renamed to
 `providerConfig`. This better reflects what this state is, and makes
this controller more closely aligned with the core network controller.

All references to the provider configuration have been updated to
prefer `providerConfig` over `provider`, to make the distinction clear
between a provider and provider config.

Closes #18902

* Add migration
2023-05-02 13:23:20 -02:30

56 lines
1.3 KiB
JavaScript

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: {},
providerConfig: {
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();
});
});