How to use the @ember/test-helpers/dom/-logging.log function in @ember/test-helpers

To help you get started, we’ve selected a few @ember/test-helpers examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github emberjs / ember-test-helpers / addon-test-support / @ember / test-helpers / dom / trigger-event.ts View on Github external
export default function triggerEvent(
  target: Target,
  eventType: string,
  options?: object
): Promise {
  log('triggerEvent', target, eventType);

  return nextTickPromise().then(() => {
    if (!target) {
      throw new Error('Must pass an element or selector to `triggerEvent`.');
    }

    let element = getElement(target);
    if (!element) {
      throw new Error(`Element not found when calling \`triggerEvent('${target}', ...)\`.`);
    }

    if (!eventType) {
      throw new Error(`Must provide an \`eventType\` to \`triggerEvent\``);
    }

    fireEvent(element, eventType, options);
github emberjs / ember-test-helpers / addon-test-support / @ember / test-helpers / dom / double-click.ts View on Github external
export default function doubleClick(target: Target, options: MouseEventInit = {}): Promise {
  log('doubleClick', target);

  return nextTickPromise().then(() => {
    if (!target) {
      throw new Error('Must pass an element or selector to `doubleClick`.');
    }

    let element = getElement(target);
    if (!element) {
      throw new Error(`Element not found when calling \`doubleClick('${target}')\`.`);
    }

    __doubleClick__(element, options);
    return settled();
  });
}
github emberjs / ember-test-helpers / addon-test-support / @ember / test-helpers / dom / fill-in.ts View on Github external
export default function fillIn(target: Target, text: string): Promise {
  log('fillIn', target, text);

  return nextTickPromise().then(() => {
    if (!target) {
      throw new Error('Must pass an element or selector to `fillIn`.');
    }

    let element = getElement(target) as any;
    if (!element) {
      throw new Error(`Element not found when calling \`fillIn('${target}')\`.`);
    }
    let isControl = isFormControl(element);
    if (!isControl && !element.isContentEditable) {
      throw new Error('`fillIn` is only usable on form controls or contenteditable elements.');
    }

    if (typeof text === 'undefined' || text === null) {
github emberjs / ember-test-helpers / addon-test-support / @ember / test-helpers / dom / click.ts View on Github external
export default function click(target: Target, options: MouseEventInit = {}): Promise {
  log('click', target);

  return nextTickPromise().then(() => {
    if (!target) {
      throw new Error('Must pass an element or selector to `click`.');
    }

    let element = getElement(target);
    if (!element) {
      throw new Error(`Element not found when calling \`click('${target}')\`.`);
    }

    let isDisabledFormControl = isFormControl(element) && element.disabled;

    if (!isDisabledFormControl) {
      __click__(element, options);
    }
github emberjs / ember-test-helpers / addon-test-support / @ember / test-helpers / dom / trigger-key-event.ts View on Github external
export default function triggerKeyEvent(
  target: Target,
  eventType: KeyboardEventType,
  key: number | string,
  modifiers: KeyModifiers = DEFAULT_MODIFIERS
): Promise {
  log('triggerKeyEvent', target, eventType, key);

  return nextTickPromise().then(() => {
    if (!target) {
      throw new Error('Must pass an element or selector to `triggerKeyEvent`.');
    }

    let element = getElement(target);
    if (!element) {
      throw new Error(`Element not found when calling \`triggerKeyEvent('${target}', ...)\`.`);
    }

    if (!eventType) {
      throw new Error(`Must provide an \`eventType\` to \`triggerKeyEvent\``);
    }

    if (!isKeyboardEventType(eventType)) {
github emberjs / ember-test-helpers / addon-test-support / @ember / test-helpers / dom / blur.ts View on Github external
export default function blur(target: Target = document.activeElement!): Promise {
  log('blur', target);

  return nextTickPromise().then(() => {
    let element = getElement(target);
    if (!element) {
      throw new Error(`Element not found when calling \`blur('${target}')\`.`);
    }

    if (!isFocusable(element)) {
      throw new Error(`${target} is not focusable`);
    }

    __blur__(element);

    return settled();
  });
}
github emberjs / ember-test-helpers / addon-test-support / @ember / test-helpers / dom / tap.ts View on Github external
export default function tap(target: Target, options: object = {}): Promise {
  log('tap', target);

  return nextTickPromise().then(() => {
    if (!target) {
      throw new Error('Must pass an element or selector to `tap`.');
    }

    let element = getElement(target);
    if (!element) {
      throw new Error(`Element not found when calling \`tap('${target}')\`.`);
    }

    let touchstartEv = fireEvent(element, 'touchstart', options);
    let touchendEv = fireEvent(element, 'touchend', options);

    if (!touchstartEv.defaultPrevented && !touchendEv.defaultPrevented) {
      __click__(element, options);
github emberjs / ember-test-helpers / addon-test-support / @ember / test-helpers / dom / focus.ts View on Github external
export default function focus(target: Target): Promise {
  log('focus', target);

  return nextTickPromise().then(() => {
    if (!target) {
      throw new Error('Must pass an element or selector to `focus`.');
    }

    let element = getElement(target);
    if (!element) {
      throw new Error(`Element not found when calling \`focus('${target}')\`.`);
    }

    if (!isFocusable(element)) {
      throw new Error(`${target} is not focusable`);
    }

    __focus__(element);