UNPKG

@augment-vir/test

Version:

A universal testing suite that works with Mocha style test runners _and_ Node.js's built-in test runner.

31 lines (30 loc) 956 B
import { sendKeys } from '@web/test-runner-commands'; import { focusElement } from './element-test-focus.js'; export async function typeString(text) { return await sendKeys({ type: text, }); } export async function typeStringIntoElement(text, element) { await focusElement(element); await typeString(text); } export async function deleteAllTextInInput(inputElement) { const lastValue = inputElement.value; if (lastValue) { await focusElement(inputElement); await sendKeys({ press: 'Delete', }); await sendKeys({ press: 'Backspace', }); if (inputElement.value === lastValue) { throw new Error(`Input value was not changed at all`); } if (inputElement.value.length >= lastValue.length) { throw new Error(`Input value length was not decreased.`); } await deleteAllTextInInput(inputElement); } }