/
githubFormatter.test.js
59 lines (56 loc) · 1.29 KB
/
githubFormatter.test.js
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
'use strict';
const githubFormatter = require('../githubFormatter');
test('githubFormatter', () => {
const results = [
{
source: 'path/to/file.css',
warnings: [
{
line: 1,
column: 2,
endLine: 1,
endColumn: 5,
rule: 'foo',
severity: 'error',
text: 'Unexpected "foo" (foo)',
},
],
},
{
source: 'a.css',
warnings: [
{
line: 10,
column: 20,
rule: 'bar',
severity: 'warning',
text: 'Unexpected "bar" (bar)',
},
{
line: 20,
column: 3,
text: 'Anonymous error',
},
],
parseErrors: [
{
line: 20,
column: 1,
stylelintType: 'foo-error',
text: 'Cannot parse foo',
},
],
},
];
const returnValue = {
ruleMetadata: {
foo: { url: 'https://stylelint.io/rules/foo' },
bar: { fixable: true },
},
};
expect(githubFormatter(results, returnValue))
.toBe(`::error file=path/to/file.css,line=1,col=2,endLine=1,endColumn=5,title=Stylelint problem::Unexpected "foo" (foo) - https://stylelint.io/rules/foo
::warning file=a.css,line=10,col=20,title=Stylelint problem::Unexpected "bar" (bar) [maybe fixable]
::error file=a.css,line=20,col=1,title=Stylelint problem::Cannot parse foo (foo-error)
::error file=a.css,line=20,col=3,title=Stylelint problem::Anonymous error`);
});