diff options
Diffstat (limited to 'spec/frontend/reports/codequality_report/components/codequality_issue_body_spec.js')
-rw-r--r-- | spec/frontend/reports/codequality_report/components/codequality_issue_body_spec.js | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/spec/frontend/reports/codequality_report/components/codequality_issue_body_spec.js b/spec/frontend/reports/codequality_report/components/codequality_issue_body_spec.js new file mode 100644 index 00000000000..3e11af9c9df --- /dev/null +++ b/spec/frontend/reports/codequality_report/components/codequality_issue_body_spec.js @@ -0,0 +1,62 @@ +import { shallowMount } from '@vue/test-utils'; +import component from '~/reports/codequality_report/components/codequality_issue_body.vue'; +import { STATUS_FAILED, STATUS_NEUTRAL, STATUS_SUCCESS } from '~/reports/constants'; + +describe('code quality issue body issue body', () => { + let wrapper; + + const codequalityIssue = { + name: + 'rubygem-rest-client: session fixation vulnerability via Set-Cookie headers in 30x redirection responses', + path: 'Gemfile.lock', + severity: 'normal', + type: 'Issue', + urlPath: '/Gemfile.lock#L22', + }; + + const mountWithStatus = initialStatus => { + wrapper = shallowMount(component, { + propsData: { + issue: codequalityIssue, + status: initialStatus, + }, + }); + }; + + afterEach(() => { + wrapper.destroy(); + wrapper = null; + }); + + describe('with success', () => { + it('renders fixed label', () => { + mountWithStatus(STATUS_SUCCESS); + + expect(wrapper.text()).toContain('Fixed'); + }); + }); + + describe('without success', () => { + it('renders fixed label', () => { + mountWithStatus(STATUS_FAILED); + + expect(wrapper.text()).not.toContain('Fixed'); + }); + }); + + describe('name', () => { + it('renders name', () => { + mountWithStatus(STATUS_NEUTRAL); + + expect(wrapper.text()).toContain(codequalityIssue.name); + }); + }); + + describe('path', () => { + it('renders the report-link path using the correct code quality issue', () => { + mountWithStatus(STATUS_NEUTRAL); + + expect(wrapper.find('report-link-stub').props('issue')).toBe(codequalityIssue); + }); + }); +}); |