Skip to content

Instantly share code, notes, and snippets.

@magistrula
Last active June 10, 2017 03:32
Show Gist options
  • Save magistrula/6fd770808b5faa74ce0ee9db0111634e to your computer and use it in GitHub Desktop.
Save magistrula/6fd770808b5faa74ce0ee9db0111634e to your computer and use it in GitHub Desktop.
// Page Object Helper.
// See http://ember-cli-page-object.js.org/docs/v1.8.x/components#custom-helper
import Ember from 'ember';
import { findElementWithAssert } from 'ember-cli-page-object';
function dynamicTriggerable(eventName, selector, options = {}) {
return {
isDescriptor: true,
get() {
return function(eventProperties = {}) {
const el = findElementWithAssert(this, selector, options);
const event = Ember.$.Event(
eventName,
Object.assign({}, options.eventProperties, eventProperties)
);
el.trigger(event);
return this;
};
}
};
}
// Page Object
// ...
searchInput: {
scope: '.t-grid-search-input',
keyup: dynamicTriggerable('keyup')
}
// ...
// Tests
page.searchInput.keyup({ keyCode: foo })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment