Skip to content

Commit

Permalink
fix(core): merge of kept / mock declarations in CommonModule help-me-…
Browse files Browse the repository at this point in the history
  • Loading branch information
satanTime committed Apr 22, 2023
1 parent 7e90dd1 commit 1dfa891
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions tests/issue-5465/test.spec.ts
Original file line number Diff line number Diff line change
@@ -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: `
<span *ngFor="let letter of this.test">{{ letter }}</span>
`,
})
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: ` <app-ng-for></app-ng-for> `,
})
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();
});
});

0 comments on commit 1dfa891

Please sign in to comment.