Sha256: 67c72a6096b0800653c4bc03a8f05836618c182bc8583a0b3faecaf598ad86ed

Contents?: true

Size: 941 Bytes

Versions: 3

Compression:

Stored size: 941 Bytes

Contents

/**
@module ember
*/
/**
  Simulates a key event, e.g. `keypress`, `keydown`, `keyup` with the desired keyCode
  Example:
  ```javascript
  keyEvent('.some-jQuery-selector', 'keypress', 13).then(function() {
   // assert something
  });
  ```
  @method keyEvent
  @param {String} selector jQuery selector for finding element on the DOM
  @param {String} type the type of key event, e.g. `keypress`, `keydown`, `keyup`
  @param {Number} keyCode the keyCode of the simulated key event
  @return {RSVP.Promise<undefined>}
  @since 1.5.0
  @public
*/
export default function keyEvent(app, selector, contextOrType, typeOrKeyCode, keyCode) {
  let context, type;

  if (keyCode === undefined) {
    context = null;
    keyCode = typeOrKeyCode;
    type = contextOrType;
  } else {
    context = contextOrType;
    type = typeOrKeyCode;
  }

  return app.testHelpers.triggerEvent(selector, context, type, {
    keyCode,
    which: keyCode,
  });
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
discourse-ember-source-3.6.0.0 dist/es/ember-testing/lib/helpers/key_event.js
discourse-ember-source-3.5.1.1 dist/es/ember-testing/lib/helpers/key_event.js
discourse-ember-source-3.5.1.0 dist/dist/es/ember-testing/lib/helpers/key_event.js