1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 19:26:13 +02:00
metamask-extension/ui/components/app/add-network/add-network.test.js
Filip Sekulic 43f7a44c25
Adding popular custom network integration (#14557)
* Initial push

* Refactored the code

* Additional code

* Removed the unused message

* Added a tooltip

* Fixed tests

* Lint fix

* Added style to a tooltip

* Fix e2e test failure

* Lint fix and code revert

* Fix e2e test

* Fixed paddings

* Fixed paddings

* CSS fix

* Minified svg files

* Applied requested changes

* Fixed theme issue

* Code revert

* Added back overridden code

* Icon problem fixed

* Lint fix

* Replaced H3 with H4

* Added unit test

* Added breadcrumbs

* Added const props for networks

* Lint fix

* Lint fix

* Added toggle button for showing the custom network list and resolved few issues

* Fixed routes

* Refactored a piece of code

* Enabled searching for the newly created option

* Fixed unit test

* Updated theme
2022-06-30 13:49:07 -02:30

61 lines
1.6 KiB
JavaScript

import React from 'react';
import { screen } from '@testing-library/react';
import { renderWithProvider } from '../../../../test/jest';
import configureStore from '../../../store/store';
import mockState from '../../../../test/data/mock-state.json';
import AddNetwork from './add-network';
jest.mock('../../../selectors', () => ({
getFrequentRpcListDetail: () => ({
frequentRpcList: [
{
chainId: '0x539',
nickname: 'Localhost 8545',
rpcPrefs: {},
rpcUrl: 'http://localhost:8545',
ticker: 'ETH',
},
{
chainId: '0xA4B1',
nickname: 'Arbitrum One',
rpcPrefs: { blockExplorerUrl: 'https://explorer.arbitrum.io' },
rpcUrl:
'https://arbitrum-mainnet.infura.io/v3/7e127583378c4732a858df2550aff333',
ticker: 'AETH',
},
],
}),
getUnapprovedConfirmations: jest.fn(),
getTheme: () => 'light',
}));
const render = () => {
const store = configureStore({
metamask: {
...mockState.metamask,
},
});
return renderWithProvider(<AddNetwork />, store);
};
describe('AddNetwork', () => {
it('should show Add from a list.. text', () => {
render();
expect(
screen.getByText(
'Add from a list of popular networks or add a network manually. Only interact with the entities you trust.',
),
).toBeInTheDocument();
});
it('should show Popular custom networks text', () => {
render();
expect(screen.getByText('Popular custom networks')).toBeInTheDocument();
});
it('should show Arbitrum One network nickname', () => {
render();
expect(screen.getByText('Arbitrum One')).toBeInTheDocument();
});
});