Skip to content

Commit d6f6d3a

Browse files
authored
fix: canSuggest should not be case sensitive (#628)
* test: add failing test * fix: compare lowecase methods
1 parent 30a1ee8 commit d6f6d3a

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/__tests__/suggestions.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,9 @@ test('getSuggestedQuery can return specified methods in addition to the best', (
373373
const input = container.querySelector('input')
374374
const button = container.querySelector('button')
375375

376-
expect(getSuggestedQuery(input, 'get', 'Role')).toMatchObject({
376+
// this function should be insensitive for the method param.
377+
// Role and role should work the same
378+
expect(getSuggestedQuery(input, 'get', 'role')).toMatchObject({
377379
queryName: 'Role',
378380
queryMethod: 'getByRole',
379381
queryArgs: ['textbox', {name: /label/i}],

src/suggestions.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@ function makeSuggestion(queryName, content, {variant = 'get', name}) {
6969
}
7070

7171
function canSuggest(currentMethod, requestedMethod, data) {
72-
return data && (!requestedMethod || requestedMethod === currentMethod)
72+
return (
73+
data &&
74+
(!requestedMethod ||
75+
requestedMethod.toLowerCase() === currentMethod.toLowerCase())
76+
)
7377
}
7478

7579
export function getSuggestedQuery(element, variant, method) {

0 commit comments

Comments
 (0)