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

utils_spec.js « jira_import « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0b1edd6550a867d3089634b8733d01dcd9c3e164 (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
import {
  calculateJiraImportLabel,
  IMPORT_STATE,
  isFinished,
  isInProgress,
} from '~/jira_import/utils';

describe('isInProgress', () => {
  it.each`
    state                     | result
    ${IMPORT_STATE.SCHEDULED} | ${true}
    ${IMPORT_STATE.STARTED}   | ${true}
    ${IMPORT_STATE.FAILED}    | ${false}
    ${IMPORT_STATE.FINISHED}  | ${false}
    ${IMPORT_STATE.NONE}      | ${false}
    ${undefined}              | ${false}
  `('returns $result when state is $state', ({ state, result }) => {
    expect(isInProgress(state)).toBe(result);
  });
});

describe('isFinished', () => {
  it.each`
    state                     | result
    ${IMPORT_STATE.SCHEDULED} | ${false}
    ${IMPORT_STATE.STARTED}   | ${false}
    ${IMPORT_STATE.FAILED}    | ${false}
    ${IMPORT_STATE.FINISHED}  | ${true}
    ${IMPORT_STATE.NONE}      | ${false}
    ${undefined}              | ${false}
  `('returns $result when state is $state', ({ state, result }) => {
    expect(isFinished(state)).toBe(result);
  });
});

describe('calculateJiraImportLabel', () => {
  const jiraImports = [
    { jiraProjectKey: 'MTG' },
    { jiraProjectKey: 'MJP' },
    { jiraProjectKey: 'MTG' },
    { jiraProjectKey: 'MSJP' },
    { jiraProjectKey: 'MTG' },
  ];

  const labels = [
    { color: '#111', title: 'jira-import::MTG-1' },
    { color: '#222', title: 'jira-import::MTG-2' },
    { color: '#333', title: 'jira-import::MTG-3' },
  ];

  it('returns a label with the Jira project key and correct import count in the title', () => {
    const label = calculateJiraImportLabel(jiraImports, labels);

    expect(label.title).toBe('jira-import::MTG-3');
  });

  it('returns a label with the correct color', () => {
    const label = calculateJiraImportLabel(jiraImports, labels);

    expect(label.color).toBe('#333');
  });
});