@@ -210,6 +210,85 @@ describe("migrateComponents", () => {
210
210
) ;
211
211
} ) ;
212
212
213
+ it ( "should detect Ionic components within *ngIf expressions" , ( ) => {
214
+ const project = new Project ( { useInMemoryFileSystem : true } ) ;
215
+
216
+ const component = `
217
+ import { Component } from "@angular/core";
218
+
219
+ @Component({
220
+ selector: 'my-component',
221
+ template: \`
222
+ <ion-header [translucent]="true">
223
+ <ion-toolbar>
224
+ <ion-title>*ngIf Usage</ion-title>
225
+ </ion-toolbar>
226
+ </ion-header>
227
+ <ion-content [fullscreen]="true">
228
+ <ion-header collapse="condense">
229
+ <ion-toolbar>
230
+ <ion-title size="large">*ngIf Usage</ion-title>
231
+ <ion-buttons *ngIf="isVisible">
232
+ <ion-button>Toggle</ion-button>
233
+ </ion-buttons>
234
+ </ion-toolbar>
235
+ </ion-header>
236
+ <div *ngIf="isVisible">
237
+ <ion-label>Visible</ion-label>
238
+ </div>
239
+ </ion-content>
240
+ \`,
241
+ standalone: true
242
+ })
243
+ export class MyComponent {
244
+ isVisible = true;
245
+ }
246
+ ` ;
247
+
248
+ const componentSourceFile = project . createSourceFile (
249
+ "foo.component.ts" ,
250
+ dedent ( component ) ,
251
+ ) ;
252
+
253
+ migrateComponents ( project , { dryRun : false } ) ;
254
+
255
+ expect ( dedent ( componentSourceFile . getText ( ) ) ) . toBe (
256
+ dedent ( `
257
+ import { Component } from "@angular/core";
258
+ import { IonHeader, IonToolbar, IonTitle, IonContent, IonButtons, IonButton, IonLabel } from "@ionic/angular/standalone";
259
+
260
+ @Component({
261
+ selector: 'my-component',
262
+ template: \`
263
+ <ion-header [translucent]="true">
264
+ <ion-toolbar>
265
+ <ion-title>*ngIf Usage</ion-title>
266
+ </ion-toolbar>
267
+ </ion-header>
268
+ <ion-content [fullscreen]="true">
269
+ <ion-header collapse="condense">
270
+ <ion-toolbar>
271
+ <ion-title size="large">*ngIf Usage</ion-title>
272
+ <ion-buttons *ngIf="isVisible">
273
+ <ion-button>Toggle</ion-button>
274
+ </ion-buttons>
275
+ </ion-toolbar>
276
+ </ion-header>
277
+ <div *ngIf="isVisible">
278
+ <ion-label>Visible</ion-label>
279
+ </div>
280
+ </ion-content>
281
+ \`,
282
+ standalone: true,
283
+ imports: [IonHeader, IonToolbar, IonTitle, IonContent, IonButtons, IonButton, IonLabel]
284
+ })
285
+ export class MyComponent {
286
+ isVisible = true;
287
+ }
288
+ ` ) ,
289
+ ) ;
290
+ } ) ;
291
+
213
292
describe ( "hyperlinks" , ( ) => {
214
293
it ( "should detect and import routerLink used in the template" , async ( ) => {
215
294
const project = new Project ( { useInMemoryFileSystem : true } ) ;
0 commit comments