Issue
How can I do it? I already looked into ionic forum, google results, and didn't find anything useful. Also, I already tried triggering dblclick
, dbltap
, doubletap
, doubleClick
, and even multiple tap
and click
events, but nothing seems to work.
I know some events that I used don't even exist, I was just trying to see if ionic would recognize them somehow. Also, I tried the click events because the app runs just fine in the browser, so I thought it could work in the specs as well.
If it helps, I need this to unit test my feature. I have an ion-list
, and when an user double taps an ion-item
, it marks the item as checked. My markup currently look like this:
<ion-item on-double-tap="ctrl.toggleProductConfirmation(product)" ...
And my spec, like this:
describe('when checking an item', function() {
beforeEach(function() {
this.element.find('ion-item').eq(0).trigger('doubletap');
});
** specs here **
One last detail: I use phantom JS to run my specs.
Solution
I asked the same question in the ionic forum, and, fortunately, someone was able to help me.
In ionic, apparently you can always use ionic.trigger
to trigger any event you want, and this includes doubletap
(http://ionicframework.com/docs/api/utility/ionic.EventController/#trigger).
The docs are a little confusing, so I'll post my code here to help someone with the same problem:
ionic.trigger('doubletap', { target: this.element.find('ion-item').get(0) });
Because I'm using jquery in my specs, I had to use get(0)
to retrieve the DOM element itself, as passing the jQuery object directly didn't work for me.
Link to my thread in ionic forum: https://forum.ionicframework.com/t/how-to-programmatically-trigger-doubletap-event/41264
Answered By - Denis Lins
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.