Repository navigation
Improve AOT unit tests - #19996
Improve AOT unit tests#19996tbosch wants to merge 2 commits into
Conversation
…ureTestingModule` Also adds caching for summaries. Closes angular#19817.
|
You can preview 7c769d6 at https://pr19996-7c769d6.ngbuilds.io/. |
This allows to overwrite templates for JIT and AOT components alike. In contrast to `TestBed.overrideTemplate`, the template is compiled in the context of the testing module, allowing to use other testing directives. Closes angular#19815
|
You can preview f29260f at https://pr19996-f29260f.ngbuilds.io/. |
| } | ||
|
|
||
| private _addAotSummaries(fn: () => any[]) { | ||
| if (this._addedAotSummaries.has(fn)) { |
There was a problem hiding this comment.
Do we want to marked only non-functions as visited ?
Could help with stateful functions ? (not sure about the exact use case for fns)
There was a problem hiding this comment.
Oh this was existing code... so probably not worth changing the behavior
| function debugCreateComponentView( | ||
| parentView: ViewData, nodeDef: NodeDef, viewDef: ViewDefinition, hostElement: any): ViewData { | ||
| const defWithOverride = applyProviderOverridesToView(viewDef); | ||
| const overrideComponentView = |
There was a problem hiding this comment.
we already have OverrideProvider, keeping for consistency
| it('should allow to override a template', () => { | ||
| resetTestEnvironmentWithSummaries(summaries); | ||
|
|
||
| TestBed.overrideTemplateUsingTestingModule(SomePublicComponent, 'overwritten'); |
There was a problem hiding this comment.
wouldn't this test work the same with overrideTemplate only ?
|
|
||
| const overwrittenValue = {}; | ||
|
|
||
| TestBed.overrideProvider(SomeDep, {useFactory: () => overwrittenValue, deps: []}); |
There was a problem hiding this comment.
chain call (or assert the type of the return value) ?
| } | ||
|
|
||
| /** | ||
| * Overrides the template of the given component, compiling the template |
There was a problem hiding this comment.
Add docs to overrideTemplate to clearly describe the difference ?
| overrideTemplateUsingTestingModule(component: Type<any>, template: string) { | ||
| this._assertNotInstantiated('overrideTemplateUsingTestingModule', 'override template'); | ||
|
|
||
| @Component({selector: 'empty', template: template}) |
There was a problem hiding this comment.
nit template: template could be simplified
| /Cannot override template when the test module has already been instantiated/); | ||
| }); | ||
|
|
||
| it('should reset overrides when the testing modules is resetted', () => { |
|
FYI: @vicb is taking over this PR and landing it once Angular 5 is done. |
|
@vicb will take over this PR. |
|
closing in favor of #20224 |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
No description provided.