Skip to content

Commit d406b48

Browse files
committed
test: fix failing tests
1 parent 99a550a commit d406b48

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

src/__tests__/element-queries.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,14 +533,14 @@ test('queryAllByRole returns semantic html elements', () => {
533533
expect(queryAllByRole(/listitem/i)).toHaveLength(3)
534534
// TODO: with https://github.com/A11yance/aria-query/pull/42
535535
// the actual value will match `toHaveLength(2)`
536-
expect(queryAllByRole(/textbox/i)).toHaveLength(1)
536+
expect(queryAllByRole(/textbox/i)).toHaveLength(2)
537537
expect(queryAllByRole(/checkbox/i)).toHaveLength(1)
538538
expect(queryAllByRole(/radio/i)).toHaveLength(1)
539539
expect(queryAllByRole('row')).toHaveLength(3)
540540
expect(queryAllByRole(/rowgroup/i)).toHaveLength(2)
541541
// TODO: with https://github.com/A11yance/aria-query/pull/42
542542
// the actual value will match `toHaveLength(3)`
543-
expect(queryAllByRole(/(table)|(textbox)/i)).toHaveLength(2)
543+
expect(queryAllByRole(/(table)|(textbox)/i)).toHaveLength(3)
544544
expect(queryAllByRole(/img/i)).toHaveLength(1)
545545
expect(queryAllByRole('meter')).toHaveLength(1)
546546
expect(queryAllByRole('progressbar')).toHaveLength(0)

src/__tests__/suggestions.js

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ test(`should not suggest if the suggestion would give different results`, () =>
7474
})
7575

7676
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+
)
7880

7981
expect(() => screen.getByTitle('foo')).toThrowError(
8082
/getByLabelText\(\/bar\/i\)/,
@@ -181,7 +183,7 @@ test('escapes regular expressions in suggestion', () => {
181183

182184
test('should suggest getByLabelText when no role available', () => {
183185
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" />`,
185187
)
186188
expect(() => screen.getByTestId('foo')).toThrowError(
187189
/getByLabelText\(\/username\/i\)/,
@@ -232,19 +234,21 @@ test.each([
232234

233235
test(`should suggest label over placeholder text`, () => {
234236
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" />`,
236238
)
237239

238-
expect(() => screen.getByPlaceholderText('Username')).toThrowError(
239-
/getByLabelText\(\/username\/i\)/,
240+
expect(() => screen.getByPlaceholderText('Password')).toThrowError(
241+
/getByLabelText\(\/password\/i\)/,
240242
)
241243
})
242244

243245
test(`should suggest getByPlaceholderText`, () => {
244-
renderIntoDocument(`<input data-testid="foo" placeholder="Username" />`)
246+
renderIntoDocument(
247+
`<input type="password" data-testid="foo" placeholder="Password" />`,
248+
)
245249

246250
expect(() => screen.getByTestId('foo')).toThrowError(
247-
/getByPlaceholderText\(\/username\/i\)/,
251+
/getByPlaceholderText\(\/password\/i\)/,
248252
)
249253
})
250254

@@ -257,25 +261,27 @@ test(`should suggest getByText for simple elements`, () => {
257261
})
258262

259263
test(`should suggest getByDisplayValue`, () => {
260-
renderIntoDocument(`<input id="lastName" data-testid="lastName" />`)
264+
renderIntoDocument(
265+
`<input type="password" id="password" data-testid="password" />`,
266+
)
261267

262-
document.getElementById('lastName').value = 'Prine' // RIP John Prine
268+
document.getElementById('password').value = 'Prine' // RIP John Prine
263269

264-
expect(() => screen.getByTestId('lastName')).toThrowError(
270+
expect(() => screen.getByTestId('password')).toThrowError(
265271
/getByDisplayValue\(\/prine\/i\)/,
266272
)
267273
})
268274

269275
test(`should suggest getByAltText`, () => {
270276
renderIntoDocument(`
271-
<input data-testid="input" alt="last name" />
277+
<input type="password" data-testid="input" alt="password" />
272278
<map name="workmap">
273279
<area data-testid="area" shape="rect" coords="34,44,270,350" alt="Computer">
274280
</map>
275281
`)
276282

277283
expect(() => screen.getByTestId('input')).toThrowError(
278-
/getByAltText\(\/last name\/i\)/,
284+
/getByAltText\(\/password\/i\)/,
279285
)
280286
expect(() => screen.getByTestId('area')).toThrowError(
281287
/getByAltText\(\/computer\/i\)/,

0 commit comments

Comments
 (0)