From 9b724d1032fa25bb5cb415bb616bb1a481513843 Mon Sep 17 00:00:00 2001 From: Thomas Huang Date: Thu, 20 Apr 2023 08:36:03 -0500 Subject: [PATCH 1/2] Create New Vault test improvements (#18259) Co-authored-by: Brad Decker --- .../app/create-new-vault/create-new-vault.js | 3 + .../create-new-vault/create-new-vault.test.js | 149 +++++++++++++++++- 2 files changed, 148 insertions(+), 4 deletions(-) diff --git a/ui/components/app/create-new-vault/create-new-vault.js b/ui/components/app/create-new-vault/create-new-vault.js index 13b28eb0a957..81e9e9063c97 100644 --- a/ui/components/app/create-new-vault/create-new-vault.js +++ b/ui/components/app/create-new-vault/create-new-vault.js @@ -101,6 +101,7 @@ export default function CreateNewVault({
) : null} + +
+ + +`; + +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); + }); + }); +});