Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/ci/reports/components/report_link_spec.js')
-rw-r--r--spec/frontend/ci/reports/components/report_link_spec.js56
1 files changed, 56 insertions, 0 deletions
diff --git a/spec/frontend/ci/reports/components/report_link_spec.js b/spec/frontend/ci/reports/components/report_link_spec.js
new file mode 100644
index 00000000000..ba541ba0303
--- /dev/null
+++ b/spec/frontend/ci/reports/components/report_link_spec.js
@@ -0,0 +1,56 @@
+import { shallowMount } from '@vue/test-utils';
+import ReportLink from '~/ci/reports/components/report_link.vue';
+
+describe('app/assets/javascripts/ci/reports/components/report_link.vue', () => {
+ let wrapper;
+
+ afterEach(() => {
+ wrapper.destroy();
+ });
+
+ const defaultProps = {
+ issue: {},
+ };
+
+ const createComponent = (props = {}) => {
+ wrapper = shallowMount(ReportLink, {
+ propsData: { ...defaultProps, ...props },
+ });
+ };
+
+ describe('When an issue prop has a $urlPath property', () => {
+ it('render a link that will take the user to the $urlPath', () => {
+ createComponent({ issue: { path: 'Gemfile.lock', urlPath: '/Gemfile.lock' } });
+
+ expect(wrapper.text()).toContain('in');
+ expect(wrapper.find('a').attributes('href')).toBe('/Gemfile.lock');
+ expect(wrapper.find('a').text()).toContain('Gemfile.lock');
+ });
+ });
+
+ describe('When an issue prop has no $urlPath property', () => {
+ it('does not render link', () => {
+ createComponent({ issue: { path: 'Gemfile.lock' } });
+
+ expect(wrapper.find('a').exists()).toBe(false);
+ expect(wrapper.text()).toContain('in');
+ expect(wrapper.text()).toContain('Gemfile.lock');
+ });
+ });
+
+ describe('When an issue prop has a $line property', () => {
+ it('render a line number', () => {
+ createComponent({ issue: { path: 'Gemfile.lock', urlPath: '/Gemfile.lock', line: 22 } });
+
+ expect(wrapper.find('a').text()).toContain('Gemfile.lock:22');
+ });
+ });
+
+ describe('When an issue prop does not have a $line property', () => {
+ it('does not render a line number', () => {
+ createComponent({ issue: { urlPath: '/Gemfile.lock' } });
+
+ expect(wrapper.find('a').text()).not.toContain(':22');
+ });
+ });
+});