@@ -8,6 +8,7 @@ ruleTester.run(RULE_NAME, rule, {
88 valid : [
99 ...ASYNC_UTILS . map ( asyncUtil => ( {
1010 code : `
11+ import { ${ asyncUtil } } from '@testing-library/dom';
1112 test('${ asyncUtil } util directly waited with await operator is valid', async () => {
1213 doSomethingElse();
1314 await ${ asyncUtil } (() => getByLabelText('email'));
@@ -17,6 +18,7 @@ ruleTester.run(RULE_NAME, rule, {
1718
1819 ...ASYNC_UTILS . map ( asyncUtil => ( {
1920 code : `
21+ import { ${ asyncUtil } } from '@testing-library/dom';
2022 test('${ asyncUtil } util promise saved in var and waited with await operator is valid', async () => {
2123 doSomethingElse();
2224 const aPromise = ${ asyncUtil } (() => getByLabelText('email'));
@@ -27,6 +29,7 @@ ruleTester.run(RULE_NAME, rule, {
2729
2830 ...ASYNC_UTILS . map ( asyncUtil => ( {
2931 code : `
32+ import { ${ asyncUtil } } from '@testing-library/dom';
3033 test('${ asyncUtil } util directly chained with then is valid', () => {
3134 doSomethingElse();
3235 ${ asyncUtil } (() => getByLabelText('email')).then(() => { console.log('done') });
@@ -36,6 +39,7 @@ ruleTester.run(RULE_NAME, rule, {
3639
3740 ...ASYNC_UTILS . map ( asyncUtil => ( {
3841 code : `
42+ import { ${ asyncUtil } } from '@testing-library/dom';
3943 test('${ asyncUtil } util promise saved in var and chained with then is valid', () => {
4044 doSomethingElse();
4145 const aPromise = ${ asyncUtil } (() => getByLabelText('email'));
@@ -46,6 +50,7 @@ ruleTester.run(RULE_NAME, rule, {
4650
4751 ...ASYNC_UTILS . map ( asyncUtil => ( {
4852 code : `
53+ import { ${ asyncUtil } } from '@testing-library/dom';
4954 test('${ asyncUtil } util directly returned in arrow function is valid', async () => {
5055 const makeCustomWait = () =>
5156 ${ asyncUtil } (() =>
@@ -57,6 +62,7 @@ ruleTester.run(RULE_NAME, rule, {
5762
5863 ...ASYNC_UTILS . map ( asyncUtil => ( {
5964 code : `
65+ import { ${ asyncUtil } } from '@testing-library/dom';
6066 test('${ asyncUtil } util explicitly returned in arrow function is valid', async () => {
6167 const makeCustomWait = () => {
6268 return ${ asyncUtil } (() =>
@@ -69,6 +75,7 @@ ruleTester.run(RULE_NAME, rule, {
6975
7076 ...ASYNC_UTILS . map ( asyncUtil => ( {
7177 code : `
78+ import { ${ asyncUtil } } from '@testing-library/dom';
7279 test('${ asyncUtil } util returned in regular function is valid', async () => {
7380 function makeCustomWait() {
7481 return ${ asyncUtil } (() =>
@@ -81,6 +88,7 @@ ruleTester.run(RULE_NAME, rule, {
8188
8289 ...ASYNC_UTILS . map ( asyncUtil => ( {
8390 code : `
91+ import { ${ asyncUtil } } from '@testing-library/dom';
8492 test('${ asyncUtil } util promise saved in var and returned in function is valid', async () => {
8593 const makeCustomWait = () => {
8694 const aPromise = ${ asyncUtil } (() =>
@@ -94,8 +102,29 @@ ruleTester.run(RULE_NAME, rule, {
94102 });
95103 ` ,
96104 } ) ) ,
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+
97124 {
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 () => {
99128 doSomethingElse();
100129 const emailInput = getByLabelText('email');
101130 await waitForElementToBeRemoved(emailInput);
@@ -114,33 +143,46 @@ ruleTester.run(RULE_NAME, rule, {
114143 invalid : [
115144 ...ASYNC_UTILS . map ( asyncUtil => ( {
116145 code : `
146+ import { ${ asyncUtil } } from '@testing-library/dom';
117147 test('${ asyncUtil } util not waited', () => {
118148 doSomethingElse();
119149 ${ asyncUtil } (() => getByLabelText('email'));
120150 });
121151 ` ,
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' } ] ,
123163 } ) ) ,
124164 ...ASYNC_UTILS . map ( asyncUtil => ( {
125165 code : `
166+ import { ${ asyncUtil } } from '@testing-library/dom';
126167 test('${ asyncUtil } util promise saved not waited', () => {
127168 doSomethingElse();
128169 const aPromise = ${ asyncUtil } (() => getByLabelText('email'));
129170 });
130171 ` ,
131- errors : [ { line : 4 , column : 28 , messageId : 'awaitAsyncUtil' } ] ,
172+ errors : [ { line : 5 , column : 28 , messageId : 'awaitAsyncUtil' } ] ,
132173 } ) ) ,
133174 ...ASYNC_UTILS . map ( asyncUtil => ( {
134175 code : `
176+ import { ${ asyncUtil } } from '@testing-library/dom';
135177 test('several ${ asyncUtil } utils not waited', () => {
136178 const aPromise = ${ asyncUtil } (() => getByLabelText('username'));
137179 doSomethingElse(aPromise);
138180 ${ asyncUtil } (() => getByLabelText('email'));
139181 });
140182 ` ,
141183 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' } ,
144186 ] ,
145187 } ) ) ,
146188 ] ,
0 commit comments