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
This commit is contained in:
parent
f575ba60fb
commit
2577f5eebf
|
@ -269,6 +269,23 @@ export function main() {
|
||||||
expect(q.query.first.nativeElement).toHaveText("1d");
|
expect(q.query.first.nativeElement).toHaveText("1d");
|
||||||
expect(q.query.last.nativeElement).toHaveText("2d");
|
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 = '<needs-query-and-project #q>' +
|
||||||
|
'<div text="hello"></div><div text="world"></div>' +
|
||||||
|
'</needs-query-and-project>';
|
||||||
|
|
||||||
|
tcb.overrideTemplate(MyComp, template)
|
||||||
|
.createAsync(MyComp)
|
||||||
|
.then((view) => {
|
||||||
|
view.detectChanges();
|
||||||
|
|
||||||
|
expect(asNativeElements(view.componentViewChildren)).toHaveText('hello|world|');
|
||||||
|
|
||||||
async.done();
|
async.done();
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
@ -417,6 +434,17 @@ class NeedsQueryByTwoLabels {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Component({selector: 'needs-query-and-project'})
|
||||||
|
@View({
|
||||||
|
directives: [NgFor],
|
||||||
|
template: '<div *ng-for="var dir of query">{{dir.text}}|</div><ng-content></ng-content>'
|
||||||
|
})
|
||||||
|
@Injectable()
|
||||||
|
class NeedsQueryAndProject {
|
||||||
|
query: QueryList<TextDirective>;
|
||||||
|
constructor(@Query(TextDirective) query: QueryList<TextDirective>) { this.query = query; }
|
||||||
|
}
|
||||||
|
|
||||||
@Component({selector: 'needs-view-query'})
|
@Component({selector: 'needs-view-query'})
|
||||||
@View({
|
@View({
|
||||||
directives: [TextDirective],
|
directives: [TextDirective],
|
||||||
|
@ -461,7 +489,7 @@ class NeedsViewQueryIf {
|
||||||
directives: [NgFor, TextDirective],
|
directives: [NgFor, TextDirective],
|
||||||
template: '<div text="1">' +
|
template: '<div text="1">' +
|
||||||
'<div *ng-for="var i of [\'2\', \'3\']" [text]="i"></div>' +
|
'<div *ng-for="var i of [\'2\', \'3\']" [text]="i"></div>' +
|
||||||
'<div text="4"'
|
'<div text="4">'
|
||||||
})
|
})
|
||||||
@Injectable()
|
@Injectable()
|
||||||
class NeedsViewQueryOrder {
|
class NeedsViewQueryOrder {
|
||||||
|
@ -476,6 +504,7 @@ class NeedsViewQueryOrder {
|
||||||
NeedsQueryDesc,
|
NeedsQueryDesc,
|
||||||
NeedsQueryByLabel,
|
NeedsQueryByLabel,
|
||||||
NeedsQueryByTwoLabels,
|
NeedsQueryByTwoLabels,
|
||||||
|
NeedsQueryAndProject,
|
||||||
NeedsViewQuery,
|
NeedsViewQuery,
|
||||||
NeedsViewQueryDesc,
|
NeedsViewQueryDesc,
|
||||||
NeedsViewQueryIf,
|
NeedsViewQueryIf,
|
||||||
|
|
Loading…
Reference in New Issue