From 51b18aa012e54a14a32606cd1dfb80da89d432f2 Mon Sep 17 00:00:00 2001 From: nixocio Date: Tue, 8 Dec 2020 13:43:24 -0500 Subject: [PATCH] Fix JobEvent tests Fix JobEvent tests --- .../screens/Job/JobOutput/JobEvent.test.jsx | 62 ++++++++++++++++--- 1 file changed, 52 insertions(+), 10 deletions(-) diff --git a/awx/ui_next/src/screens/Job/JobOutput/JobEvent.test.jsx b/awx/ui_next/src/screens/Job/JobOutput/JobEvent.test.jsx index baceb1c6f4..e76ae0a3ac 100644 --- a/awx/ui_next/src/screens/Job/JobOutput/JobEvent.test.jsx +++ b/awx/ui_next/src/screens/Job/JobOutput/JobEvent.test.jsx @@ -1,6 +1,5 @@ import React from 'react'; import { mountWithContexts } from '../../../../testUtils/enzymeHelpers'; - import JobEvent from './JobEvent'; const mockOnPlayStartEvent = { @@ -24,23 +23,64 @@ const selectors = { lineText: 'JobEventLineText', }; +const singleDigitTimestampEvent = { + ...mockOnPlayStartEvent, + created: '2019-07-11T08:01:02.906001Z', +}; + +const mockSingleDigitTimestampEventLineTextHtml = [ + { lineNumber: 0, html: '' }, + { + lineNumber: 1, + html: + 'PLAY [add hosts to inventory] **************************************************08:01:02', + }, +]; + +const mockAnsiLineTextHtml = [ + { + lineNumber: 4, + html: 'ok: [localhost]', + }, +]; + +const mockOnPlayStartLineTextHtml = [ + { lineNumber: 0, html: '' }, + { + lineNumber: 1, + html: + 'PLAY [add hosts to inventory] **************************************************18:11:22', + }, +]; + describe('', () => { test('initially renders successfully', () => { - mountWithContexts(); + mountWithContexts( + + ); }); test('playbook event timestamps are rendered', () => { - let wrapper = mountWithContexts(); + let wrapper = mountWithContexts( + + ); let lineText = wrapper.find(selectors.lineText); expect( lineText.filterWhere(e => e.text().includes('18:11:22')) ).toHaveLength(1); - const singleDigitTimestampEvent = { - ...mockOnPlayStartEvent, - created: '2019-07-11T08:01:02.906001Z', - }; - wrapper = mountWithContexts(); + wrapper = mountWithContexts( + + ); lineText = wrapper.find(selectors.lineText); expect( lineText.filterWhere(e => e.text().includes('08:01:02')) @@ -48,12 +88,14 @@ describe('', () => { }); test('ansi stdout colors are rendered as html', () => { - const wrapper = mountWithContexts(); + const wrapper = mountWithContexts( + + ); const lineText = wrapper.find(selectors.lineText); expect( lineText .html() - .includes('ok: [localhost]') + .includes('ok: [localhost]') ).toBe(true); });