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
|
import { sortFindingsByFile } from '~/diffs/utils/sort_findings_by_file';
describe('sort_findings_by_file utilities', () => {
const mockDescription = 'mockDescription';
const mockSeverity = 'mockseverity';
const mockLine = '00';
const mockFile1 = 'file1.js';
const mockFile2 = 'file2.rb';
const emptyResponse = {
files: {},
};
const unsortedFindings = [
{
severity: mockSeverity,
filePath: mockFile1,
line: mockLine,
description: mockDescription,
},
{
severity: mockSeverity,
filePath: mockFile2,
line: mockLine,
description: mockDescription,
},
];
const sortedFindings = {
files: {
[mockFile1]: [
{
line: mockLine,
description: mockDescription,
severity: mockSeverity,
},
],
[mockFile2]: [
{
line: mockLine,
description: mockDescription,
severity: mockSeverity,
},
],
},
};
it('sorts Findings correctly', () => {
expect(sortFindingsByFile(unsortedFindings)).toEqual(sortedFindings);
});
it('does not throw error when given no input', () => {
expect(sortFindingsByFile()).toEqual(emptyResponse);
});
});
|