Skip to content

Commit a98b8cd

Browse files
committed
refactor: improve the description of folder-match-with-fex unit cases
1 parent da6ef1e commit a98b8cd

File tree

1 file changed

+190
-174
lines changed

1 file changed

+190
-174
lines changed

tests/lib/rules/folder-match-with-fex.js

Lines changed: 190 additions & 174 deletions
Original file line numberDiff line numberDiff line change
@@ -9,184 +9,198 @@ const RuleTester = require('eslint').RuleTester;
99

1010
const ruleTester = new RuleTester();
1111

12-
ruleTester.run("[{ '*.js': '**/__tests__/' }]", rule, {
13-
valid: [
14-
{
15-
code: "var foo = 'bar';",
16-
filename: '/__tests__/foo.test.js',
17-
options: [{ '*.js': '**/__tests__/' }],
18-
},
19-
{
20-
code: "var foo = 'bar';",
21-
filename: '__tests__/foo.test.js',
22-
options: [{ '*.js': '**/__tests__/' }],
23-
},
24-
{
25-
code: "var foo = 'bar';",
26-
filename: 'bar/__tests__/foo.test.js',
27-
options: [{ '*.js': '**/__tests__/' }],
28-
},
29-
{
30-
code: "var foo = 'bar';",
31-
filename: '/bar/__tests__/foo.test.js',
32-
options: [{ '*.js': '**/__tests__/' }],
33-
},
34-
],
12+
ruleTester.run(
13+
"folder-match-with-fex with option: [{ '*.js': '**/__tests__/' }]",
14+
rule,
15+
{
16+
valid: [
17+
{
18+
code: "var foo = 'bar';",
19+
filename: '/__tests__/foo.test.js',
20+
options: [{ '*.js': '**/__tests__/' }],
21+
},
22+
{
23+
code: "var foo = 'bar';",
24+
filename: '__tests__/foo.test.js',
25+
options: [{ '*.js': '**/__tests__/' }],
26+
},
27+
{
28+
code: "var foo = 'bar';",
29+
filename: 'bar/__tests__/foo.test.js',
30+
options: [{ '*.js': '**/__tests__/' }],
31+
},
32+
{
33+
code: "var foo = 'bar';",
34+
filename: '/bar/__tests__/foo.test.js',
35+
options: [{ '*.js': '**/__tests__/' }],
36+
},
37+
],
3538

36-
invalid: [
37-
{
38-
code: "var foo = 'bar';",
39-
filename: '/bar/__test__/foo.test.js',
40-
options: [{ '*.js': '**/__tests__/' }],
41-
errors: [
42-
{
43-
message:
44-
'The folder of the file "/bar/__test__/foo.test.js" does not match "**/__tests__/"',
45-
column: 1,
46-
line: 1,
47-
},
48-
],
49-
},
50-
],
51-
});
39+
invalid: [
40+
{
41+
code: "var foo = 'bar';",
42+
filename: '/bar/__test__/foo.test.js',
43+
options: [{ '*.js': '**/__tests__/' }],
44+
errors: [
45+
{
46+
message:
47+
'The folder of the file "/bar/__test__/foo.test.js" does not match "**/__tests__/"',
48+
column: 1,
49+
line: 1,
50+
},
51+
],
52+
},
53+
],
54+
}
55+
);
5256

