Skip to content

Commit

Permalink
fix(angular): update component correctly when remote uses inlineTemplate
Browse files Browse the repository at this point in the history
  • Loading branch information
Coly010 committed Sep 27, 2022
1 parent 66d1aed commit c344eee
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
24 changes: 24 additions & 0 deletions packages/angular/src/generators/remote/remote.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,30 @@ describe('MF Remote App Generator', () => {
expect(projects.has('remote1-e2e')).toBeFalsy();
});

it('should generate a correct app component when inline template is used', async () => {
// ARRANGE
const tree = createTreeWithEmptyWorkspace();

// ACT
await remote(tree, {
name: 'test',
inlineTemplate: true,
});

// ASSERT
expect(tree.read('apps/test/src/app/app.component.ts', 'utf-8'))
.toMatchInlineSnapshot(`
"import { Component } from '@angular/core';
@Component({
selector: 'proj-root',
template: '<router-outlet></router-outlet>'
})
export class AppComponent {}"
`);
});

it('should update the index.html to use the remote entry component selector for root when standalone', async () => {
// ARRANGE
const tree = createTreeWithEmptyWorkspace();
Expand Down
5 changes: 4 additions & 1 deletion packages/angular/src/generators/remote/remote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,11 @@ function removeDeadCode(tree: Tree, options: Schema) {
);
if (!options.standalone) {
const component =
tree.read(pathToAppComponent, 'utf-8').split('templateUrl')[0] +
tree
.read(pathToAppComponent, 'utf-8')
.split(options.inlineTemplate ? 'template' : 'templateUrl')[0] +
`template: '<router-outlet></router-outlet>'
})
export class AppComponent {}`;

Expand Down

0 comments on commit c344eee

Please sign in to comment.