mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-29 15:50:28 +01:00
d1cea85f33
* 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
48 lines
1.5 KiB
JavaScript
48 lines
1.5 KiB
JavaScript
import React from 'react';
|
|
import configureMockStore from 'redux-mock-store';
|
|
import { waitFor } from '@testing-library/react';
|
|
import { renderWithProvider } from '../../../../../test/jest/rendering';
|
|
import NetworksTabSubheader from '.';
|
|
|
|
const mockState = {
|
|
metamask: {
|
|
providerConfig: {
|
|
chainId: '0x539',
|
|
nickname: '',
|
|
rpcPrefs: {},
|
|
rpcUrl: 'http://localhost:8545',
|
|
ticker: 'ETH',
|
|
type: 'localhost',
|
|
},
|
|
networkConfigurations: {},
|
|
},
|
|
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', () => {
|
|
const { queryByText, getAllByText } = renderComponent({
|
|
addNewNetwork: true,
|
|
});
|
|
expect(queryByText('Networks')).toBeInTheDocument();
|
|
waitFor(() => expect(getAllByText('>')).toBeInTheDocument());
|
|
expect(queryByText('Add a network')).toBeInTheDocument();
|
|
});
|
|
});
|