Skip to content

Commit 1febc64

Browse files
committed
Adds test for string case
1 parent eaa264d commit 1febc64

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

src/__tests__/role.js

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ Here are the accessible roles:
380380
`)
381381
})
382382

383-
test('accessible name in error message for multiple found', () => {
383+
test('accessible regex name in error message for multiple found', () => {
384384
const {getByRole} = render(
385385
`<button>Increment value</button
386386
><button>Decrement value</button
@@ -408,6 +408,34 @@ test('accessible name in error message for multiple found', () => {
408408
`)
409409
})
410410

411+
test('accessible string name in error message for multiple found', () => {
412+
const {getByRole} = render(
413+
`<button>Submit</button
414+
><button>Submit</button
415+
><button>Submit</button
416+
>`,
417+
)
418+
419+
expect(() => getByRole('button', {name: 'Submit'}))
420+
.toThrowErrorMatchingInlineSnapshot(`
421+
"Found multiple elements with the role "button" and name "Submit"
422+
423+
(If this is intentional, then use the \`*AllBy*\` variant of the query (like \`queryAllByText\`, \`getAllByText\`, or \`findAllByText\`)).
424+
425+
<div>
426+
<button>
427+
Submit
428+
</button>
429+
<button>
430+
Submit
431+
</button>
432+
<button>
433+
Submit
434+
</button>
435+
</div>"
436+
`)
437+
})
438+
411439
describe('configuration', () => {
412440
let originalConfig
413441
beforeEach(() => {

0 commit comments

Comments
 (0)