Skip to content

Commit

Permalink
fix(migrations): Fix control flow migration issue with multiple i18n …
Browse files Browse the repository at this point in the history
…blocks

fixes: angular#53149
  • Loading branch information
thePunderWoman committed Nov 27, 2023
1 parent 44cc242 commit 7db4ecd
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions packages/core/schematics/test/control_flow_migration_spec.ts
Expand Up @@ -620,6 +620,43 @@ describe('control flow migration', () => {
].join('\n'));
});

fit('should migrate an NgIfElse case with ng-templates with multiple i18n attributes',
async () => {
writeFile('/comp.ts', `
import {Component} from '@angular/core';
import {NgIf} from '@angular/common';
@Component({
templateUrl: './comp.html'
})
class Comp {
show = false;
}
`);

writeFile('/comp.html', [
`<ng-template *ngIf="false; else barTempl" i18n="@@foo">`,
` Foo`,
`</ng-template>`,
`<ng-template i18n="@@bar" #barTempl> Bar </ng-template>`,
`<a *ngIf="true" i18n="@@bam">Bam</a>`,
].join('\n'));

await runMigration();
const content = tree.readContent('/comp.html');

expect(content).toBe([
`@if (false) {`,
` <ng-container i18n="@@foo">Foo</ng-container>`,
`} @else {`,
` <ng-container i18n="@@bar"> Bar </ng-container>`,
`}`,
`@if (true) {`,
` <a i18n="@@bam">Bam</a>`,
`}`,
].join('\n'));
});

it('should migrate an if else case', async () => {
writeFile('/comp.ts', `
import {Component} from '@angular/core';
Expand Down

0 comments on commit 7db4ecd

Please sign in to comment.