53-
ruleTester.run("[{ '*.js': '*/__tests__/' }]", rule, {
54-
valid: [
55-
{
56-
code: "var foo = 'bar';",
57-
filename: '/__tests__/foo.test.js',
58-
options: [{ '*.js': '*/__tests__/' }],
59-
},
60-
{
61-
code: "var foo = 'bar';",
62-
filename: 'bar/__tests__/foo.test.js',
63-
options: [{ '*.js': '*/__tests__/' }],
64-
},
65-
],
66-
invalid: [
67-
{
68-
code: "var foo = 'bar';",
69-
filename: '/__test__/foo.test.js',
70-
options: [{ '*.js': '*/__tests__/' }],
71-
errors: [
72-
{
73-
message:
74-
'The folder of the file "/__test__/foo.test.js" does not match "*/__tests__/"',
75-
column: 1,
76-
line: 1,
77-
},
78-
],
79-
},
80-
{
81-
code: "var foo = 'bar';",
82-
filename: '/bar/__tests__/foo.test.js',
83-
options: [{ '*.js': '*/__tests__/' }],
84-
errors: [
85-
{
86-
message:
87-
'The folder of the file "/bar/__tests__/foo.test.js" does not match "*/__tests__/"',
88-
column: 1,
89-
line: 1,
90-
},
91-
],
92-
},
93-
{
94-
code: "var foo = 'bar';",
95-
filename: '__tests__/foo.test.js',
96-
options: [{ '*.js': '*/__tests__/' }],
97-
errors: [
98-
{
99-
message:
100-
'The folder of the file "__tests__/foo.test.js" does not match "*/__tests__/"',
101-
column: 1,
102-
line: 1,
103-
},
104-
],
105-
},
106-
],
107-
});
57+
ruleTester.run(
58+
"folder-match-with-fex with option: [{ '*.js': '*/__tests__/' }]",
59+
rule,
60+
{
61+
valid: [
62+
{
63+
code: "var foo = 'bar';",
64+
filename: '/__tests__/foo.test.js',
65+
options: [{ '*.js': '*/__tests__/' }],
66+
},
67+
{
68+
code: "var foo = 'bar';",
69+
filename: 'bar/__tests__/foo.test.js',
70+
options: [{ '*.js': '*/__tests__/' }],
71+
},
72+
],
10873

109-
ruleTester.run("[{ '*.test.{js,jsx,ts,tsx}': '*/__tests__/' }]", rule, {
110-
valid: [
111-
{
112-
code: "var foo = 'bar';",
113-
filename: 'bar/__tests__/foo.test.js',
114-
options: [{ '*.test.{js,jsx,ts,tsx}': '*/__tests__/' }],
115-
},
116-
{
117-
code: "var foo = 'bar';",
118-
filename: 'bar/__tests__/foo.test.jsx',
119-
options: [{ '*.test.{js,jsx,ts,tsx}': '*/__tests__/' }],
120-
},
121-
{
122-
code: "var foo = 'bar';",
123-
filename: 'bar/__tests__/foo.test.ts',
124-
options: [{ '*.test.{js,jsx,ts,tsx}': '*/__tests__/' }],
125-
},
126-
{
127-
code: "var foo = 'bar';",
128-
filename: 'bar/__tests__/foo.test.tsx',
129-
options: [{ '*.test.{js,jsx,ts,tsx}': '*/__tests__/' }],
130-
},
131-
],
132-
invalid: [
133-
{
134-
code: "var foo = 'bar';",
135-
filename: 'bar/_tests_/foo.test.js',
136-
options: [{ '*.test.{js,jsx,ts,tsx}': '*/__tests__/' }],
137-
errors: [
138-
{
139-
message:
140-
'The folder of the file "bar/_tests_/foo.test.js" does not match "*/__tests__/"',
141-
column: 1,
142-
line: 1,
143-
},
144-
],
145-
},
146-
{
147-
code: "var foo = 'bar';",
148-
filename: 'bar/_tests_/foo.test.jsx',
149-
options: [{ '*.test.{js,jsx,ts,tsx}': '*/__tests__/' }],
150-
errors: [
151-
{
152-
message:
153-
'The folder of the file "bar/_tests_/foo.test.jsx" does not match "*/__tests__/"',
154-
column: 1,
155-
line: 1,
156-
},
157-
],
158-
},
159-
{
160-
code: "var foo = 'bar';",
161-
filename: 'bar/_tests_/foo.test.ts',
162-
options: [{ '*.test.{js,jsx,ts,tsx}': '*/__tests__/' }],
163-
errors: [
164-
{
165-
message:
166-
'The folder of the file "bar/_tests_/foo.test.ts" does not match "*/__tests__/"',
167-
column: 1,
168-
line: 1,
169-
},
170-
],
171-
},
172-
{
173-
code: "var foo = 'bar';",
174-
filename: 'bar/_tests_/foo.test.tsx',
175-
options: [{ '*.test.{js,jsx,ts,tsx}': '*/__tests__/' }],
176-
errors: [
177-
{
178-
message:
179-
'The folder of the file "bar/_tests_/foo.test.tsx" does not match "*/__tests__/"',
180-
column: 1,
181-
line: 1,
182-
},
183-
],
184-
},
185-
],
186-
});
74+
invalid: [
75+
{
76+
code: "var foo = 'bar';",
77+
filename: '/__test__/foo.test.js',
78+
options: [{ '*.js': '*/__tests__/' }],
79+
errors: [
80+
{
81+
message:
82+
'The folder of the file "/__test__/foo.test.js" does not match "*/__tests__/"',
83+
column: 1,
84+
line: 1,
85+
},
86+
],
87+
},
88+
{
89+
code: "var foo = 'bar';",
90+
filename: '/bar/__tests__/foo.test.js',
91+
options: [{ '*.js': '*/__tests__/' }],
92+
errors: [
93+
{
94+
message:
95+
'The folder of the file "/bar/__tests__/foo.test.js" does not match "*/__tests__/"',
96+
column: 1,
97+
line: 1,
98+
},
99+
],
100+
},
101+
{
102+
code: "var foo = 'bar';",
103+
filename: '__tests__/foo.test.js',
104+
options: [{ '*.js': '*/__tests__/' }],
105+
errors: [
106+
{
107+
message:
108+
'The folder of the file "__tests__/foo.test.js" does not match "*/__tests__/"',
109+
column: 1,
110+
line: 1,
111+
},
112+
],
113+
},
114+
],
115+
}
116+
);
187117

