diff --git a/tests/issue-5465/test.spec.ts b/tests/issue-5465/test.spec.ts new file mode 100644 index 0000000000..2bd23c9965 --- /dev/null +++ b/tests/issue-5465/test.spec.ts @@ -0,0 +1,60 @@ +import { NgFor } from '@angular/common'; +import { Component, NgModule, VERSION } from '@angular/core'; + +import { MockBuilder, MockRender } from 'ng-mocks'; + +@Component({ + selector: 'app-ng-for', + template: ` + {{ letter }} + `, +}) +export class AppNgForComponent { + test = ['a', 'b']; + + appNgFor5465() {} +} + +@NgModule({ + imports: [NgFor as never /* TODO: remove after upgrade to a14 */], + declarations: [AppNgForComponent], + exports: [AppNgForComponent], +}) +export class AppNgForModule {} + +@Component({ + selector: 'app-root', + template: ` `, +}) +export class AppRootComponent { + appRoot5465() {} +} + +@NgModule({ + declarations: [AppRootComponent], + imports: [AppNgForModule], + providers: [], + bootstrap: [AppRootComponent], +}) +class AppModule {} + +// @see https://github.com/help-me-mom/ng-mocks/issues/5465 +// TypeError: Class constructor CommonModule cannot be invoked without 'new' +describe('issue-5465', () => { + if (Number.parseInt(VERSION.major, 10) < 14) { + it('needs a14', () => { + // pending('Need Angular 14+'); + expect(true).toBeTruthy(); + }); + + return; + } + + beforeEach(() => + MockBuilder([AppRootComponent], [AppModule, NgFor]), + ); + + it('renders AppRootComponent', () => { + expect(() => MockRender(AppRootComponent)).not.toThrow(); + }); +});