UNPKG

cli-testing-library

Version:

Simple and complete CLI testing utilities that encourage good testing practices.

26 lines (25 loc) 710 B
import { fireEvent } from "../../events.js"; import { wait } from "../utils.js"; import { getNextKeyDef } from "./getNextKeyDef.js"; async function keyboardImplementation(instance, text, options) { const { keyDef, consumedLength } = getNextKeyDef(text, options); keypress(keyDef, instance); if (text.length > consumedLength) { if (options.delay > 0) { await wait(options.delay); } return keyboardImplementation( instance, text.slice(consumedLength), options ); } return void 0; } function keypress(keyDef, instance) { fireEvent.write(instance, { value: keyDef.hex }); } export { keyboardImplementation }; //# sourceMappingURL=keyboardImplementation.js.map