@@ -8,6 +8,7 @@ ruleTester.run(RULE_NAME, rule, {
8
8
valid : [
9
9
...ASYNC_UTILS . map ( asyncUtil => ( {
10
10
code : `
11
+ import { ${ asyncUtil } } from '@testing-library/dom';
11
12
test('${ asyncUtil } util directly waited with await operator is valid', async () => {
12
13
doSomethingElse();
13
14
await ${ asyncUtil } (() => getByLabelText('email'));
@@ -17,6 +18,7 @@ ruleTester.run(RULE_NAME, rule, {
17
18
18
19
...ASYNC_UTILS . map ( asyncUtil => ( {
19
20
code : `
21
+ import { ${ asyncUtil } } from '@testing-library/dom';
20
22
test('${ asyncUtil } util promise saved in var and waited with await operator is valid', async () => {
21
23
doSomethingElse();
22
24
const aPromise = ${ asyncUtil } (() => getByLabelText('email'));
@@ -27,6 +29,7 @@ ruleTester.run(RULE_NAME, rule, {
27
29
28
30
...ASYNC_UTILS . map ( asyncUtil => ( {
29
31
code : `
32
+ import { ${ asyncUtil } } from '@testing-library/dom';
30
33
test('${ asyncUtil } util directly chained with then is valid', () => {
31
34
doSomethingElse();
32
35
${ asyncUtil } (() => getByLabelText('email')).then(() => { console.log('done') });
@@ -36,6 +39,7 @@ ruleTester.run(RULE_NAME, rule, {
36
39
37
40
...ASYNC_UTILS . map ( asyncUtil => ( {
38
41
code : `
42
+ import { ${ asyncUtil } } from '@testing-library/dom';
39
43
test('${ asyncUtil } util promise saved in var and chained with then is valid', () => {
40
44
doSomethingElse();
41
45
const aPromise = ${ asyncUtil } (() => getByLabelText('email'));
@@ -46,6 +50,7 @@ ruleTester.run(RULE_NAME, rule, {
46
50
47
51
...ASYNC_UTILS . map ( asyncUtil => ( {
48
52
code : `
53
+ import { ${ asyncUtil } } from '@testing-library/dom';
49
54
test('${ asyncUtil } util directly returned in arrow function is valid', async () => {
50
55
const makeCustomWait = () =>
51
56
${ asyncUtil } (() =>
@@ -57,6 +62,7 @@ ruleTester.run(RULE_NAME, rule, {
57
62
58
63
...ASYNC_UTILS . map ( asyncUtil => ( {
59
64
code : `
65
+ import { ${ asyncUtil } } from '@testing-library/dom';
60
66
test('${ asyncUtil } util explicitly returned in arrow function is valid', async () => {
61
67
const makeCustomWait = () => {
62
68
return ${ asyncUtil } (() =>
@@ -69,6 +75,7 @@ ruleTester.run(RULE_NAME, rule, {
69
75
70
76
...ASYNC_UTILS . map ( asyncUtil => ( {
71
77
code : `
78
+ import { ${ asyncUtil } } from '@testing-library/dom';
72
79
test('${ asyncUtil } util returned in regular function is valid', async () => {
73
80
function makeCustomWait() {
74
81
return ${ asyncUtil } (() =>
@@ -81,6 +88,7 @@ ruleTester.run(RULE_NAME, rule, {
81
88
82
89
...ASYNC_UTILS . map ( asyncUtil => ( {
83
90
code : `
91
+ import { ${ asyncUtil } } from '@testing-library/dom';
84
92
test('${ asyncUtil } util promise saved in var and returned in function is valid', async () => {
85
93
const makeCustomWait = () => {
86
94
const aPromise = ${ asyncUtil } (() =>
@@ -94,8 +102,29 @@ ruleTester.run(RULE_NAME, rule, {
94
102
});
95
103
` ,
96
104
} ) ) ,
105
+ ...ASYNC_UTILS . map ( asyncUtil => ( {
106
+ code : `
107
+ import { ${ asyncUtil } } from 'some-other-library';
108
+ test('util "${ asyncUtil } " which is not related to testing library is valid', async () => {
109
+ doSomethingElse();
110
+ ${ asyncUtil } ();
111
+ });
112
+ ` ,
113
+ } ) ) ,
114
+ ...ASYNC_UTILS . map ( asyncUtil => ( {
115
+ code : `
116
+ import * as asyncUtils from 'some-other-library';
117
+ test('util "asyncUtils.${ asyncUtil } " which is not related to testing library is valid', async () => {
118
+ doSomethingElse();
119
+ asyncUtils.${ asyncUtil } ();
120
+ });
121
+ ` ,
122
+ } ) ) ,
123
+
97
124
{
98
- code : `test('waitForElementToBeRemoved receiving element rather than callback is valid', async () => {
125
+ code : `
126
+ import { waitForElementToBeRemoved } from '@testing-library/dom';
127
+ test('waitForElementToBeRemoved receiving element rather than callback is valid', async () => {
99
128
doSomethingElse();
100
129
const emailInput = getByLabelText('email');
101
130
await waitForElementToBeRemoved(emailInput);
@@ -114,33 +143,46 @@ ruleTester.run(RULE_NAME, rule, {
114
143
invalid : [
115
144
...ASYNC_UTILS . map ( asyncUtil => ( {
116
145
code : `
146
+ import { ${ asyncUtil } } from '@testing-library/dom';
117
147
test('${ asyncUtil } util not waited', () => {
118
148
doSomethingElse();
119
149
${ asyncUtil } (() => getByLabelText('email'));
120
150
});
121
151
` ,
122
- errors : [ { line : 4 , messageId : 'awaitAsyncUtil' } ] ,
152
+ errors : [ { line : 5 , messageId : 'awaitAsyncUtil' } ] ,
153
+ } ) ) ,
154
+ ...ASYNC_UTILS . map ( asyncUtil => ( {
155
+ code : `
156
+ import * as asyncUtil from '@testing-library/dom';
157
+ test('asyncUtil.${ asyncUtil } util not waited', () => {
158
+ doSomethingElse();
159
+ asyncUtil.${ asyncUtil } (() => getByLabelText('email'));
160
+ });
161
+ ` ,
162
+ errors : [ { line : 5 , messageId : 'awaitAsyncUtil' } ] ,
123
163
} ) ) ,
124
164
...ASYNC_UTILS . map ( asyncUtil => ( {
125
165
code : `
166
+ import { ${ asyncUtil } } from '@testing-library/dom';
126
167
test('${ asyncUtil } util promise saved not waited', () => {
127
168
doSomethingElse();
128
169
const aPromise = ${ asyncUtil } (() => getByLabelText('email'));
129
170
});
130
171
` ,
131
- errors : [ { line : 4 , column : 28 , messageId : 'awaitAsyncUtil' } ] ,
172
+ errors : [ { line : 5 , column : 28 , messageId : 'awaitAsyncUtil' } ] ,
132
173
} ) ) ,
133
174
...ASYNC_UTILS . map ( asyncUtil => ( {
134
175
code : `
176
+ import { ${ asyncUtil } } from '@testing-library/dom';
135
177
test('several ${ asyncUtil } utils not waited', () => {
136
178
const aPromise = ${ asyncUtil } (() => getByLabelText('username'));
137
179
doSomethingElse(aPromise);
138
180
${ asyncUtil } (() => getByLabelText('email'));
139
181
});
140
182
` ,
141
183
errors : [
142
- { line : 3 , column : 28 , messageId : 'awaitAsyncUtil' } ,
143
- { line : 5 , column : 11 , messageId : 'awaitAsyncUtil' } ,
184
+ { line : 4 , column : 28 , messageId : 'awaitAsyncUtil' } ,
185
+ { line : 6 , column : 11 , messageId : 'awaitAsyncUtil' } ,
144
186
] ,
145
187
} ) ) ,
146
188
] ,
0 commit comments