Last active
June 10, 2017 03:32
-
-
Save magistrula/6fd770808b5faa74ce0ee9db0111634e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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