1
- import { type TSESLint } from '@typescript-eslint/utils' ;
1
+ import {
2
+ type InvalidTestCase ,
3
+ type ValidTestCase ,
4
+ } from '@typescript-eslint/rule-tester' ;
2
5
3
6
import rule , {
4
7
MessageIds ,
@@ -9,9 +12,9 @@ import { createRuleTester } from '../test-utils';
9
12
10
13
const ruleTester = createRuleTester ( ) ;
11
14
12
- type ValidTestCase = TSESLint . ValidTestCase < Options > ;
13
- type InvalidTestCase = TSESLint . InvalidTestCase < MessageIds , Options > ;
14
- type TestCase = InvalidTestCase | ValidTestCase ;
15
+ type RuleValidTestCase = ValidTestCase < Options > ;
16
+ type RuleInvalidTestCase = InvalidTestCase < MessageIds , Options > ;
17
+ type TestCase = RuleValidTestCase | RuleInvalidTestCase ;
15
18
const disableAggressiveReporting = < T extends TestCase > ( array : T [ ] ) : T [ ] =>
16
19
array . map ( ( testCase ) => ( {
17
20
...testCase ,
@@ -22,11 +25,11 @@ const disableAggressiveReporting = <T extends TestCase>(array: T[]): T[] =>
22
25
} ,
23
26
} ) ) ;
24
27
25
- const validTestCases : ValidTestCase [ ] = [
28
+ const validTestCases : RuleValidTestCase [ ] = [
26
29
{
27
30
code : `
28
31
import React from 'react';
29
-
32
+
30
33
const TestComponent = props => {
31
34
return (
32
35
<div data-testid="cool">
@@ -40,7 +43,7 @@ const validTestCases: ValidTestCase[] = [
40
43
{
41
44
code : `
42
45
import React from 'react';
43
-
46
+
44
47
const TestComponent = props => {
45
48
return (
46
49
<div className="cool">
@@ -54,7 +57,7 @@ const validTestCases: ValidTestCase[] = [
54
57
{
55
58
code : `
56
59
import React from 'react';
57
-
60
+
58
61
const TestComponent = props => {
59
62
return (
60
63
<div data-testid="Awesome__CoolStuff">
@@ -73,7 +76,7 @@ const validTestCases: ValidTestCase[] = [
73
76
{
74
77
code : `
75
78
import React from 'react';
76
-
79
+
77
80
const TestComponent = props => {
78
81
return (
79
82
<div data-testid="Awesome">
@@ -92,7 +95,7 @@ const validTestCases: ValidTestCase[] = [
92
95
{
93
96
code : `
94
97
import React from 'react';
95
-
98
+
96
99
const TestComponent = props => {
97
100
return (
98
101
<div data-testid="Parent">
@@ -111,7 +114,7 @@ const validTestCases: ValidTestCase[] = [
111
114
{
112
115
code : `
113
116
import React from 'react';
114
-
117
+
115
118
const TestComponent = props => {
116
119
return (
117
120
<div data-testid="Parent">
@@ -130,7 +133,7 @@ const validTestCases: ValidTestCase[] = [
130
133
{
131
134
code : `
132
135
import React from 'react';
133
-
136
+
134
137
const TestComponent = props => {
135
138
return (
136
139
<div data-testid="wrong" custom-attr="right-1">
@@ -149,7 +152,7 @@ const validTestCases: ValidTestCase[] = [
149
152
{
150
153
code : `
151
154
import React from 'react';
152
-
155
+
153
156
const TestComponent = props => {
154
157
return (
155
158
<div another-custom-attr="right-1" custom-attr="right-2">
@@ -168,7 +171,7 @@ const validTestCases: ValidTestCase[] = [
168
171
{
169
172
code : `
170
173
import React from 'react';
171
-
174
+
172
175
const TestComponent = props => {
173
176
return (
174
177
<div data-test-id="Parent">
@@ -188,7 +191,7 @@ const validTestCases: ValidTestCase[] = [
188
191
{
189
192
code : `
190
193
import React from 'react';
191
-
194
+
192
195
const TestComponent = props => {
193
196
const dynamicTestId = 'somethingDynamic';
194
197
return (
@@ -205,7 +208,7 @@ const validTestCases: ValidTestCase[] = [
205
208
{
206
209
code : `
207
210
import React from 'react';
208
-
211
+
209
212
const TestComponent = props => {
210
213
return (
211
214
<div data-testid="__CoolStuff">
@@ -224,7 +227,7 @@ const validTestCases: ValidTestCase[] = [
224
227
{
225
228
code : `
226
229
import React from 'react';
227
-
230
+
228
231
const TestComponent = props => {
229
232
return (
230
233
<div data-testid="__CoolStuff">
@@ -244,7 +247,7 @@ const validTestCases: ValidTestCase[] = [
244
247
{
245
248
code : `
246
249
import React from 'react';
247
-
250
+
248
251
const TestComponent = props => {
249
252
return (
250
253
<div data-testid="__CoolStuff">
@@ -262,11 +265,11 @@ const validTestCases: ValidTestCase[] = [
262
265
filename : '/my/cool/file/path/[...wildcard].js' ,
263
266
} ,
264
267
] ;
265
- const invalidTestCases : InvalidTestCase [ ] = [
268
+ const invalidTestCases : RuleInvalidTestCase [ ] = [
266
269
{
267
270
code : `
268
271
import React from 'react';
269
-
272
+
270
273
const TestComponent = props => {
271
274
return (
272
275
<div data-testid="Awesome__CoolStuff">
@@ -291,7 +294,7 @@ const invalidTestCases: InvalidTestCase[] = [
291
294
{
292
295
code : `
293
296
import React from 'react';
294
-
297
+
295
298
const TestComponent = props => {
296
299
return (
297
300
<div data-testid="Nope">
@@ -321,7 +324,7 @@ const invalidTestCases: InvalidTestCase[] = [
321
324
{
322
325
code : `
323
326
import React from 'react';
324
-
327
+
325
328
const TestComponent = props => {
326
329
return (
327
330
<div data-testid="Parent__cool" my-custom-attr="WrongComponent__cool">
@@ -352,7 +355,7 @@ const invalidTestCases: InvalidTestCase[] = [
352
355
{
353
356
code : `
354
357
import React from 'react';
355
-
358
+
356
359
const TestComponent = props => {
357
360
return (
358
361
<div custom-attr="wrong" another-custom-attr="wrong">
@@ -391,7 +394,7 @@ const invalidTestCases: InvalidTestCase[] = [
391
394
{
392
395
code : `
393
396
import React from 'react';
394
-
397
+
395
398
const TestComponent = props => {
396
399
return (
397
400
<div data-testid="WrongComponent__cool">
@@ -421,7 +424,7 @@ const invalidTestCases: InvalidTestCase[] = [
421
424
{
422
425
code : ` // test for custom message
423
426
import React from 'react';
424
-
427
+
425
428
const TestComponent = props => {
426
429
return (
427
430
<div data-testid="snake_case_value">
0 commit comments