diff --git a/ui/pages/onboarding-flow/add-network-modal/__snapshots__/add-network-modal.test.js.snap b/ui/pages/onboarding-flow/add-network-modal/__snapshots__/add-network-modal.test.js.snap new file mode 100644 index 000000000000..66e85931d4f2 --- /dev/null +++ b/ui/pages/onboarding-flow/add-network-modal/__snapshots__/add-network-modal.test.js.snap @@ -0,0 +1,241 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Add Network Modal should render 1`] = ` +
+
+

+ Add custom network +

+
+
+
+ + + + +
+ A malicious network provider can lie about the state of the blockchain and record your network activity. Only add custom networks you trust. +
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+`; + +exports[`Add Network Modal should render 2`] = `
`; diff --git a/ui/pages/onboarding-flow/add-network-modal/add-network-modal.test.js b/ui/pages/onboarding-flow/add-network-modal/add-network-modal.test.js new file mode 100644 index 000000000000..eb2a62fb9acf --- /dev/null +++ b/ui/pages/onboarding-flow/add-network-modal/add-network-modal.test.js @@ -0,0 +1,35 @@ +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(, mockStore); + + await waitFor(() => { + expect(container).toMatchSnapshot(); + }); + }); + + it('should handle callback', async () => { + const mockStore = configureMockStore([thunk])(); + const { queryByText } = renderWithProvider(, mockStore); + + const cancelButton = queryByText('Cancel'); + fireEvent.click(cancelButton); + + await waitFor(() => { + expect(mockHideModal).toHaveBeenCalledTimes(1); + }); + }); +});