188118
ruleTester.run(
189-
"[{ '*.test.js': '*/__tests__/', '*.test.ts': '*/__tests__/' }]",
119+
"folder-match-with-fex with option: [{ '*.test.{js,jsx,ts,tsx}': '*/__tests__/' }]",
120+
rule,
121+
{
122+
valid: [
123+
{
124+
code: "var foo = 'bar';",
125+
filename: 'bar/__tests__/foo.test.js',
126+
options: [{ '*.test.{js,jsx,ts,tsx}': '*/__tests__/' }],
127+
},
128+
{
129+
code: "var foo = 'bar';",
130+
filename: 'bar/__tests__/foo.test.jsx',
131+
options: [{ '*.test.{js,jsx,ts,tsx}': '*/__tests__/' }],
132+
},
133+
{
134+
code: "var foo = 'bar';",
135+
filename: 'bar/__tests__/foo.test.ts',
136+
options: [{ '*.test.{js,jsx,ts,tsx}': '*/__tests__/' }],
137+
},
138+
{
139+
code: "var foo = 'bar';",
140+
filename: 'bar/__tests__/foo.test.tsx',
141+
options: [{ '*.test.{js,jsx,ts,tsx}': '*/__tests__/' }],
142+
},
143+
],
144+
145+
invalid: [
146+
{
147+
code: "var foo = 'bar';",
148+
filename: 'bar/_tests_/foo.test.js',
149+
options: [{ '*.test.{js,jsx,ts,tsx}': '*/__tests__/' }],
150+
errors: [
151+
{
152+
message:
153+
'The folder of the file "bar/_tests_/foo.test.js" does not match "*/__tests__/"',
154+
column: 1,
155+
line: 1,
156+
},
157+
],
158+
},
159+
{
160+
code: "var foo = 'bar';",
161+
filename: 'bar/_tests_/foo.test.jsx',
162+
options: [{ '*.test.{js,jsx,ts,tsx}': '*/__tests__/' }],
163+
errors: [
164+
{
165+
message:
166+
'The folder of the file "bar/_tests_/foo.test.jsx" does not match "*/__tests__/"',
167+
column: 1,
168+
line: 1,
169+
},
170+
],
171+
},
172+
{
173+
code: "var foo = 'bar';",
174+
filename: 'bar/_tests_/foo.test.ts',
175+
options: [{ '*.test.{js,jsx,ts,tsx}': '*/__tests__/' }],
176+
errors: [
177+
{
178+
message:
179+
'The folder of the file "bar/_tests_/foo.test.ts" does not match "*/__tests__/"',
180+
column: 1,
181+
line: 1,
182+
},
183+
],
184+
},
185+
{
186+
code: "var foo = 'bar';",
187+
filename: 'bar/_tests_/foo.test.tsx',
188+
options: [{ '*.test.{js,jsx,ts,tsx}': '*/__tests__/' }],
189+
errors: [
190+
{
191+
message:
192+
'The folder of the file "bar/_tests_/foo.test.tsx" does not match "*/__tests__/"',
193+
column: 1,
194+
line: 1,
195+
},
196+
],
197+
},
198+
],
199+
}
200+
);
201+
202+
ruleTester.run(
203+
"folder-match-with-fex with option: [{ '*.test.js': '*/__tests__/', '*.test.ts': '*/__tests__/' }]",
190204
rule,
191205
{
192206
valid: [
@@ -201,6 +215,7 @@ ruleTester.run(
201215
options: [{ '*.test.js': '*/__tests__/', '*.test.ts': '*/__tests__/' }],
202216
},
203217
],
218+
204219
invalid: [
205220
{
206221
code: "var foo = 'bar';",
@@ -232,13 +247,14 @@ ruleTester.run(
232247
}
233248
);
234249

235-
ruleTester.run('fex that has not been set', rule, {
250+
ruleTester.run('folder-match-with-fex with fex that has not been set', rule, {
236251
valid: [
237252
{
238253
code: "var foo = 'bar';",
239254
filename: '/bar/__test__/foo.test.ts',
240255
options: [{ '*.js': '**/__tests__/', '*.jsx': '**/__tests__/' }],
241256
},
242257
],
258+
243259
invalid: [],
244260
});

0 commit comments

Comments
 (0)