From f45dd7a748229346ac3b7353ef1025319f10c137 Mon Sep 17 00:00:00 2001 From: nixocio Date: Tue, 5 Oct 2021 11:16:06 -0400 Subject: [PATCH] Update unit-tests Update unit-tests mocked values, as attempt to mitigate CI failures. --- .../NotificationTemplateListItem.test.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/awx/ui/src/screens/NotificationTemplate/NotificationTemplateList/NotificationTemplateListItem.test.js b/awx/ui/src/screens/NotificationTemplate/NotificationTemplateList/NotificationTemplateListItem.test.js index 660d974d5f..eba9049bf2 100644 --- a/awx/ui/src/screens/NotificationTemplate/NotificationTemplateList/NotificationTemplateListItem.test.js +++ b/awx/ui/src/screens/NotificationTemplate/NotificationTemplateList/NotificationTemplateListItem.test.js @@ -69,7 +69,7 @@ describe('', () => { }); test('should call api to copy inventory', async () => { - NotificationTemplatesAPI.copy.mockResolvedValue(); + NotificationTemplatesAPI.copy.mockResolvedValue({ name: 'Foo' }); const wrapper = mountWithContexts( @@ -91,7 +91,18 @@ describe('', () => { }); test('should render proper alert modal on copy error', async () => { - NotificationTemplatesAPI.copy.mockRejectedValue(new Error()); + NotificationTemplatesAPI.copy.mockRejectedValue( + new Error({ + response: { + config: { + method: 'post', + url: '/api/v2/notification_templates/3/copy', + }, + data: 'An error ocurred', + status: 403, + }, + }) + ); const wrapper = mountWithContexts(
@@ -104,10 +115,12 @@ describe('', () => {
); + expect(wrapper.find('Modal').length).toBe(0); await act(async () => wrapper.find('Button[aria-label="Copy"]').prop('onClick')() ); wrapper.update(); + expect(wrapper.find('Modal').length).toBe(1); expect(wrapper.find('Modal').prop('isOpen')).toBe(true); jest.clearAllMocks(); });