UNPKG

@augment-vir/test

Version:

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

32 lines (31 loc) 1.04 kB
import { focusElement } from './element-test-focus.js'; export async function typeString(text) { const { sendKeys } = await import('@web/test-runner-commands'); return await sendKeys({ type: text, }); } export async function typeStringIntoElement(text, element) { await focusElement(element); await typeString(text); } export async function deleteAllTextInInput(inputElement) { const { sendKeys } = await import('@web/test-runner-commands'); 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); } }