@@ -5,6 +5,11 @@ import {createTestCaseSetup, resolveBazelPath} from '@angular/cdk/schematics/tes
5
5
import { readFileSync } from 'fs' ;
6
6
import { MIGRATION_PATH } from '../../../../index.spec' ;
7
7
8
+
9
+ interface PackageJson {
10
+ dependencies : Record < string , string | undefined > ;
11
+ }
12
+
8
13
describe ( 'v9 HammerJS removal' , ( ) => {
9
14
const GESTURE_CONFIG_TEMPLATE_PATH = resolveBazelPath ( __dirname ,
10
15
'../../../migrations/hammer-gestures-v9/gesture-config.template' ) ;
@@ -55,11 +60,11 @@ describe('v9 HammerJS removal', () => {
55
60
it ( 'should remove hammerjs from "package.json" file' , async ( ) => {
56
61
addPackageToPackageJson ( tree , 'hammerjs' , '0.0.0' ) ;
57
62
58
- expect ( JSON . parse ( tree . readContent ( '/package.json' ) ) . dependencies [ 'hammerjs' ] ) . toBe ( '0.0.0' ) ;
63
+ expect ( ( JSON . parse ( tree . readContent ( '/package.json' ) ) as PackageJson ) . dependencies [ 'hammerjs' ] ) . toBe ( '0.0.0' ) ;
59
64
60
65
await runMigration ( ) ;
61
66
62
- expect ( JSON . parse ( tree . readContent ( '/package.json' ) ) . dependencies [ 'hammerjs' ] )
67
+ expect ( ( JSON . parse ( tree . readContent ( '/package.json' ) ) as PackageJson ) . dependencies [ 'hammerjs' ] )
63
68
. toBe ( undefined ) ;
64
69
65
70
// expect that there is a "node-package" install task. The task is
@@ -803,7 +808,7 @@ describe('v9 HammerJS removal', () => {
803
808
it ( 'should not remove hammerjs if test target compilation scope does not contain hammerjs usage' ,
804
809
async ( ) => {
805
810
addPackageToPackageJson ( tree , 'hammerjs' , '0.0.0' ) ;
806
- expect ( JSON . parse ( tree . readContent ( '/package.json' ) ) . dependencies [ 'hammerjs' ] ) . toBe ( '0.0.0' ) ;
811
+ expect ( ( JSON . parse ( tree . readContent ( '/package.json' ) ) as PackageJson ) . dependencies [ 'hammerjs' ] ) . toBe ( '0.0.0' ) ;
807
812
808
813
// we simulate a case where a component does not have any tests for. In that case,
809
814
// the test target compilation scope does not include "test.component.ts" and the
@@ -820,14 +825,14 @@ describe('v9 HammerJS removal', () => {
820
825
821
826
await runMigration ( ) ;
822
827
823
- expect ( JSON . parse ( tree . readContent ( '/package.json' ) ) . dependencies [ 'hammerjs' ] ) . toBe ( '0.0.0' ) ;
828
+ expect ( ( JSON . parse ( tree . readContent ( '/package.json' ) ) as PackageJson ) . dependencies [ 'hammerjs' ] ) . toBe ( '0.0.0' ) ;
824
829
} ) ;
825
830
826
831
it ( 'should not remove hammerjs from "package.json" file if used in one project while ' +
827
832
'unused in other project' , async ( ) => {
828
833
addPackageToPackageJson ( tree , 'hammerjs' , '0.0.0' ) ;
829
834
830
- expect ( JSON . parse ( tree . readContent ( '/package.json' ) ) . dependencies [ 'hammerjs' ] ) . toBe ( '0.0.0' ) ;
835
+ expect ( ( JSON . parse ( tree . readContent ( '/package.json' ) ) as PackageJson ) . dependencies [ 'hammerjs' ] ) . toBe ( '0.0.0' ) ;
831
836
832
837
await runner . runExternalSchematicAsync ( '@schematics/angular' , 'application' ,
833
838
{ name : 'second-project' } , tree ) . toPromise ( ) ;
@@ -840,7 +845,7 @@ describe('v9 HammerJS removal', () => {
840
845
await runMigration ( ) ;
841
846
842
847
expect ( runner . tasks . some ( t => t . name === 'node-package' ) ) . toBe ( false ) ;
843
- expect ( JSON . parse ( tree . readContent ( '/package.json' ) ) . dependencies [ 'hammerjs' ] )
848
+ expect ( ( JSON . parse ( tree . readContent ( '/package.json' ) ) as PackageJson ) . dependencies [ 'hammerjs' ] )
844
849
. toBe ( '0.0.0' ) ;
845
850
} ) ;
846
851
0 commit comments