2021-11-04 22:48:21 +01:00
|
|
|
import React from 'react';
|
|
|
|
import configureMockStore from 'redux-mock-store';
|
|
|
|
import { renderWithProvider } from '../../../../test/jest/rendering';
|
|
|
|
import NetworksTab from '.';
|
|
|
|
|
|
|
|
const mockState = {
|
|
|
|
metamask: {
|
|
|
|
provider: {
|
|
|
|
chainId: '0x539',
|
|
|
|
nickname: '',
|
|
|
|
rpcPrefs: {},
|
|
|
|
rpcUrl: 'http://localhost:8545',
|
|
|
|
ticker: 'ETH',
|
|
|
|
type: 'localhost',
|
|
|
|
},
|
|
|
|
frequentRpcListDetail: [],
|
|
|
|
},
|
|
|
|
appState: {
|
|
|
|
networksTabSelectedRpcUrl: 'http://localhost:8545',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const renderComponent = (props) => {
|
|
|
|
const store = configureMockStore([])(mockState);
|
|
|
|
return renderWithProvider(<NetworksTab {...props} />, store);
|
|
|
|
};
|
|
|
|
|
|
|
|
describe('NetworksTab Component', () => {
|
|
|
|
it('should render networks tab content correctly', () => {
|
|
|
|
const { queryByText } = renderComponent({
|
|
|
|
addNewNetwork: false,
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(queryByText('Ethereum Mainnet')).toBeInTheDocument();
|
2022-08-08 21:01:38 +02:00
|
|
|
expect(queryByText('Ropsten test network')).toBeInTheDocument();
|
|
|
|
expect(queryByText('Rinkeby test network')).toBeInTheDocument();
|
|
|
|
expect(queryByText('Goerli test network')).toBeInTheDocument();
|
|
|
|
expect(queryByText('Kovan test network')).toBeInTheDocument();
|
|
|
|
expect(queryByText('Add network')).toBeInTheDocument();
|
2021-11-04 22:48:21 +01:00
|
|
|
});
|
|
|
|
it('should render add network form correctly', () => {
|
|
|
|
const { queryByText } = renderComponent({
|
|
|
|
addNewNetwork: true,
|
|
|
|
});
|
2022-08-08 21:01:38 +02:00
|
|
|
expect(queryByText('Network name')).toBeInTheDocument();
|
2021-11-04 22:48:21 +01:00
|
|
|
expect(queryByText('New RPC URL')).toBeInTheDocument();
|
|
|
|
expect(queryByText('Chain ID')).toBeInTheDocument();
|
2022-08-08 21:01:38 +02:00
|
|
|
expect(queryByText('Currency symbol')).toBeInTheDocument();
|
|
|
|
expect(queryByText('Block explorer URL')).toBeInTheDocument();
|
2021-11-04 22:48:21 +01:00
|
|
|
expect(queryByText('Cancel')).toBeInTheDocument();
|
|
|
|
expect(queryByText('Save')).toBeInTheDocument();
|
|
|
|
});
|
|
|
|
});
|