1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { GlLink } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import DependencyVulnerability from 'ee/dependencies/components/dependency_vulnerability.vue';
import SeverityBadge from 'ee/vue_shared/security_reports/components/severity_badge.vue';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import mockDataVulnerabilities from 'ee_jest/security_dashboard/store/modules/vulnerabilities/data/mock_data_vulnerabilities';
describe('DependencyVulnerability component', () => {
let wrapper;
const findLink = () => wrapper.findComponent(GlLink);
const factory = ({ propsData, ...options } = {}, standaloneVulnDependencyList = false) => {
wrapper = extendedWrapper(
shallowMount(DependencyVulnerability, {
...options,
propsData: { ...propsData },
provide: {
glFeatures: {
standaloneVulnDependencyList,
},
},
}),
);
};
afterEach(() => {
wrapper.destroy();
});
describe('given an vulnerability', () => {
const vulnerability = mockDataVulnerabilities[0];
beforeEach(() => {
factory({
propsData: {
vulnerability,
},
});
});
it('matches the snapshot', () => {
expect(wrapper.element).toMatchSnapshot();
});
it('renders the severity badge with the correct props', () => {
const badge = wrapper.find(SeverityBadge);
expect(badge.isVisible()).toBe(true);
expect(badge.props().severity).toEqual(vulnerability.severity);
});
it('renders the vulnerability name as a Link', () => {
const link = findLink();
expect(link.exists()).toBe(true);
expect(link.element.getAttribute('href')).toBe(
'/testgroup/testproject/-/security/vulnerabilities/1',
);
});
});
});