@@ -250,6 +250,20 @@ ruleTester.run(RULE_NAME, rule, {
250
250
test('handled promise from function wrapping ${ asyncUtil } util is valid', async () => {
251
251
await waitForSomethingAsync()
252
252
});
253
+ ` ,
254
+ } ) ) ,
255
+ ...ASYNC_UTILS . map ( ( asyncUtil ) => ( {
256
+ code : `
257
+ import { ${ asyncUtil } } from '${ testingFramework } ';
258
+
259
+ function waitForSomethingAsync() {
260
+ return ${ asyncUtil } (() => somethingAsync())
261
+ }
262
+
263
+ test('handled promise in variable declaration from function wrapping ${ asyncUtil } util is valid', async () => {
264
+ const result = await waitForSomethingAsync()
265
+ expect(result).toBe('foo')
266
+ });
253
267
` ,
254
268
} ) ) ,
255
269
{
@@ -506,6 +520,32 @@ ruleTester.run(RULE_NAME, rule, {
506
520
( asyncUtil ) =>
507
521
( {
508
522
code : `
523
+ import { ${ asyncUtil } , render } from '${ testingFramework } ';
524
+
525
+ function waitForSomethingAsync() {
526
+ return ${ asyncUtil } (() => somethingAsync())
527
+ }
528
+
529
+ test('unhandled promise in variable declaration from function wrapping ${ asyncUtil } util is invalid', async () => {
530
+ render()
531
+ const result = waitForSomethingAsync()
532
+ expect(result).toBe('foo')
533
+ });
534
+ ` ,
535
+ errors : [
536
+ {
537
+ messageId : 'asyncUtilWrapper' ,
538
+ line : 10 ,
539
+ column : 24 ,
540
+ data : { name : 'waitForSomethingAsync' } ,
541
+ } ,
542
+ ] ,
543
+ } ) as const
544
+ ) ,
545
+ ...ASYNC_UTILS . map (
546
+ ( asyncUtil ) =>
547
+ ( {
548
+ code : `
509
549
import { ${ asyncUtil } } from 'some-other-library'; // rather than ${ testingFramework }
510
550
test(
511
551
'aggressive reporting - util "${ asyncUtil } " which is not related to testing library is invalid',
0 commit comments