@@ -188,37 +188,35 @@ test('escapes regular expressions in suggestion', () => {
188
188
189
189
expect (
190
190
getSuggestedQuery (
191
- container . querySelector ( 'img' ) as HTMLImageElement ,
191
+ container . querySelector ( 'img' ) ! ,
192
192
'get' ,
193
193
'AltText' ,
194
194
) ?. toString ( ) ,
195
195
) . toEqual ( `getByAltText(/the problem \\(picture of a question mark\\)/i)` )
196
196
197
- expect (
198
- getSuggestedQuery (
199
- container . querySelector ( 'p' ) as HTMLParagraphElement ,
200
- ) ?. toString ( ) ,
201
- ) . toEqual ( `getByText(/loading \\.\\.\\. \\(1\\)/i)` )
197
+ expect ( getSuggestedQuery ( container . querySelector ( 'p' ) ! ) ?. toString ( ) ) . toEqual (
198
+ `getByText(/loading \\.\\.\\. \\(1\\)/i)` ,
199
+ )
202
200
203
201
expect (
204
202
getSuggestedQuery (
205
- container . querySelector ( 'input' ) as HTMLInputElement ,
203
+ container . querySelector ( 'input' ) ! ,
206
204
'get' ,
207
205
'PlaceholderText' ,
208
206
) ?. toString ( ) ,
209
207
) . toEqual ( `getByPlaceholderText(/should escape \\+\\-'\\(\\//i)` )
210
208
211
209
expect (
212
210
getSuggestedQuery (
213
- container . querySelector ( 'input' ) as HTMLInputElement ,
211
+ container . querySelector ( 'input' ) ! ,
214
212
'get' ,
215
213
'DisplayValue' ,
216
214
) ?. toString ( ) ,
217
215
) . toEqual ( `getByDisplayValue(/my super string \\+\\-\\('\\{\\}\\^\\$\\)/i)` )
218
216
219
217
expect (
220
218
getSuggestedQuery (
221
- container . querySelector ( 'input' ) as HTMLInputElement ,
219
+ container . querySelector ( 'input' ) ! ,
222
220
'get' ,
223
221
'LabelText' ,
224
222
) ?. toString ( ) ,
@@ -437,9 +435,8 @@ test('getSuggestedQuery can return specified methods in addition to the best', (
437
435
<button>button</button>
438
436
` )
439
437
440
- const input = container . querySelector ( 'input' ) as HTMLInputElement
441
- const button = container . querySelector ( 'button' ) as HTMLButtonElement
442
-
438
+ const input = container . querySelector ( 'input' ) !
439
+ const button = container . querySelector ( 'button' ) !
443
440
// this function should be insensitive for the method param.
444
441
// Role and role should work the same
445
442
expect ( getSuggestedQuery ( input , 'get' , 'role' ) ) . toMatchObject ( {
@@ -520,7 +517,7 @@ test('getSuggestedQuery works with custom testIdAttribute', () => {
520
517
<button>button</button>
521
518
` )
522
519
523
- const input = container . querySelector ( 'input' ) as HTMLInputElement
520
+ const input = container . querySelector ( 'input' ) !
524
521
525
522
expect ( getSuggestedQuery ( input , 'get' , 'TestId' ) ) . toMatchObject ( {
526
523
queryName : 'TestId' ,
@@ -536,8 +533,8 @@ test('getSuggestedQuery does not create suggestions for script and style element
536
533
<style data-testid="style"></style>
537
534
` )
538
535
539
- const script = container . querySelector ( 'script' ) as HTMLScriptElement
540
- const style = container . querySelector ( 'style' ) as HTMLStyleElement
536
+ const script = container . querySelector ( 'script' ) !
537
+ const style = container . querySelector ( 'style' ) !
541
538
542
539
expect ( getSuggestedQuery ( script , 'get' , 'TestId' ) ) . toBeUndefined ( )
543
540
expect ( getSuggestedQuery ( style , 'get' , 'TestId' ) ) . toBeUndefined ( )
@@ -557,11 +554,7 @@ test('should get the first label with aria-labelledby contains multiple ids', ()
557
554
` )
558
555
559
556
expect (
560
- getSuggestedQuery (
561
- container . querySelector ( 'input' ) as HTMLInputElement ,
562
- 'get' ,
563
- 'LabelText' ,
564
- ) ,
557
+ getSuggestedQuery ( container . querySelector ( 'input' ) ! , 'get' , 'LabelText' ) ,
565
558
) . toMatchObject ( {
566
559
queryName : 'LabelText' ,
567
560
queryMethod : 'getByLabelText' ,
@@ -603,7 +596,7 @@ test('should suggest hidden option if element is not in the accessibility tree',
603
596
` )
604
597
605
598
const suggestion = getSuggestedQuery (
606
- container . querySelector ( 'input' ) as HTMLInputElement ,
599
+ container . querySelector ( 'input' ) ! ,
607
600
'get' ,
608
601
'role' ,
609
602
)
@@ -643,7 +636,7 @@ test('should find label text using the aria-labelledby', () => {
643
636
644
637
expect (
645
638
getSuggestedQuery (
646
- container . querySelector ( '[id="sixth-id"]' ) as HTMLInputElement ,
639
+ container . querySelector ( '[id="sixth-id"]' ) ! ,
647
640
'get' ,
648
641
'LabelText' ,
649
642
) ,
0 commit comments