Skip to content

Commit

Permalink
Document helper functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jnicklas committed Dec 2, 2020
1 parent bc564ad commit 4a87ffd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/interactor/src/fill-in.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ function setValue(element: TextFieldElement, value: string): void {
}
}

/**
* Fill in text into an element by emulating how a user would do it, first
* focusing the element, then filling in the text letter by letter, generating
* the appropriate keyboard events.
*
* @param element The element to fill in text in
* @param value The text value to fill in
*/
export function fillIn(element: TextFieldElement, value: string) {
let originalValue = element.value;

Expand Down
3 changes: 3 additions & 0 deletions packages/interactor/src/focused.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* Helper function for focused filters, returns whether the given element is focused.
*/
export function focused(element: Element): boolean {
return element.ownerDocument.activeElement === element;
}

0 comments on commit 4a87ffd

Please sign in to comment.