@@ -76,134 +76,31 @@ describe('Migration 20.0.6 - Replace filteringOptions.filterable', () => {
76
76
77
77
// TS file tests
78
78
79
- it ( 'should remove line when filteringOptions.filterable is set to true' , async ( ) => {
80
- const input = `this.igxSimpleCombo.filteringOptions.filterable = true;` ;
81
- appTree . create ( makeScript ( 'tsRemoveTrue' ) , input ) ;
82
-
83
- const tree = await runner . runSchematic ( migrationName , { } , appTree ) ;
84
- const output = tree . readContent ( makeScript ( 'tsRemoveTrue' ) ) ;
85
-
86
- expect ( output ) . not . toContain ( 'filteringOptions.filterable' ) ;
87
- } ) ;
88
-
89
- it ( 'should replace filteringOptions.filterable = false with disableFiltering = true' , async ( ) => {
90
- const input = `this.igxSimpleCombo.filteringOptions.filterable = false;` ;
91
- appTree . create ( makeScript ( 'tsReplaceFalse' ) , input ) ;
92
-
93
- const tree = await runner . runSchematic ( migrationName , { } , appTree ) ;
94
- const output = tree . readContent ( makeScript ( 'tsReplaceFalse' ) ) ;
95
-
96
- expect ( output ) . toContain ( 'this.igxSimpleCombo.disableFiltering = true;' ) ;
97
- } ) ;
98
-
99
- it ( 'should handle the use of negative flag correctly' , async ( ) => {
100
- const input = `this.igxSimpleCombo.filteringOptions.filterable = !this.disableFilteringFlag;` ;
101
- appTree . create ( makeScript ( 'tsNegativeFlag' ) , input ) ;
102
-
103
- const tree = await runner . runSchematic ( migrationName , { } , appTree ) ;
104
- const output = tree . readContent ( makeScript ( 'tsNegativeFlag' ) ) ;
105
-
106
- expect ( output ) . toContain ( 'this.igxSimpleCombo.disableFiltering = this.disableFilteringFlag;' ) ;
107
- } ) ;
108
-
109
- it ( 'should handle the use of possitive flag correctly' , async ( ) => {
110
- const input = `this.igxSimpleCombo.filteringOptions.filterable = this.disableFilteringFlag;` ;
111
- appTree . create ( makeScript ( 'tsNegativeFlag' ) , input ) ;
112
-
113
- const tree = await runner . runSchematic ( migrationName , { } , appTree ) ;
114
- const output = tree . readContent ( makeScript ( 'tsNegativeFlag' ) ) ;
115
-
116
- expect ( output ) . toContain ( 'this.igxSimpleCombo.disableFiltering = !this.disableFilteringFlag;' ) ;
117
- } ) ;
118
-
119
- it ( 'should split filteringOptions object and move filterable out' , async ( ) => {
120
- const input = `this.igxSimpleCombo.filteringOptions = { filterable: false, caseSensitive: true };` ;
121
- appTree . create ( makeScript ( 'tsSplitObj' ) , input ) ;
122
-
123
- const tree = await runner . runSchematic ( migrationName , { } , appTree ) ;
124
- const output = tree . readContent ( makeScript ( 'tsSplitObj' ) ) ;
125
-
126
- expect ( output ) . toContain ( 'this.igxSimpleCombo.disableFiltering = true;' ) ;
127
- expect ( output ) . toContain ( 'this.igxSimpleCombo.filteringOptions = { caseSensitive: true };' ) ;
128
- expect ( output ) . not . toContain ( 'filterable' ) ;
129
- } ) ;
130
-
131
- it ( 'should not add disableFiltering again if already present when filterable is set to false' , async ( ) => {
132
- const input = `
133
- this.igxCombo.filteringOptions.filterable = false;
134
- this.igxCombo.disableFiltering = true;
135
- ` ;
136
- appTree . create ( makeScript ( 'tsDirectFalseExistingDisable' ) , input ) ;
137
-
138
- const tree = await runner . runSchematic ( migrationName , { } , appTree ) ;
139
- const output = tree . readContent ( makeScript ( 'tsDirectFalseExistingDisable' ) ) ;
140
-
141
- const occurrences = ( output . match ( / \. d i s a b l e F i l t e r i n g / g) || [ ] ) . length ;
142
-
143
- expect ( occurrences ) . toBe ( 1 ) ;
144
- expect ( output ) . not . toContain ( 'filterable' ) ;
145
- } ) ;
146
-
147
- it ( 'should not add disableFiltering again if already present when using negative flag assignment' , async ( ) => {
148
- const input = `
149
- this.igxSimpleCombo.filteringOptions.filterable = !this.flag;
150
- this.igxSimpleCombo.disableFiltering = this.flag;
151
- ` ;
152
- appTree . create ( makeScript ( 'tsNegativeFlagExistingDisable' ) , input ) ;
153
-
154
- const tree = await runner . runSchematic ( migrationName , { } , appTree ) ;
155
- const output = tree . readContent ( makeScript ( 'tsNegativeFlagExistingDisable' ) ) ;
156
-
157
- const occurrences = ( output . match ( / \. d i s a b l e F i l t e r i n g / g) || [ ] ) . length ;
158
-
159
- expect ( occurrences ) . toBe ( 1 ) ;
160
- expect ( output ) . not . toContain ( 'filterable' ) ;
161
- } ) ;
162
-
163
- it ( 'should not add disableFiltering again if already present when using positive flag assignment' , async ( ) => {
164
- const input = `
165
- this.igxSimpleCombo.filteringOptions.filterable = this.flag;
166
- this.igxSimpleCombo.disableFiltering = !this.flag;
167
- ` ;
168
- appTree . create ( makeScript ( 'tsPositiveFlagExistingDisable' ) , input ) ;
169
-
170
- const tree = await runner . runSchematic ( migrationName , { } , appTree ) ;
171
- const output = tree . readContent ( makeScript ( 'tsPositiveFlagExistingDisable' ) ) ;
172
-
173
- const occurrences = ( output . match ( / \. d i s a b l e F i l t e r i n g / g) || [ ] ) . length ;
174
-
175
- expect ( occurrences ) . toBe ( 1 ) ;
176
- expect ( output ) . not . toContain ( 'filterable' ) ;
177
- } ) ;
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.'" ;
178
83
179
- it ( 'should split filteringOptions object and remove filterable if disableFiltering is already present' , async ( ) => {
180
- const input = `
181
- this.igxCombo.filteringOptions = { filterable: false, caseSensitive: true };
182
- this.igxCombo.disableFiltering = true;
183
- ` ;
184
- appTree . create ( makeScript ( 'tsSplitObjAndDisabledFiltering' ) , input ) ;
84
+ appTree . create ( makeScript ( 'tsWarnOnDirectAssignment' ) , input ) ;
185
85
186
86
const tree = await runner . runSchematic ( migrationName , { } , appTree ) ;
187
- const output = tree . readContent ( makeScript ( 'tsSplitObjAndDisabledFiltering' ) ) ;
188
-
189
- const occurrences = ( output . match ( / \. d i s a b l e F i l t e r i n g / g) || [ ] ) . length ;
87
+ const output = tree . readContent ( makeScript ( 'tsWarnOnDirectAssignment' ) ) ;
190
88
191
- expect ( occurrences ) . toBe ( 1 ) ;
192
- expect ( output ) . toContain ( 'this.igxCombo.filteringOptions = { caseSensitive: true };' ) ;
193
- expect ( output ) . not . toContain ( 'filterable' ) ;
89
+ expect ( output ) . toContain ( expectedComment ) ;
90
+ expect ( output ) . toContain ( 'this.igxCombo.filteringOptions.filterable = false;' ) ;
194
91
} ) ;
195
92
196
- it ( 'should insert warning comment when filteringOptions is assigned from a variable ' , async ( ) => {
197
- const input = `this.igxSimpleCombo .filteringOptions = filterOpts ;` ;
93
+ it ( 'should insert warning comment before `. filteringOptions = { ... }` assignment ' , async ( ) => {
94
+ const input = `this.igxCombo .filteringOptions = { filterable: false, caseSensitive: true } ;` ;
198
95
const expectedComment = "// Manual migration needed: please use 'disableFiltering' instead of filteringOptions.filterable." +
199
96
"Since it has been deprecated.'" ;
200
97
201
- appTree . create ( makeScript ( 'tsVariableAssign ' ) , input ) ;
98
+ appTree . create ( makeScript ( 'tsWarnOnObjectAssignment ' ) , input ) ;
202
99
203
100
const tree = await runner . runSchematic ( migrationName , { } , appTree ) ;
204
- const output = tree . readContent ( makeScript ( 'tsVariableAssign ' ) ) ;
101
+ const output = tree . readContent ( makeScript ( 'tsWarnOnObjectAssignment ' ) ) ;
205
102
206
- expect ( output ) . toContain ( input ) ;
207
103
expect ( output ) . toContain ( expectedComment ) ;
104
+ expect ( output ) . toContain ( 'this.igxCombo.filteringOptions = { filterable: false, caseSensitive: true };' ) ;
208
105
} ) ;
209
106
} ) ;
0 commit comments