UNPKG

cli-testing-library

Version:

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

26 lines (25 loc) 849 B
"use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const events = require("../../events.cjs"); const utils = require("../utils.cjs"); const getNextKeyDef = require("./getNextKeyDef.cjs"); async function keyboardImplementation(instance, text, options) { const { keyDef, consumedLength } = getNextKeyDef.getNextKeyDef(text, options); keypress(keyDef, instance); if (text.length > consumedLength) { if (options.delay > 0) { await utils.wait(options.delay); } return keyboardImplementation( instance, text.slice(consumedLength), options ); } return void 0; } function keypress(keyDef, instance) { events.fireEvent.write(instance, { value: keyDef.hex }); } exports.keyboardImplementation = keyboardImplementation; //# sourceMappingURL=keyboardImplementation.cjs.map