From bb896c0b0257a9a3cc2424bd3f9b49c30bceb5dd Mon Sep 17 00:00:00 2001 From: seiwailai Date: Sun, 25 Apr 2021 01:44:35 +0800 Subject: [PATCH] ProjectSyncButton: Add tests. Add 'disable button and set onClick to undefined on sync' and 'should render tooltip on sync' --- .../Project/shared/ProjectSyncButton.test.jsx | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/awx/ui_next/src/screens/Project/shared/ProjectSyncButton.test.jsx b/awx/ui_next/src/screens/Project/shared/ProjectSyncButton.test.jsx index 9f53dfb339..dceb8d7d16 100644 --- a/awx/ui_next/src/screens/Project/shared/ProjectSyncButton.test.jsx +++ b/awx/ui_next/src/screens/Project/shared/ProjectSyncButton.test.jsx @@ -41,6 +41,32 @@ describe('ProjectSyncButton', () => { expect(ProjectsAPI.sync).toHaveBeenCalledWith(1); }); + test('disable button and set onClick to undefined on sync', async () => { + await act(async () => { + wrapper = mountWithContexts( + + {children} + + ); + }); + + expect(wrapper.find('Button').prop('isDisabled')).toBe(true); + expect(wrapper.find('Button').prop('onClick')).toBe(undefined); + }); + test('should render tooltip on sync', async () => { + await act(async () => { + wrapper = mountWithContexts( + + {children} + + ); + }); + + expect(wrapper.find('Tooltip')).toHaveLength(1); + expect(wrapper.find('Tooltip').prop('content')).toEqual( + 'This project is currently on sync and cannot be clicked until sync process completed' + ); + }); test('displays error modal after unsuccessful sync', async () => { ProjectsAPI.sync.mockRejectedValue( new Error({