Skip to content

Commit 91b2ca0

Browse files
committed
Add tests
1 parent 08fde17 commit 91b2ca0

12 files changed

+562
-88
lines changed

test/__snapshots__/cli.spec.js.snap

+94-56
Original file line numberDiff line numberDiff line change
@@ -1,123 +1,161 @@
11
// Bun Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`prettier-formatter-gitlab cli should create a code quality report file 1`] = `
4-
"[
3+
exports[`prettier-formatter-gitlab cli should create a code quality report file with prettier -l 1`] = `
4+
[
55
{
6-
"type": "issue",
76
"check_name": "prettier",
87
"description": "Replace ·arg·· with arg",
9-
"severity": "minor",
108
"fingerprint": "ea70e2ae0144c16efa5df45bf52a33de",
119
"location": {
12-
"path": "test/__stubs__/dirty-2.js",
1310
"lines": {
1411
"begin": 3,
15-
"end": 3
16-
}
17-
}
12+
"end": 3,
13+
},
14+
"path": "test/__stubs__/dirty-2.js",
15+
},
16+
"severity": "minor",
17+
"type": "issue",
1818
},
1919
{
20-
"type": "issue",
2120
"check_name": "prettier",
2221
"description": "Insert ;",
23-
"severity": "minor",
2422
"fingerprint": "d88816112daed6a61fd9d81e964a484b",
2523
"location": {
26-
"path": "test/__stubs__/dirty-2.js",
2724
"lines": {
2825
"begin": 5,
29-
"end": 5
30-
}
31-
}
26+
"end": 5,
27+
},
28+
"path": "test/__stubs__/dirty-2.js",
29+
},
30+
"severity": "minor",
31+
"type": "issue",
3232
},
3333
{
34-
"type": "issue",
3534
"check_name": "prettier",
3635
"description": "Replace ⏎⏎⏎⏎⏎⏎function·foo(·arg··)·{⏎⏎ with function·foo(arg)·{",
37-
"severity": "minor",
3836
"fingerprint": "c38522eb22f56c446d6b78774d940d24",
3937
"location": {
40-
"path": "test/__stubs__/dirty.js",
4138
"lines": {
4239
"begin": 3,
43-
"end": 11
44-
}
45-
}
40+
"end": 11,
41+
},
42+
"path": "test/__stubs__/dirty.js",
43+
},
44+
"severity": "minor",
45+
"type": "issue",
4646
},
4747
{
48-
"type": "issue",
4948
"check_name": "prettier",
5049
"description": "Delete ⏎⏎⏎",
51-
"severity": "minor",
5250
"fingerprint": "f312c866f5c2332c733d2de24b9efa0f",
5351
"location": {
54-
"path": "test/__stubs__/dirty.js",
5552
"lines": {
5653
"begin": 12,
57-
"end": 15
58-
}
59-
}
60-
}
61-
]"
54+
"end": 15,
55+
},
56+
"path": "test/__stubs__/dirty.js",
57+
},
58+
"severity": "minor",
59+
"type": "issue",
60+
},
61+
{
62+
"check_name": "prettier",
63+
"description":
64+
"SyntaxError: Unexpected token, expected "(" (3:13)
65+
1 | /* eslint-disable */
66+
2 |
67+
> 3 | function foo#####( arg ) {
68+
| ^
69+
4 | return arg;
70+
5 | }
71+
6 |"
72+
,
73+
"fingerprint": "2c7e0de9e9eff8b589318b043ed783db",
74+
"location": {
75+
"path": "test/__stubs__/syntax-error.js",
76+
},
77+
"severity": "major",
78+
"type": "issue",
79+
},
80+
]
6281
`;
6382
64-
exports[`prettier-formatter-gitlab cli should create a code quality report file 2`] = `
65-
"[
83+
exports[`prettier-formatter-gitlab cli should create a code quality report file with prettier -c 1`] = `
84+
[
6685
{
67-
"type": "issue",
6886
"check_name": "prettier",
6987
"description": "Replace ·arg·· with arg",
70-
"severity": "minor",
7188
"fingerprint": "ea70e2ae0144c16efa5df45bf52a33de",
7289
"location": {
73-
"path": "test/__stubs__/dirty-2.js",
7490
"lines": {
7591
"begin": 3,
76-
"end": 3
77-
}
78-
}
92+
"end": 3,
93+
},
94+
"path": "test/__stubs__/dirty-2.js",
95+
},
96+
"severity": "minor",
97+
"type": "issue",
7998
},
8099
{
81-
"type": "issue",
82100
"check_name": "prettier",
83101
"description": "Insert ;",
84-
"severity": "minor",
85102
"fingerprint": "d88816112daed6a61fd9d81e964a484b",
86103
"location": {
87-
"path": "test/__stubs__/dirty-2.js",
88104
"lines": {
89105
"begin": 5,
90-
"end": 5
91-
}
92-
}
106+
"end": 5,
107+
},
108+
"path": "test/__stubs__/dirty-2.js",
109+
},
110+
"severity": "minor",
111+
"type": "issue",
93112
},
94113
{
95-
"type": "issue",
96114
"check_name": "prettier",
97115
"description": "Replace ⏎⏎⏎⏎⏎⏎function·foo(·arg··)·{⏎⏎ with function·foo(arg)·{",
98-
"severity": "minor",
99116
"fingerprint": "c38522eb22f56c446d6b78774d940d24",
100117
"location": {
101-
"path": "test/__stubs__/dirty.js",
102118
"lines": {
103119
"begin": 3,
104-
"end": 11
105-
}
106-
}
120+
"end": 11,
121+
},
122+
"path": "test/__stubs__/dirty.js",
123+
},
124+
"severity": "minor",
125+
"type": "issue",
107126
},
108127
{
109-
"type": "issue",
110128
"check_name": "prettier",
111129
"description": "Delete ⏎⏎⏎",
112-
"severity": "minor",
113130
"fingerprint": "f312c866f5c2332c733d2de24b9efa0f",
114131
"location": {
115-
"path": "test/__stubs__/dirty.js",
116132
"lines": {
117133
"begin": 12,
118-
"end": 15
119-
}
120-
}
121-
}
122-
]"
134+
"end": 15,
135+
},
136+
"path": "test/__stubs__/dirty.js",
137+
},
138+
"severity": "minor",
139+
"type": "issue",
140+
},
141+
{
142+
"check_name": "prettier",
143+
"description":
144+
"SyntaxError: Unexpected token, expected "(" (3:13)
145+
1 | /* eslint-disable */
146+
2 |
147+
> 3 | function foo#####( arg ) {
148+
| ^
149+
4 | return arg;
150+
5 | }
151+
6 |"
152+
,
153+
"fingerprint": "2c7e0de9e9eff8b589318b043ed783db",
154+
"location": {
155+
"path": "test/__stubs__/syntax-error.js",
156+
},
157+
"severity": "major",
158+
"type": "issue",
159+
},
160+
]
123161
`;

test/__snapshots__/index.spec.js.snap

+146
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
// Bun Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`The prettierFormatterGitLab function should work with the \`-c\` or \`-l\` flag 1`] = `
4+
[
5+
[
6+
7+
"----------------------------------------------------
8+
test/__stubs__/dirty-2.js
9+
----------------------------------------------------
10+
\x1B[33m@@ -1,7 +1,7 @@\x1B[39m
11+
\x1B[2m /* eslint-disable */\x1B[22m
12+
13+
\x1B[31m- function foo(\x1B[7m \x1B[27marg\x1B[7m \x1B[27m) {\x1B[39m
14+
\x1B[32m+ function foo(arg) {\x1B[39m
15+
\x1B[2m const data = arg.split(',');\x1B[22m
16+
\x1B[31m- const message = \`Cras non justo iaculis, placerat tortor non, venenatis neque. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Nullam ut neque a justo efficitur tristique. Aliquam consequat convallis sagittis. Curabitur venenatis imperdiet fermentum. Curabitur euismod sit amet mi eu tristique. Phasellus leo nisi, tempor efficitur laoreet vitae, rutrum id justo. Nullam ac mi vehicula, rhoncus turpis a, mattis odio. Donec id condimentum metus. Vivamus posuere libero nec orci volutpat, in euismod dolor ornare. Cras tincidunt gravida ante, sed dictum nulla posuere ut.\`\x1B[39m
17+
\x1B[32m+ const message = \`Cras non justo iaculis, placerat tortor non, venenatis neque. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Nullam ut neque a justo efficitur tristique. Aliquam consequat convallis sagittis. Curabitur venenatis imperdiet fermentum. Curabitur euismod sit amet mi eu tristique. Phasellus leo nisi, tempor efficitur laoreet vitae, rutrum id justo. Nullam ac mi vehicula, rhoncus turpis a, mattis odio. Donec id condimentum metus. Vivamus posuere libero nec orci volutpat, in euismod dolor ornare. Cras tincidunt gravida ante, sed dictum nulla posuere ut.\`\x1B[7m;\x1B[27m\x1B[39m
18+
\x1B[2m return data;\x1B[22m
19+
\x1B[2m }\x1B[22m
20+
"
21+
,
22+
],
23+
[
24+
25+
"----------------------------------------------------
26+
test/__stubs__/dirty.js
27+
----------------------------------------------------
28+
\x1B[33m@@ -1,18 +1,7 @@\x1B[39m
29+
\x1B[2m /* eslint-disable */\x1B[22m
30+
31+
\x1B[31m-\x1B[39m
32+
\x1B[31m-\x1B[39m
33+
\x1B[31m-\x1B[39m
34+
\x1B[31m-\x1B[39m
35+
\x1B[31m-\x1B[39m
36+
\x1B[31m-\x1B[39m
37+
\x1B[31m- function foo(\x1B[7m \x1B[27marg\x1B[7m \x1B[27m) {\x1B[39m
38+
\x1B[32m+ function foo(arg) {\x1B[39m
39+
\x1B[31m-\x1B[39m
40+
\x1B[31m-\x1B[39m
41+
\x1B[2m const data = arg.split(',');\x1B[22m
42+
43+
\x1B[31m-\x1B[39m
44+
\x1B[31m-\x1B[39m
45+
\x1B[31m-\x1B[39m
46+
\x1B[2m return data;\x1B[22m
47+
\x1B[2m }\x1B[22m
48+
"
49+
,
50+
],
51+
[
52+
53+
"----------------------------------------------------
54+
test/__stubs__/syntax-error.js
55+
----------------------------------------------------
56+
SyntaxError: Unexpected token, expected "(" (3:13)
57+
\x1B[0m \x1B[90m 1 |\x1B[39m \x1B[90m/* eslint-disable */\x1B[39m
58+
\x1B[90m 2 |\x1B[39m
59+
\x1B[31m\x1B[1m>\x1B[22m\x1B[39m\x1B[90m 3 |\x1B[39m \x1B[36mfunction\x1B[39m foo\x1B[33m#\x1B[39m\x1B[33m#\x1B[39m\x1B[33m#\x1B[39m\x1B[33m#\x1B[39m\x1B[33m#\x1B[39m( arg ) {
60+
\x1B[90m |\x1B[39m \x1B[31m\x1B[1m^\x1B[22m\x1B[39m
61+
\x1B[90m 4 |\x1B[39m \x1B[36mreturn\x1B[39m arg\x1B[33m;\x1B[39m
62+
\x1B[90m 5 |\x1B[39m }
63+
\x1B[90m 6 |\x1B[39m\x1B[0m
64+
"
65+
,
66+
],
67+
[
68+
69+
"----------------------------------------------------
70+
test/__stubs__/syntax-error.js
71+
----------------------------------------------------
72+
SyntaxError: Unexpected token, expected "(" (3:13)
73+
\x1B[0m \x1B[90m 1 |\x1B[39m \x1B[90m/* eslint-disable */\x1B[39m
74+
\x1B[90m 2 |\x1B[39m
75+
\x1B[31m\x1B[1m>\x1B[22m\x1B[39m\x1B[90m 3 |\x1B[39m \x1B[36mfunction\x1B[39m foo\x1B[33m#\x1B[39m\x1B[33m#\x1B[39m\x1B[33m#\x1B[39m\x1B[33m#\x1B[39m\x1B[33m#\x1B[39m( arg ) {
76+
\x1B[90m |\x1B[39m \x1B[31m\x1B[1m^\x1B[22m\x1B[39m
77+
\x1B[90m 4 |\x1B[39m \x1B[36mreturn\x1B[39m arg\x1B[33m;\x1B[39m
78+
\x1B[90m 5 |\x1B[39m }
79+
\x1B[90m 6 |\x1B[39m\x1B[0m
80+
"
81+
,
82+
],
83+
[
84+
85+
"----------------------------------------------------
86+
test/__stubs__/dirty-2.js
87+
----------------------------------------------------
88+
\x1B[33m@@ -1,7 +1,7 @@\x1B[39m
89+
\x1B[2m /* eslint-disable */\x1B[22m
90+
91+
\x1B[31m- function foo(\x1B[7m \x1B[27marg\x1B[7m \x1B[27m) {\x1B[39m
92+
\x1B[32m+ function foo(arg) {\x1B[39m
93+
\x1B[2m const data = arg.split(',');\x1B[22m
94+
\x1B[31m- const message = \`Cras non justo iaculis, placerat tortor non, venenatis neque. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Nullam ut neque a justo efficitur tristique. Aliquam consequat convallis sagittis. Curabitur venenatis imperdiet fermentum. Curabitur euismod sit amet mi eu tristique. Phasellus leo nisi, tempor efficitur laoreet vitae, rutrum id justo. Nullam ac mi vehicula, rhoncus turpis a, mattis odio. Donec id condimentum metus. Vivamus posuere libero nec orci volutpat, in euismod dolor ornare. Cras tincidunt gravida ante, sed dictum nulla posuere ut.\`\x1B[39m
95+
\x1B[32m+ const message = \`Cras non justo iaculis, placerat tortor non, venenatis neque. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Nullam ut neque a justo efficitur tristique. Aliquam consequat convallis sagittis. Curabitur venenatis imperdiet fermentum. Curabitur euismod sit amet mi eu tristique. Phasellus leo nisi, tempor efficitur laoreet vitae, rutrum id justo. Nullam ac mi vehicula, rhoncus turpis a, mattis odio. Donec id condimentum metus. Vivamus posuere libero nec orci volutpat, in euismod dolor ornare. Cras tincidunt gravida ante, sed dictum nulla posuere ut.\`\x1B[7m;\x1B[27m\x1B[39m
96+
\x1B[2m return data;\x1B[22m
97+
\x1B[2m }\x1B[22m
98+
"
99+
,
100+
],
101+
[
102+
103+
"----------------------------------------------------
104+
test/__stubs__/dirty.js
105+
----------------------------------------------------
106+
\x1B[33m@@ -1,18 +1,7 @@\x1B[39m
107+
\x1B[2m /* eslint-disable */\x1B[22m
108+
109+
\x1B[31m-\x1B[39m
110+
\x1B[31m-\x1B[39m
111+
\x1B[31m-\x1B[39m
112+
\x1B[31m-\x1B[39m
113+
\x1B[31m-\x1B[39m
114+
\x1B[31m-\x1B[39m
115+
\x1B[31m- function foo(\x1B[7m \x1B[27marg\x1B[7m \x1B[27m) {\x1B[39m
116+
\x1B[32m+ function foo(arg) {\x1B[39m
117+
\x1B[31m-\x1B[39m
118+
\x1B[31m-\x1B[39m
119+
\x1B[2m const data = arg.split(',');\x1B[22m
120+
121+
\x1B[31m-\x1B[39m
122+
\x1B[31m-\x1B[39m
123+
\x1B[31m-\x1B[39m
124+
\x1B[2m return data;\x1B[22m
125+
\x1B[2m }\x1B[22m
126+
"
127+
,
128+
],
129+
[
130+
131+
"----------------------------------------------------
132+
test/__stubs__/syntax-error.js
133+
----------------------------------------------------
134+
SyntaxError: Unexpected token, expected "(" (3:13)
135+
\x1B[0m \x1B[90m 1 |\x1B[39m \x1B[90m/* eslint-disable */\x1B[39m
136+
\x1B[90m 2 |\x1B[39m
137+
\x1B[31m\x1B[1m>\x1B[22m\x1B[39m\x1B[90m 3 |\x1B[39m \x1B[36mfunction\x1B[39m foo\x1B[33m#\x1B[39m\x1B[33m#\x1B[39m\x1B[33m#\x1B[39m\x1B[33m#\x1B[39m\x1B[33m#\x1B[39m( arg ) {
138+
\x1B[90m |\x1B[39m \x1B[31m\x1B[1m^\x1B[22m\x1B[39m
139+
\x1B[90m 4 |\x1B[39m \x1B[36mreturn\x1B[39m arg\x1B[33m;\x1B[39m
140+
\x1B[90m 5 |\x1B[39m }
141+
\x1B[90m 6 |\x1B[39m\x1B[0m
142+
"
143+
,
144+
],
145+
]
146+
`;

test/__stubs__/syntax-error.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/* eslint-disable */
2+
3+
function foo#####( arg ) {
4+
return arg;
5+
}

0 commit comments

Comments
 (0)