@@ -297,6 +297,32 @@ test('on touchstart calls preventDefault', () => {
297
297
td . verify ( evt . preventDefault ( ) ) ;
298
298
} ) ;
299
299
300
+ test ( 'on touchmove call returns if is IE' , ( ) => {
301
+ const { foundation, mockAdapter } = setupTest ( ) ;
302
+ const handlers = captureHandlers ( mockAdapter , 'registerHandler' ) ;
303
+ const evt = {
304
+ preventDefault : td . func ( 'evt.preventDefault' ) ,
305
+ } ;
306
+
307
+ td . when ( mockAdapter . detectIsIE ( ) ) . thenReturn ( true ) ;
308
+ foundation . init ( ) ;
309
+ handlers . touchmove ( evt ) ;
310
+ td . verify ( evt . preventDefault ( ) , { times : 0 } ) ;
311
+ } ) ;
312
+
313
+ test ( 'on touchmove call returns if pointerType not touch' , ( ) => {
314
+ const { foundation, mockAdapter } = setupTest ( ) ;
315
+ const handlers = captureHandlers ( mockAdapter , 'registerHandler' ) ;
316
+ const evt = {
317
+ preventDefault : td . func ( 'evt.preventDefault' ) ,
318
+ pointerType : 'other' ,
319
+ } ;
320
+
321
+ foundation . init ( ) ;
322
+ handlers . touchmove ( evt ) ;
323
+ td . verify ( evt . preventDefault ( ) , { times : 0 } ) ;
324
+ } ) ;
325
+
300
326
test ( 'on mousedown calls preventDefault' , ( ) => {
301
327
const { foundation, mockAdapter } = setupTest ( ) ;
302
328
const handlers = captureHandlers ( mockAdapter , 'registerRootHandler' ) ;
@@ -318,6 +344,27 @@ test('on mousedown calls preventDefault', () => {
318
344
td . verify ( evt . preventDefault ( ) ) ;
319
345
} ) ;
320
346
347
+ test ( 'on mousedown returns if target not parentElement' , ( ) => {
348
+ const { foundation, mockAdapter } = setupTest ( ) ;
349
+ const handlers = captureHandlers ( mockAdapter , 'registerRootHandler' ) ;
350
+ const target = { } ;
351
+ const evt = {
352
+ preventDefault : td . func ( 'evt.preventDefault' ) ,
353
+ target,
354
+ } ;
355
+
356
+ const nativeInput = {
357
+ max : 100 ,
358
+ parentElement : { } ,
359
+ getBoundingClientRect : ( ) => ( { width : 100 , left : 0 , top : 10 } ) ,
360
+ dispatchEvent : ( ) => undefined ,
361
+ } ;
362
+ td . when ( mockAdapter . getNativeInput ( ) ) . thenReturn ( nativeInput ) ;
363
+ foundation . init ( ) ;
364
+ handlers . mousedown ( evt ) ;
365
+ td . verify ( evt . preventDefault ( ) , { times : 0 } ) ;
366
+ } ) ;
367
+
321
368
test ( 'on mousedown calls dispatchEvent' , ( ) => {
322
369
const { foundation, mockAdapter } = setupTest ( ) ;
323
370
const handlers = captureHandlers ( mockAdapter , 'registerRootHandler' ) ;
@@ -339,6 +386,33 @@ test('on mousedown calls dispatchEvent', () => {
339
386
td . verify ( nativeInput . dispatchEvent ( td . matchers . anything ( ) ) ) ;
340
387
} ) ;
341
388
389
+ test ( "#on mousedown dispatches a mouse event with the supplied data where MouseEvent isn't available" , ( ) => {
390
+ const { foundation, mockAdapter } = setupTest ( ) ;
391
+ const handlers = captureHandlers ( mockAdapter , 'registerRootHandler' ) ;
392
+ const target = { } ;
393
+ const evt = {
394
+ preventDefault : td . func ( 'evt.preventDefault' ) ,
395
+ target,
396
+ } ;
397
+
398
+ const nativeInput = {
399
+ max : 100 ,
400
+ parentElement : target ,
401
+ getBoundingClientRect : ( ) => ( { width : 100 , left : 0 , top : 10 } ) ,
402
+ dispatchEvent : td . func ( 'input.dispatchEvent' ) ,
403
+ } ;
404
+ td . when ( mockAdapter . getNativeInput ( ) ) . thenReturn ( nativeInput ) ;
405
+ foundation . init ( ) ;
406
+ const { MouseEvent } = window ;
407
+ window . MouseEvent = undefined ;
408
+ try {
409
+ handlers . mousedown ( evt ) ;
410
+ } finally {
411
+ window . MouseEvent = MouseEvent ;
412
+ }
413
+ td . verify ( nativeInput . dispatchEvent ( td . matchers . anything ( ) ) ) ;
414
+ } ) ;
415
+
342
416
test ( 'on mouseup calls target.blur()' , ( ) => {
343
417
const { foundation, mockAdapter } = setupTest ( ) ;
344
418
const handlers = captureHandlers ( mockAdapter , 'registerHandler' ) ;
0 commit comments