Skip to content

Commit 600f9b5

Browse files
committed
Adds quotes around strings if needed
1 parent eba7e82 commit 600f9b5

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/queries/role.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,18 @@ function queryAllByRole(
107107
})
108108
}
109109

110-
const getMultipleError = (c, role, {name} = {}) =>
111-
`Found multiple elements with the role "${role}" matching ${name}`
110+
const getMultipleError = (c, role, {name} = {}) => {
111+
let nameHint = ''
112+
if (name === undefined) {
113+
nameHint = ''
114+
} else if (typeof name === 'string') {
115+
nameHint = ` and name "${name}"`
116+
} else {
117+
nameHint = ` and name \`${name}\``
118+
}
119+
120+
return `Found multiple elements with the role "${role}"${nameHint}`
121+
}
112122

113123
const getMissingError = (
114124
container,

0 commit comments

Comments
 (0)