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

diff_line_spec.js « components « diffs « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 501bd0757c860329279147aad4ecb5c9acdeef88 (plain)
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
59
60
61
62
63
64
65
import { shallowMount } from '@vue/test-utils';
import DiffLine from '~/diffs/components/diff_line.vue';
import InlineFindings from '~/diffs/components/inline_findings.vue';

const EXAMPLE_LINE_NUMBER = 3;
const EXAMPLE_DESCRIPTION = 'example description';
const EXAMPLE_SEVERITY = 'example severity';

const left = {
  line: {
    left: {
      codequality: [
        {
          line: EXAMPLE_LINE_NUMBER,
          description: EXAMPLE_DESCRIPTION,
          severity: EXAMPLE_SEVERITY,
        },
      ],
    },
  },
};

const right = {
  line: {
    right: {
      codequality: [
        {
          line: EXAMPLE_LINE_NUMBER,
          description: EXAMPLE_DESCRIPTION,
          severity: EXAMPLE_SEVERITY,
        },
      ],
    },
  },
};

const mockData = [right, left];

describe('DiffLine', () => {
  const createWrapper = (propsData) => {
    return shallowMount(DiffLine, { propsData });
  };

  it('should emit event when hideInlineFindings is called', () => {
    const wrapper = createWrapper(right);

    wrapper.findComponent(InlineFindings).vm.$emit('hideInlineFindings');
    expect(wrapper.emitted()).toEqual({
      hideInlineFindings: [[EXAMPLE_LINE_NUMBER]],
    });
  });

  mockData.forEach((element) => {
    it('should set correct props for InlineFindings', () => {
      const wrapper = createWrapper(element);
      expect(wrapper.findComponent(InlineFindings).props('codeQuality')).toEqual([
        {
          line: EXAMPLE_LINE_NUMBER,
          description: EXAMPLE_DESCRIPTION,
          severity: EXAMPLE_SEVERITY,
        },
      ]);
    });
  });
});