2021-11-04 22:48:21 +01:00
|
|
|
import React from 'react';
|
|
|
|
import configureMockStore from 'redux-mock-store';
|
2022-06-30 18:19:07 +02:00
|
|
|
import { waitFor } from '@testing-library/react';
|
2021-11-04 22:48:21 +01:00
|
|
|
import { renderWithProvider } from '../../../../../test/jest/rendering';
|
|
|
|
import NetworksTabSubheader from '.';
|
|
|
|
|
|
|
|
const mockState = {
|
|
|
|
metamask: {
|
2023-05-02 17:53:20 +02:00
|
|
|
providerConfig: {
|
2021-11-04 22:48:21 +01:00
|
|
|
chainId: '0x539',
|
|
|
|
nickname: '',
|
|
|
|
rpcPrefs: {},
|
|
|
|
rpcUrl: 'http://localhost:8545',
|
|
|
|
ticker: 'ETH',
|
|
|
|
type: 'localhost',
|
|
|
|
},
|
2023-03-09 22:00:28 +01:00
|
|
|
networkConfigurations: {},
|
2021-11-04 22:48:21 +01:00
|
|
|
},
|
|
|
|
appState: {
|
|
|
|
networksTabSelectedRpcUrl: 'http://localhost:8545',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const renderComponent = (props) => {
|
|
|
|
const store = configureMockStore([])(mockState);
|
|
|
|
return renderWithProvider(<NetworksTabSubheader {...props} />, store);
|
|
|
|
};
|
|
|
|
|
|
|
|
describe('NetworksTabSubheader Component', () => {
|
|
|
|
it('should render network subheader correctly', () => {
|
|
|
|
const { queryByText, getByRole } = renderComponent({
|
|
|
|
addNewNetwork: false,
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(queryByText('Networks')).toBeInTheDocument();
|
|
|
|
expect(queryByText('Add a network')).toBeInTheDocument();
|
|
|
|
expect(getByRole('button', { text: 'Add a network' })).toBeDefined();
|
|
|
|
});
|
|
|
|
it('should render add network form subheader correctly', () => {
|
2022-06-30 18:19:07 +02:00
|
|
|
const { queryByText, getAllByText } = renderComponent({
|
2021-11-04 22:48:21 +01:00
|
|
|
addNewNetwork: true,
|
|
|
|
});
|
|
|
|
expect(queryByText('Networks')).toBeInTheDocument();
|
2022-06-30 18:19:07 +02:00
|
|
|
waitFor(() => expect(getAllByText('>')).toBeInTheDocument());
|
2021-11-04 22:48:21 +01:00
|
|
|
expect(queryByText('Add a network')).toBeInTheDocument();
|
|
|
|
});
|
|
|
|
});
|