mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-23 02:10:12 +01:00
eb51460cae
* UX: Multichain: App header * Export app header, provide required information, put feature flag in place * Provide available data * Implement account picker -- centered and opens account popover * Remove backgrounds, use isUnlocked * Fix placement of the global menu * Show logo when unlocked * Add selector for getting current network, provide props to AvatarNetwork and PickerNetwork * Wire up the network menu to the header * fixed ui for all the screens * updated story for header * fixed import and header settings * updated lint error * fixed tests * updated header * removed test * updated snapshot test * updated network menu * updated changes * removed comment from menu bar * updated css * updated test for network list menu * updated stylesheet * updated ButtonIcon import --------- Co-authored-by: NidhiKJha <menidhikjha@gmail.com>
65 lines
2.0 KiB
JavaScript
65 lines
2.0 KiB
JavaScript
/* eslint-disable jest/require-top-level-describe */
|
|
import React from 'react';
|
|
import { fireEvent, renderWithProvider } from '../../../../test/jest';
|
|
import configureStore from '../../../store/store';
|
|
import mockState from '../../../../test/data/mock-state.json';
|
|
import {
|
|
MAINNET_DISPLAY_NAME,
|
|
SEPOLIA_DISPLAY_NAME,
|
|
} from '../../../../shared/constants/network';
|
|
import { NetworkListMenu } from '.';
|
|
|
|
const mockSetShowTestNetworks = jest.fn();
|
|
const mockSetProviderType = jest.fn();
|
|
const mockToggleNetworkMenu = jest.fn();
|
|
jest.mock('../../../store/actions.ts', () => ({
|
|
setShowTestNetworks: () => mockSetShowTestNetworks,
|
|
setProviderType: () => mockSetProviderType,
|
|
toggleNetworkMenu: () => mockToggleNetworkMenu,
|
|
}));
|
|
|
|
const render = (showTestNetworks = false) => {
|
|
const store = configureStore({
|
|
metamask: {
|
|
...mockState.metamask,
|
|
preferences: {
|
|
showTestNetworks,
|
|
},
|
|
},
|
|
});
|
|
return renderWithProvider(<NetworkListMenu onClose={jest.fn()} />, store);
|
|
};
|
|
|
|
describe('NetworkListMenu', () => {
|
|
it('displays important controls', () => {
|
|
const { getByText } = render();
|
|
|
|
expect(getByText('Add network')).toBeInTheDocument();
|
|
expect(getByText('Show test networks')).toBeInTheDocument();
|
|
});
|
|
|
|
it('renders mainnet item', () => {
|
|
const { getByText } = render();
|
|
expect(getByText(MAINNET_DISPLAY_NAME)).toBeInTheDocument();
|
|
});
|
|
|
|
it('renders test networks when it should', () => {
|
|
const { getByText } = render(true);
|
|
expect(getByText(SEPOLIA_DISPLAY_NAME)).toBeInTheDocument();
|
|
});
|
|
|
|
it('toggles showTestNetworks when toggle is clicked', () => {
|
|
const { queryAllByRole } = render();
|
|
const [testNetworkToggle] = queryAllByRole('checkbox');
|
|
fireEvent.click(testNetworkToggle);
|
|
expect(mockSetShowTestNetworks).toHaveBeenCalled();
|
|
});
|
|
|
|
it('switches networks when an item is clicked', () => {
|
|
const { getByText } = render();
|
|
fireEvent.click(getByText(MAINNET_DISPLAY_NAME));
|
|
expect(mockToggleNetworkMenu).toHaveBeenCalled();
|
|
expect(mockSetProviderType).toHaveBeenCalled();
|
|
});
|
|
});
|