@@ -144,6 +144,11 @@ test('matches case with RegExp matcher', () => {
144
144
expect ( queryByText ( / S t e p 1 o f 4 / ) ) . not . toBeTruthy ( )
145
145
} )
146
146
147
+ test ( 'queryByText matches case with non-string matcher' , ( ) => {
148
+ const { queryByText} = render ( `<span>1</span>` )
149
+ expect ( queryByText ( 1 ) ) . toBeTruthy ( )
150
+ } )
151
+
147
152
test ( 'can get form controls by label text' , ( ) => {
148
153
const { getByLabelText} = render ( `
149
154
<div>
@@ -338,6 +343,11 @@ test('get can get form controls by placeholder', () => {
338
343
expect ( getByPlaceholderText ( 'username' ) . id ) . toBe ( 'username-id' )
339
344
} )
340
345
346
+ test ( 'queryByPlaceholderText matches case with non-string matcher' , ( ) => {
347
+ const { queryByPlaceholderText} = render ( `<input placeholder="1" />` )
348
+ expect ( queryByPlaceholderText ( 1 ) ) . toBeTruthy ( )
349
+ } )
350
+
341
351
test ( 'label with no form control' , ( ) => {
342
352
const { getByLabelText, queryByLabelText} = render ( `<label>All alone</label>` )
343
353
expect ( queryByLabelText ( / a l o n e / ) ) . toBeNull ( )
@@ -535,6 +545,11 @@ test('getByLabelText with aria-label', () => {
535
545
expect ( queryByLabelText ( / b a t / ) ) . toBeTruthy ( )
536
546
} )
537
547
548
+ test ( 'queryByLabelText matches case with non-string matcher' , ( ) => {
549
+ const { queryByLabelText} = render ( `<input aria-label="1" />` )
550
+ expect ( queryByLabelText ( 1 ) ) . toBeTruthy ( )
551
+ } )
552
+
538
553
test ( 'get element by its alt text' , ( ) => {
539
554
const { getByAltText} = render ( `
540
555
<div>
@@ -545,6 +560,11 @@ test('get element by its alt text', () => {
545
560
expect ( getByAltText ( / f i n .* n e m .* p o s t e r $ / i) . src ) . toContain ( '/finding-nemo.png' )
546
561
} )
547
562
563
+ test ( 'queryByAltText matches case with non-string matcher' , ( ) => {
564
+ const { queryByAltText} = render ( `<img alt="1" src="/finding-nemo.png" />` )
565
+ expect ( queryByAltText ( 1 ) ) . toBeTruthy ( )
566
+ } )
567
+
548
568
test ( 'query/get element by its title' , ( ) => {
549
569
const { getByTitle, queryByTitle} = render ( `
550
570
<div>
@@ -577,6 +597,11 @@ test('query/get title element of SVG', () => {
577
597
expect ( queryByTitle ( 'Close' ) . id ) . toEqual ( 'svg-title' )
578
598
} )
579
599
600
+ test ( 'queryByTitle matches case with non-string matcher' , ( ) => {
601
+ const { queryByTitle} = render ( `<span title="1" />` )
602
+ expect ( queryByTitle ( 1 ) ) . toBeTruthy ( )
603
+ } )
604
+
580
605
test ( 'query/get element by its value' , ( ) => {
581
606
const { getByDisplayValue, queryByDisplayValue} = render ( `
582
607
<div>
@@ -632,6 +657,15 @@ test('query/get select by text with multiple options selected', () => {
632
657
expect ( queryByDisplayValue ( 'Alaska' ) . id ) . toEqual ( 'state-select' )
633
658
} )
634
659
660
+ test ( 'queryByDisplayValue matches case with non-string matcher' , ( ) => {
661
+ const { queryByDisplayValue} = render ( `
662
+ <select multiple id="state-select">
663
+ <option selected value="one">1</option>
664
+ </select>
665
+ ` )
666
+ expect ( queryByDisplayValue ( 1 ) ) . toBeTruthy ( )
667
+ } )
668
+
635
669
describe ( 'query by test id' , ( ) => {
636
670
afterEach ( ( ) => {
637
671
// Restore the default test id attribute
@@ -651,6 +685,11 @@ describe('query by test id', () => {
651
685
expect ( queryByTestId ( 'first-name' ) ) . not . toBeTruthy ( )
652
686
} )
653
687
688
+ test ( 'queryByTestId matches case with non-string matcher' , ( ) => {
689
+ const { queryByTestId} = render ( `<span data-testid="1" />` )
690
+ expect ( queryByTestId ( 1 ) ) . toBeTruthy ( )
691
+ } )
692
+
654
693
test ( 'can override test id attribute' , ( ) => {
655
694
const { queryByTestId} = render ( `<div data-my-test-id="theTestId"></div>` )
656
695
@@ -732,6 +771,11 @@ test('queryAllByRole returns semantic html elements', () => {
732
771
expect ( queryAllByRole ( 'listbox' ) ) . toHaveLength ( 1 )
733
772
} )
734
773
774
+ test ( 'queryByRole matches case with non-string matcher' , ( ) => {
775
+ const { queryByRole} = render ( `<span role="1" />` )
776
+ expect ( queryByRole ( 1 ) ) . toBeTruthy ( )
777
+ } )
778
+
735
779
test ( 'getAll* matchers return an array' , ( ) => {
736
780
const {
737
781
getAllByAltText,
0 commit comments