1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-23 18:41:38 +01:00
metamask-extension/ui/components/app/import-token-link/import-token-link.test.js
ryanml 0bc1eeaf37
Deprecating the Rinkeby, Ropsten, and Kovan test networks (#15989)
* Deprecating Rinkeby, setting default debug network to Goerli

* Deprecating Ropsten and Kovan

* Conflict fix

* Remove unused localization, test fixes

* Add migration for moving used deprecated testnets to custom networks

* Fix migrator test

* Add more unit tests

* Migration updates provider type to rpc if deprecated network is selected

* Migration fully and correctly updates the provider if selected network is a deprecated testnet

* Continue to show deprecation warning on each of rinkeby, ropsten and kovan

* Add rpcUrl deprecation message to loading screen

* Removing mayBeFauceting prop

Co-authored-by: Dan Miller <danjm.com@gmail.com>
2022-09-28 20:26:01 -07:00

96 lines
2.2 KiB
JavaScript

import React from 'react';
import configureMockStore from 'redux-mock-store';
import { fireEvent, screen } from '@testing-library/react';
import { detectNewTokens } from '../../../store/actions';
import { renderWithProvider } from '../../../../test/lib/render-helpers';
import ImportTokenLink from '.';
const mockPushHistory = jest.fn();
jest.mock('react-router-dom', () => {
const original = jest.requireActual('react-router-dom');
return {
...original,
useLocation: jest.fn(() => ({ search: '' })),
useHistory: () => ({
push: mockPushHistory,
}),
};
});
jest.mock('../../../store/actions.js', () => ({
detectNewTokens: jest.fn(),
}));
describe('Import Token Link', () => {
it('should match snapshot for goerli chainId', () => {
const mockState = {
metamask: {
provider: {
chainId: '0x5',
},
},
};
const store = configureMockStore()(mockState);
const { container } = renderWithProvider(<ImportTokenLink />, store);
expect(container).toMatchSnapshot();
});
it('should match snapshot for mainnet chainId', () => {
const mockState = {
metamask: {
provider: {
chainId: '0x1',
},
},
};
const store = configureMockStore()(mockState);
const { container } = renderWithProvider(<ImportTokenLink />, store);
expect(container).toMatchSnapshot();
});
it('should detectNewTokens when clicking refresh', () => {
const mockState = {
metamask: {
provider: {
chainId: '0x5',
},
},
};
const store = configureMockStore()(mockState);
renderWithProvider(<ImportTokenLink />, store);
const refreshList = screen.getByTestId('refresh-list-button');
fireEvent.click(refreshList);
expect(detectNewTokens).toHaveBeenCalled();
});
it('should push import token route', () => {
const mockState = {
metamask: {
provider: {
chainId: '0x5',
},
},
};
const store = configureMockStore()(mockState);
renderWithProvider(<ImportTokenLink />, store);
const importToken = screen.getByTestId('import-token-button');
fireEvent.click(importToken);
expect(mockPushHistory).toHaveBeenCalledWith('/import-token');
});
});