@@ -74,7 +74,9 @@ test(`should not suggest if the suggestion would give different results`, () =>
74
74
} )
75
75
76
76
test ( 'should suggest by label over title' , ( ) => {
77
- renderIntoDocument ( `<label><span>bar</span><input title="foo" /></label>` )
77
+ renderIntoDocument (
78
+ `<label><span>bar</span><input type="password" title="foo" /></label>` ,
79
+ )
78
80
79
81
expect ( ( ) => screen . getByTitle ( 'foo' ) ) . toThrowError (
80
82
/ g e t B y L a b e l T e x t \( \/ b a r \/ i \) / ,
@@ -181,7 +183,7 @@ test('escapes regular expressions in suggestion', () => {
181
183
182
184
test ( 'should suggest getByLabelText when no role available' , ( ) => {
183
185
renderIntoDocument (
184
- `<label for="foo">Username</label><input data-testid="foo" id="foo" />` ,
186
+ `<label for="foo">Username</label><input type="password" data-testid="foo" id="foo" />` ,
185
187
)
186
188
expect ( ( ) => screen . getByTestId ( 'foo' ) ) . toThrowError (
187
189
/ g e t B y L a b e l T e x t \( \/ u s e r n a m e \/ i \) / ,
@@ -232,19 +234,21 @@ test.each([
232
234
233
235
test ( `should suggest label over placeholder text` , ( ) => {
234
236
renderIntoDocument (
235
- `<label for="foo">Username </label><input id="foo" data-testid="foo" placeholder="Username " />` ,
237
+ `<label for="foo">Password </label><input type="password" id="foo" data-testid="foo" placeholder="Password " />` ,
236
238
)
237
239
238
- expect ( ( ) => screen . getByPlaceholderText ( 'Username ' ) ) . toThrowError (
239
- / g e t B y L a b e l T e x t \( \/ u s e r n a m e \/ i \) / ,
240
+ expect ( ( ) => screen . getByPlaceholderText ( 'Password ' ) ) . toThrowError (
241
+ / g e t B y L a b e l T e x t \( \/ p a s s w o r d \/ i \) / ,
240
242
)
241
243
} )
242
244
243
245
test ( `should suggest getByPlaceholderText` , ( ) => {
244
- renderIntoDocument ( `<input data-testid="foo" placeholder="Username" />` )
246
+ renderIntoDocument (
247
+ `<input type="password" data-testid="foo" placeholder="Password" />` ,
248
+ )
245
249
246
250
expect ( ( ) => screen . getByTestId ( 'foo' ) ) . toThrowError (
247
- / g e t B y P l a c e h o l d e r T e x t \( \/ u s e r n a m e \/ i \) / ,
251
+ / g e t B y P l a c e h o l d e r T e x t \( \/ p a s s w o r d \/ i \) / ,
248
252
)
249
253
} )
250
254
@@ -257,25 +261,27 @@ test(`should suggest getByText for simple elements`, () => {
257
261
} )
258
262
259
263
test ( `should suggest getByDisplayValue` , ( ) => {
260
- renderIntoDocument ( `<input id="lastName" data-testid="lastName" />` )
264
+ renderIntoDocument (
265
+ `<input type="password" id="password" data-testid="password" />` ,
266
+ )
261
267
262
- document . getElementById ( 'lastName ' ) . value = 'Prine' // RIP John Prine
268
+ document . getElementById ( 'password ' ) . value = 'Prine' // RIP John Prine
263
269
264
- expect ( ( ) => screen . getByTestId ( 'lastName ' ) ) . toThrowError (
270
+ expect ( ( ) => screen . getByTestId ( 'password ' ) ) . toThrowError (
265
271
/ g e t B y D i s p l a y V a l u e \( \/ p r i n e \/ i \) / ,
266
272
)
267
273
} )
268
274
269
275
test ( `should suggest getByAltText` , ( ) => {
270
276
renderIntoDocument ( `
271
- <input data-testid="input" alt="last name " />
277
+ <input type="password" data-testid="input" alt="password " />
272
278
<map name="workmap">
273
279
<area data-testid="area" shape="rect" coords="34,44,270,350" alt="Computer">
274
280
</map>
275
281
` )
276
282
277
283
expect ( ( ) => screen . getByTestId ( 'input' ) ) . toThrowError (
278
- / g e t B y A l t T e x t \( \/ l a s t n a m e \/ i \) / ,
284
+ / g e t B y A l t T e x t \( \/ p a s s w o r d \/ i \) / ,
279
285
)
280
286
expect ( ( ) => screen . getByTestId ( 'area' ) ) . toThrowError (
281
287
/ g e t B y A l t T e x t \( \/ c o m p u t e r \/ i \) / ,
0 commit comments