From 2577f5eebfc63d64cc5c58396b2edc97f23af84b Mon Sep 17 00:00:00 2001 From: Rado Kirov Date: Thu, 23 Jul 2015 14:49:24 -0700 Subject: [PATCH] test(query): adds a test for query in the presense of projection. Query uses only the logical structure of the application, so it is not affected by projection, which only the rendering structure. Closes #3278 --- .../core/compiler/query_integration_spec.ts | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/modules/angular2/test/core/compiler/query_integration_spec.ts b/modules/angular2/test/core/compiler/query_integration_spec.ts index 1248cc00a0..2223c31310 100644 --- a/modules/angular2/test/core/compiler/query_integration_spec.ts +++ b/modules/angular2/test/core/compiler/query_integration_spec.ts @@ -269,6 +269,23 @@ export function main() { expect(q.query.first.nativeElement).toHaveText("1d"); expect(q.query.last.nativeElement).toHaveText("2d"); + async.done(); + }); + })); + + it('should contain all the elements in the light dom even if they get projected', + inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { + var template = '' + + '
' + + '
'; + + tcb.overrideTemplate(MyComp, template) + .createAsync(MyComp) + .then((view) => { + view.detectChanges(); + + expect(asNativeElements(view.componentViewChildren)).toHaveText('hello|world|'); + async.done(); }); })); @@ -417,6 +434,17 @@ class NeedsQueryByTwoLabels { } } +@Component({selector: 'needs-query-and-project'}) +@View({ + directives: [NgFor], + template: '
{{dir.text}}|
' +}) +@Injectable() +class NeedsQueryAndProject { + query: QueryList; + constructor(@Query(TextDirective) query: QueryList) { this.query = query; } +} + @Component({selector: 'needs-view-query'}) @View({ directives: [TextDirective], @@ -461,7 +489,7 @@ class NeedsViewQueryIf { directives: [NgFor, TextDirective], template: '
' + '
' + - '
' }) @Injectable() class NeedsViewQueryOrder { @@ -476,6 +504,7 @@ class NeedsViewQueryOrder { NeedsQueryDesc, NeedsQueryByLabel, NeedsQueryByTwoLabels, + NeedsQueryAndProject, NeedsViewQuery, NeedsViewQueryDesc, NeedsViewQueryIf,