@@ -297,7 +297,7 @@ describe('v9 HammerJS removal', () => {
297
297
} ) ;
298
298
} ) ;
299
299
300
- describe ( 'hammerjs used' , ( ) => {
300
+ describe ( 'hammerjs used programmatically ' , ( ) => {
301
301
beforeEach ( ( ) => {
302
302
appendContent ( '/projects/cdk-testing/src/main.ts' , `
303
303
import 'hammerjs';
@@ -335,7 +335,7 @@ describe('v9 HammerJS removal', () => {
335
335
await runMigration ( ) ;
336
336
337
337
expect ( tree . readContent ( '/projects/cdk-testing/src/main.ts' ) )
338
- . not . toContain ( `import 'hammerjs';` ) ;
338
+ . not . toContain ( `import 'hammerjs';` ) ;
339
339
} ) ;
340
340
341
341
it ( 'should not create gesture config if hammer is only used programmatically' , async ( ) => {
@@ -388,10 +388,93 @@ describe('v9 HammerJS removal', () => {
388
388
})
389
389
export class TestModule {}` ) ;
390
390
} ) ;
391
+ } ) ;
392
+
393
+ describe ( 'used in template with standard HammerJS events' , ( ) => {
394
+ beforeEach ( ( ) => {
395
+ appendContent ( '/projects/cdk-testing/src/main.ts' , `
396
+ import 'hammerjs';
397
+ ` ) ;
398
+ } ) ;
391
399
392
- it ( 'should create gesture config file if used in template ' , async ( ) => {
400
+ it ( 'should not create gesture config file' , async ( ) => {
393
401
writeFile ( '/projects/cdk-testing/src/app/app.component.html' , `
394
- <span (longpress)="onPress()"></span>
402
+ <span (panstart)="onPanStart()"></span>
403
+ ` ) ;
404
+
405
+ await runMigration ( ) ;
406
+
407
+ expect ( tree . readContent ( '/projects/cdk-testing/src/main.ts' ) ) . toContain ( `import 'hammerjs';` ) ;
408
+ expect ( tree . exists ( '/projects/cdk-testing/src/gesture-config.ts' ) ) . toBe ( false ) ;
409
+ } ) ;
410
+
411
+ it ( 'should not setup custom gesture config provider in root module' , async ( ) => {
412
+ writeFile ( '/projects/cdk-testing/src/app/app.component.html' , `
413
+ <span (panstart)="onPanStart()"></span>
414
+ ` ) ;
415
+
416
+ await runMigration ( ) ;
417
+
418
+ expect ( tree . readContent ( '/projects/cdk-testing/src/app/app.module.ts' ) ) . toContain ( dedent `\
419
+ import { BrowserModule, HammerModule } from '@angular/platform-browser';
420
+ import { NgModule } from '@angular/core';
421
+
422
+ import { AppComponent } from './app.component';
423
+
424
+ @NgModule({
425
+ declarations: [
426
+ AppComponent
427
+ ],
428
+ imports: [
429
+ BrowserModule,
430
+ HammerModule
431
+ ],
432
+ providers: [],
433
+ bootstrap: [AppComponent]
434
+ })
435
+ export class AppModule { }` ) ;
436
+ } ) ;
437
+
438
+ it ( 'should remove references to the deprecated gesture config' , async ( ) => {
439
+ writeFile ( '/projects/cdk-testing/src/app/app.component.html' , `
440
+ <span (panstart)="onPanStart()"></span>
441
+ ` ) ;
442
+
443
+ writeFile ( '/projects/cdk-testing/src/test.module.ts' , dedent `
444
+ import {NgModule} from '@angular/core';
445
+ import {HAMMER_GESTURE_CONFIG} from '@angular/platform-browser';
446
+ import {GestureConfig} from '@angular/material/core';
447
+
448
+ @NgModule({
449
+ providers: [{provide: HAMMER_GESTURE_CONFIG, useClass: GestureConfig}]
450
+ })
451
+ export class TestModule {}
452
+ ` ) ;
453
+
454
+ await runMigration ( ) ;
455
+
456
+ expect ( tree . readContent ( '/projects/cdk-testing/src/test.module.ts' ) ) . toContain ( dedent `
457
+ import {NgModule} from '@angular/core';
458
+
459
+ @NgModule({
460
+ providers: []
461
+ })
462
+ export class TestModule {}` ) ;
463
+ } ) ;
464
+ } ) ;
465
+
466
+ describe ( 'used in template with custom Material gesture events' , ( ) => {
467
+ beforeEach ( ( ) => {
468
+ appendContent ( '/projects/cdk-testing/src/main.ts' , `
469
+ import 'hammerjs';
470
+ ` ) ;
471
+ } ) ;
472
+
473
+ it ( 'should create gesture config file' , async ( ) => {
474
+ writeFile ( '/projects/cdk-testing/src/app/app.component.html' , `
475
+ <span (panstart)="onPanStart()">
476
+ <span (longpress)="onPress()"></span>
477
+ </span>
395
478
` ) ;
396
479
397
480
await runMigration ( ) ;
@@ -441,7 +524,7 @@ describe('v9 HammerJS removal', () => {
441
524
442
525
it ( 'should create gesture config file if used in template and programmatically' , async ( ) => {
443
526
writeFile ( '/projects/cdk-testing/src/app/app.component.html' , `
444
- <span (rotatemove )="onRotate ($event)"></span>
527
+ <span (slide )="onSlide ($event)"></span>
445
528
` ) ;
446
529
447
530
writeFile ( '/projects/cdk-testing/src/app/hammer.ts' , `
@@ -478,7 +561,7 @@ describe('v9 HammerJS removal', () => {
478
561
479
562
it ( 'should rewrite references to gesture config' , async ( ) => {
480
563
writeFile ( '/projects/cdk-testing/src/app/app.component.html' , `
481
- <span (panstart )="onPanStart ()"></span>
564
+ <span (slidestart )="onSlideStart ()"></span>
482
565
` ) ;
483
566
484
567
writeFile ( '/projects/cdk-testing/src/nested/test.module.ts' , dedent `
@@ -515,7 +598,7 @@ describe('v9 HammerJS removal', () => {
515
598
516
599
it ( 'should rewrite references to gesture config without causing conflicts' , async ( ) => {
517
600
writeFile ( '/projects/cdk-testing/src/app/app.component.html' , `
518
- <span (panstart )="onPanStart ()"></span>
601
+ <span (slideend )="onSlideEnd ()"></span>
519
602
` ) ;
520
603
521
604
writeFile ( '/projects/cdk-testing/src/test.module.ts' , dedent `
@@ -553,15 +636,15 @@ describe('v9 HammerJS removal', () => {
553
636
554
637
it ( 'should set up Hammer gestures in app module' , async ( ) => {
555
638
writeFile ( '/projects/cdk-testing/src/app/app.component.html' , `
556
- <span (pinch )="onPinch ($event)"></span>
639
+ <span (longpress )="onLongPress ($event)"></span>
557
640
` ) ;
558
641
559
642
await runMigration ( ) ;
560
643
561
644
expect ( tree . readContent ( '/projects/cdk-testing/src/main.ts' ) ) . toContain ( `import 'hammerjs';` ) ;
562
645
expect ( tree . exists ( '/projects/cdk-testing/src/gesture-config.ts' ) ) . toBe ( true ) ;
563
646
expect ( tree . readContent ( '/projects/cdk-testing/src/app/app.module.ts' ) ) . toContain ( dedent `\
564
- import { BrowserModule, HammerModule, HAMMER_GESTURE_CONFIG } from '@angular/platform-browser';
647
+ import { BrowserModule, HAMMER_GESTURE_CONFIG, HammerModule } from '@angular/platform-browser';
565
648
import { NgModule } from '@angular/core';
566
649
567
650
import { AppComponent } from './app.component';
@@ -584,7 +667,7 @@ describe('v9 HammerJS removal', () => {
584
667
it ( 'should add gesture config provider to app module if module is referenced through ' +
585
668
're-exports in bootstrap' , async ( ) => {
586
669
writeFile ( '/projects/cdk-testing/src/app/app.component.html' , `
587
- <span (pinch )="onPinch ($event)"></span>
670
+ <span (slide )="onSlide ($event)"></span>
588
671
` ) ;
589
672
590
673
writeFile ( '/projects/cdk-testing/src/main.ts' , `
@@ -610,7 +693,7 @@ describe('v9 HammerJS removal', () => {
610
693
expect ( tree . readContent ( '/projects/cdk-testing/src/main.ts' ) ) . toContain ( `import 'hammerjs';` ) ;
611
694
expect ( tree . exists ( '/projects/cdk-testing/src/gesture-config.ts' ) ) . toBe ( true ) ;
612
695
expect ( tree . readContent ( '/projects/cdk-testing/src/app/app.module.ts' ) ) . toContain ( dedent `\
613
- import { BrowserModule, HammerModule, HAMMER_GESTURE_CONFIG } from '@angular/platform-browser';
696
+ import { BrowserModule, HAMMER_GESTURE_CONFIG, HammerModule } from '@angular/platform-browser';
614
697
import { NgModule } from '@angular/core';
615
698
616
699
import { AppComponent } from './app.component';
@@ -632,7 +715,7 @@ describe('v9 HammerJS removal', () => {
632
715
633
716
it ( 'should not add gesture config provider multiple times if already provided' , async ( ) => {
634
717
writeFile ( '/projects/cdk-testing/src/app/app.component.html' , `
635
- <span (pinch )="onPinch ($event)"></span>
718
+ <span (slide )="onSlide ($event)"></span>
636
719
` ) ;
637
720
638
721
writeFile ( '/projects/cdk-testing/src/app/app.module.ts' , dedent `
@@ -674,7 +757,7 @@ describe('v9 HammerJS removal', () => {
674
757
675
758
it ( 'should not add HammerModule multiple times if already provided' , async ( ) => {
676
759
writeFile ( '/projects/cdk-testing/src/app/app.component.html' , `
677
- <span (pinch )="onPinch ($event)"></span>
760
+ <span (slide )="onSlide ($event)"></span>
678
761
` ) ;
679
762
680
763
writeFile ( '/projects/cdk-testing/src/app/app.module.ts' , dedent `
0 commit comments