From 0fc8479cd1a4a50b5d11f27677bf135259bc52ae Mon Sep 17 00:00:00 2001 From: Kevin Exposito Date: Thu, 6 Aug 2020 13:02:18 -0300 Subject: [PATCH] Add test example to README --- README.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1c3da94..e471fc5 100644 --- a/README.md +++ b/README.md @@ -153,7 +153,24 @@ Components available by default include `context-element`, `fast-action`, and `f The jQuery events you need to trigger are the Hammer variant, meaning it is entirely lowercase `swiperight`, `panup`. jQuery events come with baggage, and using the `trigger` helper executes handlers in a different order than they -would otherwise execute, and in some situations will cause a handler to execute twice. If you are experiencing +would otherwise execute, and in some situations will cause a handler to execute twice. + +Example +```js +import { module, test } from 'qunit'; +import { triggerEvent } from '@ember/test-helpers'; + +module('Swipe element', function(hooks) { + + test('Can swipe element', async function(assert) { + ... + await triggerEvent('.swipeable-element', 'swipeleft'); + ... + }); +}); +``` + +If you are experiencing issues with testing gesture events, try creating your own `trigger` helper that uses native APIs instead of jQuery to trigger the event.