Commit c384c077 authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch...

Merge branch 'migrate_ee_spec_javascripts_vue_mr_widget_components_codequality_issue_body_spec' into 'master'

Migrate ee codequality_issue_body_spec to Jest

See merge request gitlab-org/gitlab!30578
parents 455cc6d2 4185d9bd
import Vue from 'vue'; import { shallowMount } from '@vue/test-utils';
import component from 'ee/vue_merge_request_widget/components/codequality_issue_body.vue'; import component from 'ee/vue_merge_request_widget/components/codequality_issue_body.vue';
import mountComponent from 'spec/helpers/vue_mount_component_helper';
import { STATUS_FAILED, STATUS_NEUTRAL, STATUS_SUCCESS } from '~/reports/constants'; import { STATUS_FAILED, STATUS_NEUTRAL, STATUS_SUCCESS } from '~/reports/constants';
describe('code quality issue body issue body', () => { describe('code quality issue body issue body', () => {
let vm; let wrapper;
const Component = Vue.extend(component);
const codequalityIssue = { const codequalityIssue = {
name: name:
'rubygem-rest-client: session fixation vulnerability via Set-Cookie headers in 30x redirection responses', 'rubygem-rest-client: session fixation vulnerability via Set-Cookie headers in 30x redirection responses',
...@@ -15,52 +13,50 @@ describe('code quality issue body issue body', () => { ...@@ -15,52 +13,50 @@ describe('code quality issue body issue body', () => {
type: 'Issue', type: 'Issue',
urlPath: '/Gemfile.lock#L22', urlPath: '/Gemfile.lock#L22',
}; };
const mountWithStatus = initialStatus => {
wrapper = shallowMount(component, {
propsData: {
issue: codequalityIssue,
status: initialStatus,
},
});
};
afterEach(() => { afterEach(() => {
vm.$destroy(); wrapper.destroy();
wrapper = null;
}); });
describe('with success', () => { describe('with success', () => {
it('renders fixed label', () => { it('renders fixed label', () => {
vm = mountComponent(Component, { mountWithStatus(STATUS_SUCCESS);
issue: codequalityIssue,
status: STATUS_SUCCESS,
});
expect(vm.$el.textContent.trim()).toContain('Fixed'); expect(wrapper.text()).toContain('Fixed');
}); });
}); });
describe('without success', () => { describe('without success', () => {
it('renders fixed label', () => { it('renders fixed label', () => {
vm = mountComponent(Component, { mountWithStatus(STATUS_FAILED);
issue: codequalityIssue,
status: STATUS_FAILED,
});
expect(vm.$el.textContent.trim()).not.toContain('Fixed'); expect(wrapper.text()).not.toContain('Fixed');
}); });
}); });
describe('name', () => { describe('name', () => {
it('renders name', () => { it('renders name', () => {
vm = mountComponent(Component, { mountWithStatus(STATUS_NEUTRAL);
issue: codequalityIssue,
status: STATUS_NEUTRAL,
});
expect(vm.$el.textContent.trim()).toContain(codequalityIssue.name); expect(wrapper.text()).toContain(codequalityIssue.name);
}); });
}); });
describe('path', () => { describe('path', () => {
it('renders name', () => { it('renders the report-link path using the correct code quality issue', () => {
vm = mountComponent(Component, { mountWithStatus(STATUS_NEUTRAL);
issue: codequalityIssue,
status: STATUS_NEUTRAL,
});
expect(vm.$el.querySelector('a').getAttribute('href')).toEqual(codequalityIssue.urlPath); expect(wrapper.find('report-link-stub').props('issue')).toBe(codequalityIssue);
expect(vm.$el.querySelector('a').textContent.trim()).toEqual(codequalityIssue.path);
}); });
}); });
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment