mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-01 21:57:06 +01:00
36 lines
1.1 KiB
JavaScript
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);
|
||
|
});
|
||
|
});
|
||
|
});
|