1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-25 11:28:51 +01:00
metamask-extension/ui/pages/onboarding-flow/add-network-modal/add-network-modal.test.js
2023-04-20 07:00:27 -07:00

36 lines
1.1 KiB
JavaScript

import React from 'react';
import { fireEvent, waitFor } from '@testing-library/react';
import configureMockStore from 'redux-mock-store';
import thunk from 'redux-thunk';
import { renderWithProvider } from '../../../../test/lib/render-helpers';
import AddNetworkModal from '.';
const mockHideModal = jest.fn();
jest.mock('../../../store/actions', () => ({
...jest.requireActual('../../../store/actions'),
hideModal: () => mockHideModal,
}));
describe('Add Network Modal', () => {
it('should render', async () => {
const mockStore = configureMockStore()();
const { container } = renderWithProvider(<AddNetworkModal />, mockStore);
await waitFor(() => {
expect(container).toMatchSnapshot();
});
});
it('should handle callback', async () => {
const mockStore = configureMockStore([thunk])();
const { queryByText } = renderWithProvider(<AddNetworkModal />, mockStore);
const cancelButton = queryByText('Cancel');
fireEvent.click(cancelButton);
await waitFor(() => {
expect(mockHideModal).toHaveBeenCalledTimes(1);
});
});
});