From 887469d73ed633ebe4dff6e62f11a944b14f42c0 Mon Sep 17 00:00:00 2001 From: mabashian Date: Tue, 4 Feb 2020 11:14:28 -0500 Subject: [PATCH] Adds test for link add/edit/delete modals --- .../Modals/LinkModals/LinkAddModal.test.jsx | 24 ++++++++ .../Modals/LinkModals/LinkDeleteModal.jsx | 2 + .../LinkModals/LinkDeleteModal.test.jsx | 60 +++++++++++++++++++ .../Modals/LinkModals/LinkEditModal.test.jsx | 32 ++++++++++ 4 files changed, 118 insertions(+) create mode 100644 awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/LinkModals/LinkAddModal.test.jsx create mode 100644 awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/LinkModals/LinkDeleteModal.test.jsx create mode 100644 awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/LinkModals/LinkEditModal.test.jsx diff --git a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/LinkModals/LinkAddModal.test.jsx b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/LinkModals/LinkAddModal.test.jsx new file mode 100644 index 0000000000..e7b5b94c40 --- /dev/null +++ b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/LinkModals/LinkAddModal.test.jsx @@ -0,0 +1,24 @@ +import React from 'react'; +import { mountWithContexts } from '@testUtils/enzymeHelpers'; +import { WorkflowDispatchContext, WorkflowStateContext } from '@contexts/Workflow'; +import LinkAddModal from './LinkAddModal'; + +const dispatch = jest.fn(); + +const workflowContext = { + linkToEdit: null +}; + +describe('LinkAddModal', () => { + test('Confirm button dispatches as expected', () => { + const wrapper = mountWithContexts( + + + + + + ); + wrapper.find('button#link-confirm').simulate('click'); + expect(dispatch).toHaveBeenCalledWith({ type: 'CREATE_LINK', linkType: 'success' }); + }); +}); diff --git a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/LinkModals/LinkDeleteModal.jsx b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/LinkModals/LinkDeleteModal.jsx index 395ac49617..d868e12083 100644 --- a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/LinkModals/LinkDeleteModal.jsx +++ b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/LinkModals/LinkDeleteModal.jsx @@ -19,6 +19,7 @@ function LinkDeleteModal({ i18n }) { onClose={() => dispatch({ type: 'SET_LINK_TO_DELETE', value: null })} actions={[ ,