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

import_source_cell_spec.js « components « import_groups « import_entities « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f2735d864939b51a51cf1e30d05125b6cc13d2ea (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
66
67
68
import { GlLink, GlSprintf } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import { STATUSES } from '~/import_entities/constants';
import ImportSourceCell from '~/import_entities/import_groups/components/import_source_cell.vue';
import { generateFakeEntry } from '../graphql/fixtures';

const generateFakeTableEntry = ({ flags = {}, ...entry }) => ({
  ...generateFakeEntry(entry),
  flags,
});

describe('import source cell', () => {
  let wrapper;
  let group;

  const createComponent = (props) => {
    wrapper = shallowMount(ImportSourceCell, {
      propsData: {
        ...props,
      },
      stubs: { GlSprintf },
    });
  };

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

  describe('when group status is NONE', () => {
    beforeEach(() => {
      group = generateFakeTableEntry({ id: 1, status: STATUSES.NONE });
      createComponent({ group });
    });

    it('renders link to a group', () => {
      const link = wrapper.findComponent(GlLink);
      expect(link.attributes().href).toBe(group.webUrl);
      expect(link.text()).toContain(group.fullPath);
    });

    it('does not render last imported line', () => {
      expect(wrapper.text()).not.toContain('Last imported to');
    });
  });

  describe('when group status is FINISHED', () => {
    beforeEach(() => {
      group = generateFakeTableEntry({
        id: 1,
        status: STATUSES.FINISHED,
        flags: {
          isFinished: true,
        },
      });
      createComponent({ group });
    });

    it('renders link to a group', () => {
      const link = wrapper.findComponent(GlLink);
      expect(link.attributes().href).toBe(group.webUrl);
      expect(link.text()).toContain(group.fullPath);
    });

    it('renders last imported line', () => {
      expect(wrapper.text()).toMatchInterpolatedText('fake_group_1 Last imported to root/group1');
    });
  });
});