summaryrefslogtreecommitdiff
path: root/spec/frontend/import_projects/components/imported_project_table_row_spec.js
blob: 8890c352826f554cbf39d83b5b2aaefa806010ce (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
import { mount } from '@vue/test-utils';
import ImportedProjectTableRow from '~/import_projects/components/imported_project_table_row.vue';
import ImportStatus from '~/import_projects/components/import_status.vue';
import { STATUSES } from '~/import_projects/constants';

describe('ImportedProjectTableRow', () => {
  let wrapper;
  const project = {
    importSource: {
      fullName: 'fullName',
      providerLink: 'providerLink',
    },
    importedProject: {
      id: 1,
      fullPath: 'fullPath',
      importSource: 'importSource',
    },
    importStatus: STATUSES.FINISHED,
  };

  function mountComponent() {
    wrapper = mount(ImportedProjectTableRow, { propsData: { project } });
  }

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

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

  it('renders an imported project table row', () => {
    const providerLink = wrapper.find('[data-testid=providerLink]');

    expect(providerLink.attributes().href).toMatch(project.importSource.providerLink);
    expect(providerLink.text()).toMatch(project.importSource.fullName);
    expect(wrapper.find('[data-testid=fullPath]').text()).toMatch(project.importedProject.fullPath);
    expect(wrapper.find(ImportStatus).props().status).toBe(project.importStatus);
    expect(wrapper.find('[data-testid=goToProject').attributes().href).toMatch(
      project.importedProject.fullPath,
    );
  });
});