summaryrefslogtreecommitdiff
path: root/spec/frontend/ide/components/commit_sidebar/list_spec.js
blob: 81c81fc0a9f175834eb6841a9b2fce046a9ffd48 (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
import { shallowMount } from '@vue/test-utils';
import CommitSidebarList from '~/ide/components/commit_sidebar/list.vue';
import ListItem from '~/ide/components/commit_sidebar/list_item.vue';
import { file } from '../../helpers';

describe('Multi-file editor commit sidebar list', () => {
  let wrapper;

  const mountComponent = ({ fileList }) =>
    shallowMount(CommitSidebarList, {
      propsData: {
        title: 'Staged',
        fileList,
        action: 'stageAllChanges',
        actionBtnText: 'stage all',
        actionBtnIcon: 'history',
        activeFileKey: 'staged-testing',
        keyPrefix: 'staged',
      },
    });

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

  describe('with a list of files', () => {
    beforeEach(async () => {
      const f = file('file name');
      f.changed = true;
      wrapper = mountComponent({ fileList: [f] });
    });

    it('renders list', () => {
      expect(wrapper.findAllComponents(ListItem)).toHaveLength(1);
    });
  });

  describe('with empty files array', () => {
    beforeEach(() => {
      wrapper = mountComponent({ fileList: [] });
    });

    it('renders no changes text ', () => {
      expect(wrapper.text()).toContain('No changes');
    });
  });
});