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

diff_stats_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: 9073462a51fef1940eddd5c944be1acd5e1e2f50 (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
import { shallowMount } from '@vue/test-utils';
import Icon from '~/vue_shared/components/icon.vue';
import DiffStats from '~/diffs/components/diff_stats.vue';

describe('diff_stats', () => {
  it('does not render a group if diffFileLengths is not a number', () => {
    const wrapper = shallowMount(DiffStats, {
      propsData: {
        addedLines: 1,
        removedLines: 2,
        diffFilesLength: Number.NaN,
      },
    });
    const groups = wrapper.findAll('.diff-stats-group');

    expect(groups.length).toBe(2);
  });

  it('shows amount of files changed, lines added and lines removed when passed all props', () => {
    const wrapper = shallowMount(DiffStats, {
      propsData: {
        addedLines: 100,
        removedLines: 200,
        diffFilesLength: 300,
      },
    });

    const findIcon = name =>
      wrapper
        .findAll(Icon)
        .filter(c => c.attributes('name') === name)
        .at(0).element.parentNode;

    const additions = findIcon('file-addition');
    const deletions = findIcon('file-deletion');
    const filesChanged = findIcon('doc-code');

    expect(additions.textContent).toContain('100');
    expect(deletions.textContent).toContain('200');
    expect(filesChanged.textContent).toContain('300');
  });
});