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

review_tab_container_spec.js « components « add_context_commits_modal « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f679576182f8a4c52ee17d5e89660979eeba3e69 (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
import { GlLoadingIcon } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import getDiffWithCommit from 'test_fixtures/merge_request_diffs/with_commit.json';
import ReviewTabContainer from '~/add_context_commits_modal/components/review_tab_container.vue';
import CommitItem from '~/diffs/components/commit_item.vue';

describe('ReviewTabContainer', () => {
  let wrapper;
  const { commit } = getDiffWithCommit;

  const createWrapper = (props = {}) => {
    wrapper = shallowMount(ReviewTabContainer, {
      propsData: {
        tab: 'commits',
        isLoading: false,
        loadingError: false,
        loadingFailedText: 'Failed to load commits',
        commits: [],
        selectedRow: [],
        ...props,
      },
    });
  };

  beforeEach(() => {
    createWrapper();
  });

  afterEach(() => {
    wrapper.destroy();
  });

  it('shows loading icon when commits are being loaded', () => {
    createWrapper({ isLoading: true });
    expect(wrapper.findComponent(GlLoadingIcon).exists()).toBe(true);
  });

  it('shows loading error text when API call fails', () => {
    createWrapper({ loadingError: true });
    expect(wrapper.text()).toContain('Failed to load commits');
  });

  it('shows "No commits present here" when commits are not present', () => {
    expect(wrapper.text()).toContain('No commits present here');
  });

  it('renders all passed commits as list', () => {
    createWrapper({ commits: [commit] });
    expect(wrapper.findAllComponents(CommitItem).length).toBe(1);
  });
});