diff --git a/awx/ui_next/src/components/Sparkline/JobStatusIcon.test.jsx b/awx/ui_next/src/components/Sparkline/JobStatusIcon.test.jsx new file mode 100644 index 0000000000..914c574cc7 --- /dev/null +++ b/awx/ui_next/src/components/Sparkline/JobStatusIcon.test.jsx @@ -0,0 +1,61 @@ +import React from 'react'; +import { mount } from 'enzyme'; +import { mountWithContexts } from '../../../testUtils/enzymeHelpers'; + +import JobStatusIcon from './JobStatusIcon'; + +describe('JobStatusIcon', () => { + const job = { + id: 1, + status: 'successful' + }; + + test('renders the expected content', () => { + const wrapper = mount(); + expect(wrapper).toHaveLength(1); + expect(wrapper.find('Tooltip')).toHaveLength(0); + expect(wrapper.find('Link')).toHaveLength(0); + }); + test('renders with tooltip if tooltip passed', () => { + const wrapper = mount(); + expect(wrapper).toHaveLength(1); + expect(wrapper.find('Tooltip')).toHaveLength(1); + expect(wrapper.find('Link')).toHaveLength(0); + }); + test('renders with link if link passed', () => { + const wrapper = mountWithContexts(); + expect(wrapper).toHaveLength(1); + expect(wrapper.find('Tooltip')).toHaveLength(0); + expect(wrapper.find('Link')).toHaveLength(1); + }); + test('renders running job', () => { + const runningJob = { + id: 2, + status: 'running' + }; + const wrapper = mount(); + expect(wrapper.find('JobStatusIcon__RunningJob')).toHaveLength(1); + }); + test('renders waiting job', () => { + const waitingJob = { + id: 3, + status: 'waiting' + }; + const wrapper = mount(); + expect(wrapper.find('JobStatusIcon__WaitingJob')).toHaveLength(1); + }); + test('renders failed job', () => { + const failedJob = { + id: 4, + status: 'failed' + }; + const wrapper = mount(); + expect(wrapper.find('JobStatusIcon__FailedTop')).toHaveLength(1); + expect(wrapper.find('JobStatusIcon__FailedBottom')).toHaveLength(1); + }); + test('renders successful job', () => { + const wrapper = mount(); + expect(wrapper.find('JobStatusIcon__SuccessfulTop')).toHaveLength(1); + expect(wrapper.find('JobStatusIcon__SuccessfulBottom')).toHaveLength(1); + }); +}); \ No newline at end of file diff --git a/awx/ui_next/src/components/Sparkline/Sparkline.test.jsx b/awx/ui_next/src/components/Sparkline/Sparkline.test.jsx new file mode 100644 index 0000000000..6417acd7d2 --- /dev/null +++ b/awx/ui_next/src/components/Sparkline/Sparkline.test.jsx @@ -0,0 +1,25 @@ +import React from 'react'; +import { mount } from 'enzyme'; +import { mountWithContexts } from '../../../testUtils/enzymeHelpers'; + +import Sparkline from './Sparkline'; + +describe('Sparkline', () => { + test('renders the expected content', () => { + const wrapper = mount(); + expect(wrapper).toHaveLength(1); + }); + test('renders an icon for each job', () => { + const jobs = [ + { + id: 1, + status: 'successful' + }, { + id: 2, + status: 'failed' + } + ] + const wrapper = mountWithContexts(); + expect(wrapper.find('JobStatusIcon')).toHaveLength(2); + }); +});