@@ -13,15 +13,22 @@ ruleTester.run(RULE_NAME, rule, {
13
13
// sync queries without await are valid
14
14
...SYNC_QUERIES_COMBINATIONS . map ( ( query ) => ( {
15
15
code : `() => {
16
- ${ query } ('foo')
16
+ const element = ${ query } ('foo')
17
+ }
18
+ ` ,
19
+ } ) ) ,
20
+ // sync queries without await inside assert are valid
21
+ ...SYNC_QUERIES_COMBINATIONS . map ( ( query ) => ( {
22
+ code : `() => {
23
+ expect(${ query } ('foo')).toBeEnabled()
17
24
}
18
25
` ,
19
26
} ) ) ,
20
27
21
28
// async queries with await operator are valid
22
29
...ASYNC_QUERIES_COMBINATIONS . map ( ( query ) => ( {
23
30
code : `async () => {
24
- await ${ query } ('foo')
31
+ const element = await ${ query } ('foo')
25
32
}
26
33
` ,
27
34
} ) ) ,
@@ -40,29 +47,58 @@ ruleTester.run(RULE_NAME, rule, {
40
47
// sync queries with await operator are not valid
41
48
...SYNC_QUERIES_COMBINATIONS . map ( ( query ) => ( {
42
49
code : `async () => {
43
- await ${ query } ('foo')
50
+ const element = await ${ query } ('foo')
51
+ }
52
+ ` ,
53
+ errors : [
54
+ {
55
+ messageId : 'noAwaitSyncQuery' ,
56
+ line : 2 ,
57
+ column : 31 ,
58
+ } ,
59
+ ] ,
60
+ } ) ) ,
61
+ // sync queries with await operator inside assert are not valid
62
+ ...SYNC_QUERIES_COMBINATIONS . map ( ( query ) => ( {
63
+ code : `async () => {
64
+ expect(await ${ query } ('foo')).toBeEnabled()
44
65
}
45
66
` ,
46
67
errors : [
47
68
{
48
69
messageId : 'noAwaitSyncQuery' ,
49
70
line : 2 ,
50
- column : 15 ,
71
+ column : 22 ,
51
72
} ,
52
73
] ,
53
74
} ) ) ,
54
75
55
76
// sync queries in screen with await operator are not valid
56
77
...SYNC_QUERIES_COMBINATIONS . map ( ( query ) => ( {
57
78
code : `async () => {
58
- await screen.${ query } ('foo')
79
+ const element = await screen.${ query } ('foo')
59
80
}
60
81
` ,
61
82
errors : [
62
83
{
63
84
messageId : 'noAwaitSyncQuery' ,
64
85
line : 2 ,
65
- column : 22 ,
86
+ column : 38 ,
87
+ } ,
88
+ ] ,
89
+ } ) ) ,
90
+
91
+ // sync queries in screen with await operator inside assert are not valid
92
+ ...SYNC_QUERIES_COMBINATIONS . map ( ( query ) => ( {
93
+ code : `async () => {
94
+ expect(await screen.${ query } ('foo')).toBeEnabled()
95
+ }
96
+ ` ,
97
+ errors : [
98
+ {
99
+ messageId : 'noAwaitSyncQuery' ,
100
+ line : 2 ,
101
+ column : 29 ,
66
102
} ,
67
103
] ,
68
104
} ) ) ,
0 commit comments