New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve AOT unit tests #19996
Improve AOT unit tests #19996
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh this was existing code... so probably not worth changing the behavior
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see inline comments
@@ -139,10 +143,15 @@ function debugCreateEmbeddedView( | |||
|
|||
function debugCreateComponentView( | |||
parentView: ViewData, nodeDef: NodeDef, viewDef: ViewDefinition, hostElement: any): ViewData { | |||
const defWithOverride = applyProviderOverridesToView(viewDef); | |||
const overrideComponentView = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
override+n+CV ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chain call (or assert the type of the return value) ?
@@ -142,9 +142,23 @@ export class TestBed implements Injector { | |||
return TestBed; | |||
} | |||
|
|||
/** | |||
* Overrides the template of the given component, compiling the template |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
testing module-s-
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.