From d6871aa398ede4cc76d2d6c9218e6357da5b405f Mon Sep 17 00:00:00 2001 From: marcosvega91 Date: Sat, 13 Jun 2020 19:22:11 +0200 Subject: [PATCH 1/2] fix: fix typescript definitions for suggestions --- types/suggestions.d.ts | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/types/suggestions.d.ts b/types/suggestions.d.ts index f574f344..e55b344a 100644 --- a/types/suggestions.d.ts +++ b/types/suggestions.d.ts @@ -3,4 +3,26 @@ 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' + | 'LabelText' + | 'PlaceholderText' + | 'Text' + | 'DisplayValue' + | 'AltText' + | 'Title' + | 'TestId' + +export function getSuggestedQuery( + element: HTMLElement, + variant: Variant, + method?: Method, +): Suggestion | undefined From ea1a0ec303f6aa457e7fb6ee38914d0f2e98d56c Mon Sep 17 00:00:00 2001 From: marcosvega91 Date: Sat, 13 Jun 2020 23:02:44 +0200 Subject: [PATCH 2/2] fix: add lowercase methods and make variant optional --- src/suggestions.js | 2 +- types/suggestions.d.ts | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/suggestions.js b/src/suggestions.js index 258a3454..dd902df1 100644 --- a/src/suggestions.js +++ b/src/suggestions.js @@ -72,7 +72,7 @@ function canSuggest(currentMethod, requestedMethod, data) { return data && (!requestedMethod || requestedMethod === currentMethod) } -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 diff --git a/types/suggestions.d.ts b/types/suggestions.d.ts index e55b344a..e10fcb02 100644 --- a/types/suggestions.d.ts +++ b/types/suggestions.d.ts @@ -13,16 +13,24 @@ export type Variant = 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, + variant?: Variant, method?: Method, ): Suggestion | undefined