Sha256: 739ea0980fe6cabac188f2c34b3471a5909b0e9fcb37e394307f39c5e8228b0d

Contents?: true

Size: 770 Bytes

Versions: 3

Compression:

Stored size: 770 Bytes

Contents

/**
@module ember
*/
import { focus, fireEvent } from '../events';

/**
  Clicks an element and triggers any actions triggered by the element's `click`
  event.

  Example:

  ```javascript
  click('.some-jQuery-selector').then(function() {
    // assert something
  });
  ```

  @method click
  @param {String} selector jQuery selector for finding element on the DOM
  @param {Object} context A DOM Element, Document, or jQuery to use as context
  @return {RSVP.Promise<undefined>}
  @public
*/
export default function click(app, selector, context) {
  let $el = app.testHelpers.findWithAssert(selector, context);
  let el = $el[0];

  fireEvent(el, 'mousedown');

  focus(el);

  fireEvent(el, 'mouseup');
  fireEvent(el, 'click');

  return app.testHelpers.wait();
}

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/click.js
discourse-ember-source-3.5.1.1 dist/es/ember-testing/lib/helpers/click.js
discourse-ember-source-3.5.1.0 dist/dist/es/ember-testing/lib/helpers/click.js