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
|
import { STATUSES } from '~/import_entities/constants';
import { isFinished, isAvailableForImport } from '~/import_entities/import_groups/utils';
const FINISHED_STATUSES = [STATUSES.FINISHED, STATUSES.FAILED, STATUSES.TIMEOUT];
const OTHER_STATUSES = Object.values(STATUSES).filter(
(status) => !FINISHED_STATUSES.includes(status),
);
describe('Direct transfer status utils', () => {
describe('isFinished', () => {
it.each(FINISHED_STATUSES.map((s) => [s]))(
'reports group as finished when import status is %s',
(status) => {
expect(isFinished({ progress: { status } })).toBe(true);
},
);
it.each(OTHER_STATUSES.map((s) => [s]))(
'does not report group as finished when import status is %s',
(status) => {
expect(isFinished({ progress: { status } })).toBe(false);
},
);
it('does not report group as finished when there is no progress', () => {
expect(isFinished({ progress: null })).toBe(false);
});
it('does not report group as finished when status is unknown', () => {
expect(isFinished({ progress: { status: 'weird' } })).toBe(false);
});
});
describe('isAvailableForImport', () => {
it.each(FINISHED_STATUSES.map((s) => [s]))(
'reports group as available for import when status is %s',
(status) => {
expect(isAvailableForImport({ progress: { status } })).toBe(true);
},
);
it.each(OTHER_STATUSES.map((s) => [s]))(
'does not report group as not available for import when status is %s',
(status) => {
expect(isAvailableForImport({ progress: { status } })).toBe(false);
},
);
it('reports group as available for import when there is no progress', () => {
expect(isAvailableForImport({ progress: null })).toBe(true);
});
it('reports group as finished when status is unknown', () => {
expect(isFinished({ progress: { status: 'weird' } })).toBe(false);
});
});
});
|