2020-11-24 15:15:51 +05:30
|
|
|
import { isProjectImportable, isIncompatible, getImportStatus } from '~/import_projects/utils';
|
2020-10-24 23:57:45 +05:30
|
|
|
import { STATUSES } from '~/import_projects/constants';
|
|
|
|
|
|
|
|
describe('import_projects utils', () => {
|
2020-11-24 15:15:51 +05:30
|
|
|
const COMPATIBLE_PROJECT = {
|
|
|
|
importSource: { incompatible: false },
|
|
|
|
};
|
|
|
|
|
|
|
|
const INCOMPATIBLE_PROJECT = {
|
|
|
|
importSource: { incompatible: true },
|
|
|
|
importedProject: null,
|
|
|
|
};
|
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
describe('isProjectImportable', () => {
|
|
|
|
it.each`
|
|
|
|
status | result
|
|
|
|
${STATUSES.FINISHED} | ${false}
|
|
|
|
${STATUSES.FAILED} | ${false}
|
|
|
|
${STATUSES.SCHEDULED} | ${false}
|
|
|
|
${STATUSES.STARTED} | ${false}
|
|
|
|
${STATUSES.NONE} | ${true}
|
|
|
|
${STATUSES.SCHEDULING} | ${false}
|
|
|
|
`('returns $result when project is compatible and status is $status', ({ status, result }) => {
|
|
|
|
expect(
|
|
|
|
isProjectImportable({
|
2020-11-24 15:15:51 +05:30
|
|
|
...COMPATIBLE_PROJECT,
|
|
|
|
importedProject: { importStatus: status },
|
2020-10-24 23:57:45 +05:30
|
|
|
}),
|
|
|
|
).toBe(result);
|
|
|
|
});
|
|
|
|
|
2020-11-24 15:15:51 +05:30
|
|
|
it('returns true if import status is not defined', () => {
|
|
|
|
expect(isProjectImportable({ importSource: {} })).toBe(true);
|
|
|
|
});
|
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
it('returns false if project is not compatible', () => {
|
2020-11-24 15:15:51 +05:30
|
|
|
expect(isProjectImportable(INCOMPATIBLE_PROJECT)).toBe(false);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('isIncompatible', () => {
|
|
|
|
it('returns true for incompatible project', () => {
|
|
|
|
expect(isIncompatible(INCOMPATIBLE_PROJECT)).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('returns false for compatible project', () => {
|
|
|
|
expect(isIncompatible(COMPATIBLE_PROJECT)).toBe(false);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('getImportStatus', () => {
|
|
|
|
it('returns actual status when project status is provided', () => {
|
2020-10-24 23:57:45 +05:30
|
|
|
expect(
|
2020-11-24 15:15:51 +05:30
|
|
|
getImportStatus({
|
|
|
|
...COMPATIBLE_PROJECT,
|
|
|
|
importedProject: { importStatus: STATUSES.FINISHED },
|
2020-10-24 23:57:45 +05:30
|
|
|
}),
|
2020-11-24 15:15:51 +05:30
|
|
|
).toBe(STATUSES.FINISHED);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('returns NONE as status if import status is not provided', () => {
|
|
|
|
expect(getImportStatus(COMPATIBLE_PROJECT)).toBe(STATUSES.NONE);
|
2020-10-24 23:57:45 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|