@@ -296,3 +296,55 @@ test('Interaction.start', t => {
296
296
297
297
t . end ( ) ;
298
298
} ) ;
299
+
300
+ test ( 'action-{start,move,end} signal listeners' , t => {
301
+ const Interactable = require ( '../src/Interactable' ) ;
302
+ const Interaction = require ( '../src/Interaction' ) ;
303
+
304
+ const interaction = new Interaction ( ) ;
305
+ const element = { } ;
306
+ const interactable = new Interactable ( 'TEST' , { context : { } } ) ;
307
+
308
+ let interactingInStartListener = null ;
309
+
310
+ interaction . target = interactable ;
311
+ interaction . element = element ;
312
+ interaction . prepared = { name : 'TEST' } ;
313
+
314
+ interactable . events . on ( 'TESTstart' , event => {
315
+ interactingInStartListener = event . interaction . interacting ( ) ;
316
+ } ) ;
317
+
318
+ Interaction . signals . fire ( 'action-start' , { interaction, event : { } } ) ;
319
+
320
+ t . ok ( interactingInStartListener , 'start event was fired correctly' ) ;
321
+
322
+ interactable . unset ( ) ;
323
+
324
+ t . end ( ) ;
325
+ } ) ;
326
+
327
+ test ( 'stop interaction from start event' , t => {
328
+ const Interactable = require ( '../src/Interactable' ) ;
329
+ const Interaction = require ( '../src/Interaction' ) ;
330
+
331
+ const interaction = new Interaction ( ) ;
332
+ const element = { } ;
333
+ const interactable = new Interactable ( 'TEST' , { context : { } } ) ;
334
+
335
+ interaction . target = interactable ;
336
+ interaction . element = element ;
337
+ interaction . prepared = { name : 'TEST' } ;
338
+
339
+ interactable . events . on ( 'TESTstart' , event => {
340
+ event . interaction . stop ( ) ;
341
+ } ) ;
342
+
343
+ Interaction . signals . fire ( 'action-start' , { interaction, event : { } } ) ;
344
+
345
+ t . notOk ( interaction . interacting ( ) , 'interaction can be stopped from start event listener' ) ;
346
+
347
+ interactable . unset ( ) ;
348
+
349
+ t . end ( ) ;
350
+ } ) ;
0 commit comments