-
-
Notifications
You must be signed in to change notification settings - Fork 237
/
EsLintIssueFactory.spec.ts
77 lines (74 loc) · 1.96 KB
/
EsLintIssueFactory.spec.ts
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import { createIssuesFromEsLintReports } from '../../../../lib/issue';
import {
LintMessage,
LintReport,
LintResult
} from '../../../../lib/types/eslint';
describe('[UNIT] issue/eslint/EsLintIssueFactory', () => {
const ES_LINT_MESSAGE_ERROR: LintMessage = {
column: 0,
line: 13,
endColumn: 5,
endLine: 13,
ruleId: 'no-unused-vars',
message: `'y' is assigned a value but never used.`,
nodeType: '',
severity: 0,
source: null
};
const ES_LINT_MESSAGE_WARNING: LintMessage = {
column: 10,
line: 15,
ruleId: 'no-unused-vars',
message: `'y' is assigned a value but never used.`,
nodeType: '',
severity: 1,
source: null
};
const ES_LINT_RESULT_INDEX: LintResult = {
filePath: 'src/index.ts',
messages: [ES_LINT_MESSAGE_ERROR],
errorCount: 1,
warningCount: 0,
fixableErrorCount: 0,
fixableWarningCount: 0
};
const ES_LINT_RESULT_ANOTHER: LintResult = {
filePath: 'src/another.ts',
messages: [ES_LINT_MESSAGE_WARNING],
errorCount: 0,
warningCount: 1,
fixableErrorCount: 0,
fixableWarningCount: 0
};
const ES_LINT_RESULT_ADDITIONAL: LintResult = {
filePath: 'src/additional.ts',
messages: [ES_LINT_MESSAGE_ERROR],
errorCount: 1,
warningCount: 0,
fixableErrorCount: 0,
fixableWarningCount: 0
};
const ES_LINT_REPORT_A: LintReport = {
results: [ES_LINT_RESULT_INDEX, ES_LINT_RESULT_ANOTHER],
errorCount: 1,
warningCount: 1,
fixableErrorCount: 0,
fixableWarningCount: 0
};
const ES_LINT_REPORT_B: LintReport = {
results: [ES_LINT_RESULT_ADDITIONAL],
errorCount: 1,
warningCount: 1,
fixableErrorCount: 0,
fixableWarningCount: 0
};
const ES_LINT_REPORTS = [ES_LINT_REPORT_A, ES_LINT_REPORT_B];
it.each([[ES_LINT_REPORTS]])(
'creates Issues from EsLint Reports: %p',
reports => {
const issues = createIssuesFromEsLintReports(reports);
expect(issues).toMatchSnapshot();
}
);
});