@@ -379,27 +379,31 @@ describe('MDCChipFoundation', () => {
379
379
const mockEvt = {
380
380
type : 'click' ,
381
381
stopPropagation : jasmine . createSpy ( 'stopPropagation' ) ,
382
+ preventDefault : jasmine . createSpy ( 'preventDefault' ) ,
382
383
key : '' ,
383
384
} ;
384
385
385
386
foundation . handleTrailingIconInteraction ( mockEvt ) ;
386
387
expect ( mockAdapter . notifyTrailingIconInteraction )
387
388
. toHaveBeenCalledTimes ( 1 ) ;
388
389
expect ( mockEvt . stopPropagation ) . toHaveBeenCalledTimes ( 1 ) ;
390
+ expect ( mockEvt . preventDefault ) . toHaveBeenCalledTimes ( 1 ) ;
389
391
390
392
mockEvt . type = 'keydown' ;
391
393
mockEvt . key = ' ' ;
392
394
foundation . handleTrailingIconInteraction ( mockEvt ) ;
393
395
expect ( mockAdapter . notifyTrailingIconInteraction )
394
396
. toHaveBeenCalledTimes ( 2 ) ;
395
397
expect ( mockEvt . stopPropagation ) . toHaveBeenCalledTimes ( 2 ) ;
398
+ expect ( mockEvt . preventDefault ) . toHaveBeenCalledTimes ( 2 ) ;
396
399
397
400
mockEvt . type = 'keydown' ;
398
401
mockEvt . key = 'Enter' ;
399
402
foundation . handleTrailingIconInteraction ( mockEvt ) ;
400
403
expect ( mockAdapter . notifyTrailingIconInteraction )
401
404
. toHaveBeenCalledTimes ( 3 ) ;
402
405
expect ( mockEvt . stopPropagation ) . toHaveBeenCalledTimes ( 3 ) ;
406
+ expect ( mockEvt . preventDefault ) . toHaveBeenCalledTimes ( 3 ) ;
403
407
} ) ;
404
408
405
409
it ( `#handleTrailingIconInteraction adds ${
@@ -409,13 +413,15 @@ describe('MDCChipFoundation', () => {
409
413
const mockEvt = {
410
414
type : 'click' ,
411
415
stopPropagation : jasmine . createSpy ( 'stopPropagation' ) ,
416
+ preventDefault : jasmine . createSpy ( 'preventDefault' ) ,
412
417
} ;
413
418
414
419
foundation . handleTrailingIconInteraction ( mockEvt ) ;
415
420
416
421
expect ( foundation . getShouldRemoveOnTrailingIconClick ( ) ) . toBe ( true ) ;
417
422
expect ( mockAdapter . addClass ) . toHaveBeenCalledWith ( cssClasses . CHIP_EXIT ) ;
418
423
expect ( mockEvt . stopPropagation ) . toHaveBeenCalled ( ) ;
424
+ expect ( mockEvt . preventDefault ) . toHaveBeenCalled ( ) ;
419
425
} ) ;
420
426
421
427
it ( `#handleTrailingIconInteraction does not add ${
@@ -426,6 +432,7 @@ describe('MDCChipFoundation', () => {
426
432
const mockEvt = {
427
433
type : 'click' ,
428
434
stopPropagation : jasmine . createSpy ( 'stopPropagation' ) ,
435
+ preventDefault : jasmine . createSpy ( 'preventDefault' ) ,
429
436
} ;
430
437
431
438
foundation . setShouldRemoveOnTrailingIconClick ( false ) ;
@@ -435,6 +442,7 @@ describe('MDCChipFoundation', () => {
435
442
expect ( mockAdapter . addClass )
436
443
. not . toHaveBeenCalledWith ( cssClasses . CHIP_EXIT ) ;
437
444
expect ( mockEvt . stopPropagation ) . toHaveBeenCalled ( ) ;
445
+ expect ( mockEvt . preventDefault ) . toHaveBeenCalled ( ) ;
438
446
} ) ;
439
447
440
448
it ( '#handleKeydown emits custom event with appropriate keys' , ( ) => {
0 commit comments