I use tap event in a angular attribute directive, but I can't trigger tap event on an element in it's test.
So, I want to know how can I manually trigger the tap event.Thanks
Hammer has it's own set of unit tests and it even has a gesture simulator for testing purposes. The simulator repository can be found here. Be warned, I don't know of @jtangelder ever intended for this to be used outside of hammer but it seems to work for him. Looking at the existing unit tests you can do something like this:
Simulator.gestures.press(el, null, function() {
start();
deepEqual(events, {
press: true
});
});
Though there's no documentation that I can see for the simulator, so you're going to have to look at the source code for more advanced usage. You can also search for "Simulator" in this repository for more examples.
Failing that you can look at the source code for the simulator. Basically you need an event you can use with EventTarget.dispatchEvent()
@enrichit
Thanks for your replies!
I have seen the code of test_gestures.js and I have tried to use Simulator.gesture.tap, but it seems that there is no tap event has been triggered.
I can't understand it's last spec.What is a invalid tap?How can I trigger a tap event?
So confused......
Any news on this? What is the best way to simulate clicks? Would be a huge help. Thanks
Most helpful comment
Any news on this? What is the best way to simulate clicks? Would be a huge help. Thanks