forked from help-me-mom/ng-mocks
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): merge of kept / mock declarations in CommonModule help-me-…
- Loading branch information
Showing
1 changed file
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); |