addon-test-support/@ember/test-helpers/dom/type-in.js
/**
 * Mimics character by character entry into the target `input` or `textarea` element.
 *
 * Allows for simulation of slow entry by passing an optional millisecond delay
 * between key events.

 * The major difference between `typeIn` and `fillIn` is that `typeIn` triggers
 * keyboard events as well as `input` and `change`.
 * Typically this looks like `focus` -> `focusin` -> `keydown` -> `keypress` -> `keyup` -> `input` -> `change`
 * per character of the passed text (this may vary on some browsers).
 *
 * @public
 * @param {string|Element} target the element or selector to enter text into
 * @param {string} text the test to fill the element with
 * @param {Object} options {delay: x} (default 50) number of milliseconds to wait per keypress
 * @return {Promise<void>} resolves when the application is settled
 */
Mimics character by character entry into the target `input` or `textarea` element.
Allows for simulation of slow entry by passing an optional millisecond delay
between key events.




Mimics character by character entry into the target ` input ` or ` textarea ` element . Allows for simulation of slow entry by passing an optional millisecond delay between key events .
function typeIn(target, text, options = { delay: 50 }) {
  return nextTickPromise().then(() => {
    if (!target) {
      throw new Error('Must pass an element or selector to `typeIn`.');
    }
    const element = getElement(target);
    if (!element) {
      throw new Error(`Element not found when calling \`typeIn('${target}')\``);
    }
    let isControl = isFormControl(element);
    if (!isControl) {
      throw new Error('`typeIn` is only usable on form controls.');
    }
    if (typeof text === 'undefined' || text === null) {
      throw new Error('Must provide `text` when calling `typeIn`.');
    }
    __focus__(element);
    return fillOut(element, text, options.delay)
      .then(() => fireEvent(element, 'change'))
      .then(settled);
  });
}
function typeIn ( target , text , options = { delay : 50 } ) { return nextTickPromise ( ) . then ( ( ) => { if ( ! target ) { throw new Error ( 'Must pass an element or selector to `typeIn`.' ) ; } const element = getElement ( target ) ; if ( ! element ) { throw new Error ( ` \` ${ target } \` ` ) ; } let isControl = isFormControl ( element ) ; if ( ! isControl ) { throw new Error ( '`typeIn` is only usable on form controls.' ) ; } if ( typeof text === 'undefined' || text === null ) { throw new Error ( 'Must provide `text` when calling `typeIn`.' ) ; } __focus__ ( element ) ; return fillOut ( element , text , options . delay ) . then ( ( ) => fireEvent ( element , 'change' ) ) . then ( settled ) ; } ) ; }
Mimics character by character entry into the target `input` or `textarea` element.
Mimics character by character entry into the target ` input ` or ` textarea ` element .