@@ -3,104 +3,101 @@ import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/te
33import  {  setupTestTree  }  from  '../common/setup.spec' ; 
44
55describe ( 'Migration 20.0.6 - Replace filteringOptions.filterable' ,  ( )  =>  { 
6-     let  appTree : UnitTestTree ; 
7-     const  runner  =  new  SchematicTestRunner ( 
8-         'ig-migrate' , 
9-         path . join ( __dirname ,  '../migration-collection.json' ) 
10-     ) ; 
11-     const  migrationName  =  'migration-48' ; 
12-     const  makeTemplate  =  ( name : string )  =>  `/testSrc/appPrefix/component/${ name }  .component.html` ; 
13-     const  makeScript  =  ( name : string )  =>  `/testSrc/appPrefix/component/${ name }  .component.ts` ; 
14-     const  components  =  [ 'igx-simple-combo' ,  'igx-combo' ] ; 
15- 
16- 
17- 
18-     beforeEach ( ( )  =>  { 
19-         appTree  =  setupTestTree ( ) ; 
20-     } ) ; 
21- 
22-     it ( 'should replace simple inline filteringOptions.filterable true with default behavior of the simple combo' ,  async  ( )  =>  { 
23-         components . forEach ( async  component  => { 
24-             const  input  =  `<${ component }   [filteringOptions]="{ filterable: true }"></${ component }  >` ; 
25-             appTree . create ( makeTemplate ( `${ component }  -inline-true` ) ,  input ) ; 
26- 
27-             const  tree  =  await  runner . runSchematic ( migrationName ,  { } ,  appTree ) ; 
28-             const  output  =  tree . readContent ( makeTemplate ( `${ component }  -inline-true` ) ) ; 
29- 
30-             expect ( output ) . not . toContain ( '[disableFiltering]' ) ; 
31-             expect ( output ) . not . toContain ( 'filterable' ) ; 
32-         } ) ; 
33-     } ) ; 
34- 
35-     it ( 'should handle mixed object literal correctly' ,  async  ( )  =>  { 
36-         components . forEach ( async  component  => { 
37-             const  input  =  `<${ component }   [filteringOptions]="{ filterable: false, caseSensitive: true }"></${ component }  >` ; 
38-             appTree . create ( makeTemplate ( `${ component }  -inline2` ) ,  input ) ; 
39- 
40-             const  tree  =  await  runner . runSchematic ( migrationName ,  { } ,  appTree ) ; 
41-             const  output  =  tree . readContent ( makeTemplate ( `${ component }  -inline2` ) ) ; 
42- 
43-             expect ( output ) . toContain ( `[disableFiltering]="true"` ) ; 
44-             expect ( output ) . toContain ( `[filteringOptions]="{ caseSensitive: true }"` ) ; 
45-         } ) ; 
6+   let  appTree : UnitTestTree ; 
7+   const  runner  =  new  SchematicTestRunner ( 
8+     'ig-migrate' , 
9+     path . join ( __dirname ,  '../migration-collection.json' ) 
10+   ) ; 
11+   const  migrationName  =  'migration-48' ; 
12+   const  makeTemplate  =  ( name : string )  =>  `/testSrc/appPrefix/component/${ name }  .component.html` ; 
13+   const  makeScript  =  ( name : string )  =>  `/testSrc/appPrefix/component/${ name }  .component.ts` ; 
14+   const  components  =  [ 'igx-simple-combo' ,  'igx-combo' ] ; 
15+ 
16+   const  warnMsg  = 
17+     "Manual migration needed: please use 'disableFiltering' instead of filteringOptions.filterable. Since it has been deprecated." ; 
18+ 
19+   beforeEach ( ( )  =>  { 
20+     appTree  =  setupTestTree ( ) ; 
21+   } ) ; 
22+ 
23+   it ( 'should replace simple inline filteringOptions.filterable true with default behavior of the simple combo' ,  async  ( )  =>  { 
24+     components . forEach ( async  component  => { 
25+       const  input  =  `<${ component }   [filteringOptions]="{ filterable: true }"></${ component }  >` ; 
26+       appTree . create ( makeTemplate ( `${ component }  -inline-true` ) ,  input ) ; 
27+ 
28+       const  tree  =  await  runner . runSchematic ( migrationName ,  { } ,  appTree ) ; 
29+       const  output  =  tree . readContent ( makeTemplate ( `${ component }  -inline-true` ) ) ; 
30+ 
31+       expect ( output ) . not . toContain ( '[disableFiltering]' ) ; 
32+       expect ( output ) . not . toContain ( 'filterable' ) ; 
33+      } ) ; 
34+   } ) ; 
35+ 
36+   it ( 'should handle mixed object literal correctly' ,  async  ( )  =>  { 
37+     components . forEach ( async  component  => { 
38+       const  input  =  `<${ component }   [filteringOptions]="{ filterable: false, caseSensitive: true }"></${ component }  >` ; 
39+       appTree . create ( makeTemplate ( `${ component }  -inline2` ) ,  input ) ; 
40+ 
41+       const  tree  =  await  runner . runSchematic ( migrationName ,  { } ,  appTree ) ; 
42+       const  output  =  tree . readContent ( makeTemplate ( `${ component }  -inline2` ) ) ; 
43+ 
44+       expect ( output ) . toContain ( `[disableFiltering]="true"` ) ; 
45+       expect ( output ) . toContain ( `[filteringOptions]="{ caseSensitive: true }"` ) ; 
46+       expect ( output ) . not . toContain ( 'filterable' ) ; 
4647    } ) ; 
48+   } ) ; 
4749
48-     it ( 'should warn on variable reference' ,  async  ( )  =>  { 
49-         components . forEach ( async  component  => { 
50-             const  input  =  `<${ component }   [filteringOptions]="filterOpts""></${ component }  >` ; 
51-             const  warnMsg  =  "Manual migration needed: please use 'disableFiltering' instead of filteringOptions.filterable."  + 
52-             "Since it has been deprecated.'" ; 
53- 
54-             appTree . create ( makeTemplate ( `${ component }  -referenceInTsFile` ) ,  input ) ; 
50+   it ( 'should warn on variable reference' ,  async  ( )  =>  { 
51+     for  ( const  component  of  components )  { 
52+       const  input  =  `<${ component }   [filteringOptions]="filterOpts"></${ component }  >` ; 
5553
56-             const  tree  =  await  runner . runSchematic ( migrationName ,  { } ,  appTree ) ; 
57-             const  output  =  tree . readContent ( makeTemplate ( `${ component }  -referenceInTsFile` ) ) ; 
54+       appTree . create ( makeTemplate ( `${ component }  -referenceInTsFile` ) ,  input ) ; 
5855
59-             expect ( output ) . toContain ( '[filteringOptions]' ) ; 
60-             expect ( output ) . toContain ( warnMsg ) ; 
61-         } ) ; 
62-     } ) ; 
56+       const  tree  =  await  runner . runSchematic ( migrationName ,  { } ,  appTree ) ; 
57+       const  output  =  tree . readContent ( makeTemplate ( `${ component }  -referenceInTsFile` ) ) ; 
6358
64-     it ( 'should skip adding new [disableFiltering] if already present on igx-combo' ,  async  ( )  =>  { 
65-         const  input  =  `<igx-combo [disableFiltering]="true" [filteringOptions]="{ filterable: false }"></igx-combo>` ; 
66-         appTree . create ( makeTemplate ( 'combo-has-disableFiltering' ) ,  input ) ; 
59+       expect ( output ) . toContain ( '[filteringOptions]' ) ; 
60+       expect ( output ) . toContain ( warnMsg ) ; 
61+     } 
62+   } ) ; 
6763
68-         const  tree  =  await  runner . runSchematic ( migrationName ,  { } ,  appTree ) ; 
69-         const  output  =  tree . readContent ( makeTemplate ( 'combo-has-disableFiltering' ) ) ; 
64+   it ( 'should skip adding new [disableFiltering] if already present on igx-combo' ,  async  ( )  =>  { 
65+     const  input  =  `<igx-combo [disableFiltering]="true" [filteringOptions]="{ filterable: false }"></igx-combo>` ; 
66+     appTree . create ( makeTemplate ( 'combo-has-disableFiltering' ) ,  input ) ; 
7067
71-         const  occurrences  =  ( output . match ( / \[ d i s a b l e F i l t e r i n g \] / g)  ||  [ ] ) . length ; 
68+     const  tree  =  await  runner . runSchematic ( migrationName ,  { } ,  appTree ) ; 
69+     const  output  =  tree . readContent ( makeTemplate ( 'combo-has-disableFiltering' ) ) ; 
7270
73-         expect ( occurrences ) . toBe ( 1 ) ; 
74-         expect ( output ) . not . toContain ( 'filterable' ) ; 
75-     } ) ; 
71+     const  occurrences  =  ( output . match ( / \[ d i s a b l e F i l t e r i n g \] / g)  ||  [ ] ) . length ; 
7672
77-     // TS file tests 
73+     expect ( occurrences ) . toBe ( 1 ) ; 
74+     expect ( output ) . not . toContain ( 'filterable' ) ; 
75+   } ) ; 
7876
79-     it ( 'should insert warning comment before `.filteringOptions.filterable = ...` assignment' ,  async  ( )  =>  { 
80-         const  input  =  `this.igxCombo.filteringOptions.filterable = false;` ; 
81-         const  expectedComment  =  "// Manual migration needed: please use 'disableFiltering' instead of filteringOptions.filterable."  + 
82-             "Since it has been deprecated.'" ; 
77+   // TS file tests 
8378
84-         appTree . create ( makeScript ( 'tsWarnOnDirectAssignment' ) ,  input ) ; 
79+   it ( 'should insert warning comment before `.filteringOptions.filterable = ...` assignment' ,  async  ( )  =>  { 
80+     const  input  =  `this.igxCombo.filteringOptions.filterable = false;` ; 
81+     const  expectedComment  =  `// ${ warnMsg }  ` ; 
8582
86-         const  tree  =  await  runner . runSchematic ( migrationName ,  { } ,  appTree ) ; 
87-         const  output  =  tree . readContent ( makeScript ( 'tsWarnOnDirectAssignment' ) ) ; 
83+     appTree . create ( makeScript ( 'tsWarnOnDirectAssignment' ) ,  input ) ; 
8884
89-         expect ( output ) . toContain ( expectedComment ) ; 
90-         expect ( output ) . toContain ( 'this.igxCombo.filteringOptions.filterable = false;' ) ; 
91-     } ) ; 
85+     const  tree  =  await  runner . runSchematic ( migrationName ,  { } ,  appTree ) ; 
86+     const  output  =  tree . readContent ( makeScript ( 'tsWarnOnDirectAssignment' ) ) ; 
9287
93-     it ( 'should insert warning comment before `.filteringOptions = { ... }` assignment' ,  async  ( )  =>  { 
94-         const  input  =  `this.igxCombo.filteringOptions = { filterable: false, caseSensitive: true };` ; 
95-         const  expectedComment  =  "// Manual migration needed: please use 'disableFiltering' instead of filteringOptions.filterable."  + 
96-             "Since it has been deprecated.'" ; 
88+     expect ( output ) . toContain ( expectedComment ) ; 
89+     expect ( output ) . toContain ( 'this.igxCombo.filteringOptions.filterable = false;' ) ; 
90+   } ) ; 
9791
98-         appTree . create ( makeScript ( 'tsWarnOnObjectAssignment' ) ,  input ) ; 
92+   it ( 'should insert warning comment before `.filteringOptions = { ... }` assignment' ,  async  ( )  =>  { 
93+     const  input  =  `this.igxCombo.filteringOptions = { filterable: false, caseSensitive: true };` ; 
94+     const  expectedComment  =  `// ${ warnMsg }  ` ; 
95+     appTree . create ( makeScript ( 'tsWarnOnObjectAssignment' ) ,  input ) ; 
9996
100-          const  tree  =  await  runner . runSchematic ( migrationName ,  { } ,  appTree ) ; 
101-          const  output  =  tree . readContent ( makeScript ( 'tsWarnOnObjectAssignment' ) ) ; 
97+     const  tree  =  await  runner . runSchematic ( migrationName ,  { } ,  appTree ) ; 
98+     const  output  =  tree . readContent ( makeScript ( 'tsWarnOnObjectAssignment' ) ) ; 
10299
103-          expect ( output ) . toContain ( expectedComment ) ; 
104-          expect ( output ) . toContain ( 'this.igxCombo.filteringOptions = { filterable: false, caseSensitive: true };' ) ; 
105-      } ) ; 
100+     expect ( output ) . toContain ( expectedComment ) ; 
101+     expect ( output ) . toContain ( 'this.igxCombo.filteringOptions = { filterable: false, caseSensitive: true };' ) ; 
102+   } ) ; 
106103} ) ; 
0 commit comments