Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions tests/issue-6143/test.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { CommonModule } from '@angular/common';
import { Component, forwardRef, VERSION } from '@angular/core';

import { MockBuilder, MockRender, ngMocks } from 'ng-mocks';

// Regression coverage for #6143:
// - this standalone child imports its standalone parent via forwardRef
// - the parent imports the child directly
//
// The same setup fails with a recursive stack overflow on v14.7.1 for the
// Angular 15 line reported in the issue, but current main should keep rendering
// both sides of the standalone graph correctly.
@Component({
selector: 'issue-6143-child',
template: 'ChildComponent',
['standalone' as never /* TODO: remove after upgrade to a14 */]: true,
['imports' as never /* TODO: remove after upgrade to a14 */]: [
CommonModule,
forwardRef(() => ParentComponent),
],
})
class ChildComponent {}

@Component({
selector: 'issue-6143-parent',
template: 'ParentComponent',
['standalone' as never /* TODO: remove after upgrade to a14 */]: true,
['imports' as never /* TODO: remove after upgrade to a14 */]: [
CommonModule,
ChildComponent,
],
})
class ParentComponent {}

describe('issue-6143', () => {
if (Number.parseInt(VERSION.major, 10) < 15) {
it('needs >=a15', () => {
expect(true).toBeTruthy();
});

return;
}

describe('ChildComponent', () => {
beforeEach(() => MockBuilder(ChildComponent));

it('renders without recursive parsing failures', () => {
const fixture = MockRender(ChildComponent);

expect(ngMocks.formatText(fixture)).toEqual('ChildComponent');
});
});

describe('ParentComponent', () => {
beforeEach(() => MockBuilder(ParentComponent));

it('renders its own standalone graph', () => {
const fixture = MockRender(ParentComponent);

expect(ngMocks.formatText(fixture)).toEqual('ParentComponent');
});
});
});
Loading