Skip to content

Commit

Permalink
fix: canSuggest should not be case sensitive (#628)
Browse files Browse the repository at this point in the history
* test: add failing test

* fix: compare lowecase methods
  • Loading branch information
marcosvega91 committed Jun 13, 2020
1 parent 30a1ee8 commit d6f6d3a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/__tests__/suggestions.js
Expand Up @@ -373,7 +373,9 @@ test('getSuggestedQuery can return specified methods in addition to the best', (
const input = container.querySelector('input')
const button = container.querySelector('button')

expect(getSuggestedQuery(input, 'get', 'Role')).toMatchObject({
// this function should be insensitive for the method param.
// Role and role should work the same
expect(getSuggestedQuery(input, 'get', 'role')).toMatchObject({
queryName: 'Role',
queryMethod: 'getByRole',
queryArgs: ['textbox', {name: /label/i}],
Expand Down
6 changes: 5 additions & 1 deletion src/suggestions.js
Expand Up @@ -69,7 +69,11 @@ function makeSuggestion(queryName, content, {variant = 'get', name}) {
}

function canSuggest(currentMethod, requestedMethod, data) {
return data && (!requestedMethod || requestedMethod === currentMethod)
return (
data &&
(!requestedMethod ||
requestedMethod.toLowerCase() === currentMethod.toLowerCase())
)
}

export function getSuggestedQuery(element, variant, method) {
Expand Down

0 comments on commit d6f6d3a

Please sign in to comment.