Skip to content

Commit

Permalink
fix: typescript definitions for suggestions (#630)
Browse files Browse the repository at this point in the history
* fix: fix typescript definitions for suggestions

* fix: add lowercase methods and make variant optional
  • Loading branch information
marcosvega91 committed Jun 13, 2020
1 parent 0158f0d commit 7f8a15e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/suggestions.js
Expand Up @@ -76,7 +76,7 @@ function canSuggest(currentMethod, requestedMethod, data) {
)
}

export function getSuggestedQuery(element, variant, method) {
export function getSuggestedQuery(element, variant = 'get', method) {
// don't create suggestions for script and style elements
if (element.matches(DEFAULT_IGNORE_TAGS)) {
return undefined
Expand Down
32 changes: 31 additions & 1 deletion types/suggestions.d.ts
Expand Up @@ -3,4 +3,34 @@ export interface Suggestion {
toString(): string
}

export function getSuggestedQuery(element: HTMLElement): Suggestion | undefined
export type Variant =
| 'get'
| 'getAll'
| 'query'
| 'queryAll'
| 'find'
| 'findAll'

export type Method =
| 'Role'
| 'role'
| 'LabelText'
| 'labeltext'
| 'PlaceholderText'
| 'placeholdertext'
| 'Text'
| 'text'
| 'DisplayValue'
| 'displayvalue'
| 'AltText'
| 'alttext'
| 'Title'
| 'title'
| 'TestId'
| 'testtd'

export function getSuggestedQuery(
element: HTMLElement,
variant?: Variant,
method?: Method,
): Suggestion | undefined

0 comments on commit 7f8a15e

Please sign in to comment.