Skip to content

Improve AOT unit tests - #19996

Closed
tbosch wants to merge 2 commits into
angular:masterfrom
tbosch:aot_tests
Closed

tbosch wants to merge 2 commits into
angular:masterfrom
tbosch:aot_tests

Conversation

@tbosch

@tbosch tbosch commented Oct 28, 2017

Copy link
Copy Markdown
Contributor

No description provided.

…ureTestingModule`

Also adds caching for summaries.

Closes angular#19817.
@tbosch
tbosch requested review from chuckjaz, vicb and vikerman October 28, 2017 00:52
@tbosch tbosch added area: core Issues related to the framework runtime target: major This PR is targeted for the next major release labels Oct 28, 2017
@mary-poppins

Copy link
Copy Markdown

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
@mary-poppins

Copy link
Copy Markdown

You can preview f29260f at https://pr19996-f29260f.ngbuilds.io/.

}

private _addAotSummaries(fn: () => any[]) {
if (this._addedAotSummaries.has(fn)) {

Copy link
Copy Markdown
Contributor

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)

Copy link
Copy Markdown
Contributor

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

@vicb vicb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see inline comments

function debugCreateComponentView(
parentView: ViewData, nodeDef: NodeDef, viewDef: ViewDefinition, hostElement: any): ViewData {
const defWithOverride = applyProviderOverridesToView(viewDef);
const overrideComponentView =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

override+n+CV ?

Copy link
Copy Markdown
Contributor

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');

Copy link
Copy Markdown
Contributor

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: []});

Copy link
Copy Markdown
Contributor

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) ?

}

/**
* Overrides the template of the given component, compiling the template

Copy link
Copy Markdown
Contributor

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})

Copy link
Copy Markdown
Contributor

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', () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

testing module-s-

@tbosch

tbosch commented Oct 31, 2017

Copy link
Copy Markdown
Contributor Author

FYI: @vicb is taking over this PR and landing it once Angular 5 is done.

@tbosch

tbosch commented Nov 1, 2017

Copy link
Copy Markdown
Contributor Author

@vicb will take over this PR.

@IgorMinar IgorMinar added target: patch This PR is targeted for the next patch release and removed target: major This PR is targeted for the next major release labels Nov 3, 2017
@vicb vicb mentioned this pull request Nov 6, 2017
vicb added a commit to vicb/angular that referenced this pull request Nov 6, 2017
@IgorMinar

Copy link
Copy Markdown
Contributor

closing in favor of #20224

@IgorMinar IgorMinar closed this Nov 17, 2017
@angular-automatic-lock-bot

Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Sep 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area: core Issues related to the framework runtime cla: yes target: patch This PR is targeted for the next patch release type: bug/fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants