debian-mirror-gitlab/spec/frontend/jira_import/utils_spec.js

63 lines
1.8 KiB
JavaScript
Raw Normal View History

2020-05-24 23:13:21 +05:30
import {
calculateJiraImportLabel,
IMPORT_STATE,
isFinished,
isInProgress,
} from '~/jira_import/utils';
2020-04-22 19:07:51 +05:30
describe('isInProgress', () => {
2020-05-24 23:13:21 +05:30
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);
2020-04-22 19:07:51 +05:30
});
2020-05-24 23:13:21 +05:30
});
2020-04-22 19:07:51 +05:30
2020-05-24 23:13:21 +05:30
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);
2020-04-22 19:07:51 +05:30
});
2020-05-24 23:13:21 +05:30
});
2020-04-22 19:07:51 +05:30
2020-05-24 23:13:21 +05:30
describe('calculateJiraImportLabel', () => {
const jiraImports = [
{ jiraProjectKey: 'MTG' },
{ jiraProjectKey: 'MJP' },
{ jiraProjectKey: 'MTG' },
{ jiraProjectKey: 'MSJP' },
{ jiraProjectKey: 'MTG' },
];
2020-04-22 19:07:51 +05:30
2020-05-24 23:13:21 +05:30
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);
2020-04-22 19:07:51 +05:30
2020-05-24 23:13:21 +05:30
expect(label.title).toBe('jira-import::MTG-3');
2020-04-22 19:07:51 +05:30
});
2020-05-24 23:13:21 +05:30
it('returns a label with the correct color', () => {
const label = calculateJiraImportLabel(jiraImports, labels);
expect(label.color).toBe('#333');
2020-04-22 19:07:51 +05:30
});
});