test(ViewMetadata): use ViewMetadata consistently in tests
Closes #3746
This commit is contained in:
parent
215c4aa8fb
commit
c4044102d6
|
@ -48,7 +48,7 @@ main() {
|
||||||
tb
|
tb
|
||||||
.overrideView(
|
.overrideView(
|
||||||
Dummy,
|
Dummy,
|
||||||
new View(
|
new ViewMetadata(
|
||||||
template:
|
template:
|
||||||
'<type-literal-component></type-literal-component>',
|
'<type-literal-component></type-literal-component>',
|
||||||
directives: [TypeLiteralComponent]))
|
directives: [TypeLiteralComponent]))
|
||||||
|
@ -69,7 +69,7 @@ main() {
|
||||||
tb
|
tb
|
||||||
.overrideView(
|
.overrideView(
|
||||||
Dummy,
|
Dummy,
|
||||||
new View(
|
new ViewMetadata(
|
||||||
template: '<throwing-component></throwing-component>',
|
template: '<throwing-component></throwing-component>',
|
||||||
directives: [ThrowingComponent]))
|
directives: [ThrowingComponent]))
|
||||||
.createAsync(Dummy)
|
.createAsync(Dummy)
|
||||||
|
@ -86,7 +86,7 @@ main() {
|
||||||
tb
|
tb
|
||||||
.overrideView(
|
.overrideView(
|
||||||
Dummy,
|
Dummy,
|
||||||
new View(
|
new ViewMetadata(
|
||||||
template: '<throwing-component2></throwing-component2>',
|
template: '<throwing-component2></throwing-component2>',
|
||||||
directives: [ThrowingComponent2]))
|
directives: [ThrowingComponent2]))
|
||||||
.createAsync(Dummy)
|
.createAsync(Dummy)
|
||||||
|
@ -105,7 +105,7 @@ main() {
|
||||||
tb
|
tb
|
||||||
.overrideView(
|
.overrideView(
|
||||||
Dummy,
|
Dummy,
|
||||||
new View(
|
new ViewMetadata(
|
||||||
template: '<property-access></property-access>',
|
template: '<property-access></property-access>',
|
||||||
directives: [PropertyAccess]))
|
directives: [PropertyAccess]))
|
||||||
.createAsync(Dummy)
|
.createAsync(Dummy)
|
||||||
|
@ -123,7 +123,7 @@ main() {
|
||||||
tb
|
tb
|
||||||
.overrideView(
|
.overrideView(
|
||||||
Dummy,
|
Dummy,
|
||||||
new View(
|
new ViewMetadata(
|
||||||
template: '<no-property-access></no-property-access>',
|
template: '<no-property-access></no-property-access>',
|
||||||
directives: [NoPropertyAccess]))
|
directives: [NoPropertyAccess]))
|
||||||
.createAsync(Dummy)
|
.createAsync(Dummy)
|
||||||
|
@ -142,7 +142,7 @@ main() {
|
||||||
tb
|
tb
|
||||||
.overrideView(
|
.overrideView(
|
||||||
Dummy,
|
Dummy,
|
||||||
new View(
|
new ViewMetadata(
|
||||||
template: '''<on-change [prop]="'hello'"></on-change>''',
|
template: '''<on-change [prop]="'hello'"></on-change>''',
|
||||||
directives: [OnChangeComponent]))
|
directives: [OnChangeComponent]))
|
||||||
.createAsync(Dummy)
|
.createAsync(Dummy)
|
||||||
|
@ -164,7 +164,7 @@ main() {
|
||||||
tcb
|
tcb
|
||||||
.overrideView(
|
.overrideView(
|
||||||
Dummy,
|
Dummy,
|
||||||
new View(
|
new ViewMetadata(
|
||||||
template:
|
template:
|
||||||
'''<component-with-observable-list [list]="value"></component-with-observable-list>''',
|
'''<component-with-observable-list [list]="value"></component-with-observable-list>''',
|
||||||
directives: [ComponentWithObservableList]))
|
directives: [ComponentWithObservableList]))
|
||||||
|
|
|
@ -24,9 +24,6 @@ import {
|
||||||
import {DOM} from 'angular2/src/dom/dom_adapter';
|
import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Component,
|
|
||||||
Directive,
|
|
||||||
View,
|
|
||||||
forwardRef,
|
forwardRef,
|
||||||
ViewContainerRef,
|
ViewContainerRef,
|
||||||
ElementRef,
|
ElementRef,
|
||||||
|
@ -34,6 +31,7 @@ import {
|
||||||
bind,
|
bind,
|
||||||
ViewEncapsulation
|
ViewEncapsulation
|
||||||
} from 'angular2/angular2';
|
} from 'angular2/angular2';
|
||||||
|
import {Component, Directive, View, ViewMetadata} from 'angular2/metadata';
|
||||||
|
|
||||||
import {MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE} from 'angular2/src/render/render';
|
import {MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE} from 'angular2/src/render/render';
|
||||||
|
|
||||||
|
@ -41,7 +39,7 @@ export function main() {
|
||||||
describe('projection', () => {
|
describe('projection', () => {
|
||||||
it('should support simple components',
|
it('should support simple components',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MainComp, new View({
|
tcb.overrideView(MainComp, new ViewMetadata({
|
||||||
template: '<simple>' +
|
template: '<simple>' +
|
||||||
'<div>A</div>' +
|
'<div>A</div>' +
|
||||||
'</simple>',
|
'</simple>',
|
||||||
|
@ -56,7 +54,7 @@ export function main() {
|
||||||
|
|
||||||
it('should support simple components with text interpolation as direct children',
|
it('should support simple components with text interpolation as direct children',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MainComp, new View({
|
tcb.overrideView(MainComp, new ViewMetadata({
|
||||||
template: '{{\'START(\'}}<simple>' +
|
template: '{{\'START(\'}}<simple>' +
|
||||||
'{{text}}' +
|
'{{text}}' +
|
||||||
'</simple>{{\')END\'}}',
|
'</simple>{{\')END\'}}',
|
||||||
|
@ -76,10 +74,11 @@ export function main() {
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(
|
tcb.overrideView(
|
||||||
Simple,
|
Simple,
|
||||||
new View(
|
new ViewMetadata(
|
||||||
{template: 'SIMPLE(<div><ng-content></ng-content></div>)', directives: []}))
|
{template: 'SIMPLE(<div><ng-content></ng-content></div>)', directives: []}))
|
||||||
.overrideView(MainComp,
|
.overrideView(
|
||||||
new View({template: '<simple>{{text}}</simple>', directives: [Simple]}))
|
MainComp,
|
||||||
|
new ViewMetadata({template: '<simple>{{text}}</simple>', directives: [Simple]}))
|
||||||
.createAsync(MainComp)
|
.createAsync(MainComp)
|
||||||
.then((main) => {
|
.then((main) => {
|
||||||
|
|
||||||
|
@ -94,13 +93,14 @@ export function main() {
|
||||||
it('should support projecting text interpolation to a non bound element with other bound elements after it',
|
it('should support projecting text interpolation to a non bound element with other bound elements after it',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(
|
tcb.overrideView(
|
||||||
Simple, new View({
|
Simple, new ViewMetadata({
|
||||||
template:
|
template:
|
||||||
'SIMPLE(<div><ng-content></ng-content></div><div [tab-index]="0">EL</div>)',
|
'SIMPLE(<div><ng-content></ng-content></div><div [tab-index]="0">EL</div>)',
|
||||||
directives: []
|
directives: []
|
||||||
}))
|
}))
|
||||||
.overrideView(MainComp,
|
.overrideView(
|
||||||
new View({template: '<simple>{{text}}</simple>', directives: [Simple]}))
|
MainComp,
|
||||||
|
new ViewMetadata({template: '<simple>{{text}}</simple>', directives: [Simple]}))
|
||||||
.createAsync(MainComp)
|
.createAsync(MainComp)
|
||||||
.then((main) => {
|
.then((main) => {
|
||||||
|
|
||||||
|
@ -113,7 +113,8 @@ export function main() {
|
||||||
|
|
||||||
it('should not show the light dom even if there is no content tag',
|
it('should not show the light dom even if there is no content tag',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MainComp, new View({template: '<empty>A</empty>', directives: [Empty]}))
|
tcb.overrideView(MainComp,
|
||||||
|
new ViewMetadata({template: '<empty>A</empty>', directives: [Empty]}))
|
||||||
.createAsync(MainComp)
|
.createAsync(MainComp)
|
||||||
.then((main) => {
|
.then((main) => {
|
||||||
|
|
||||||
|
@ -124,7 +125,7 @@ export function main() {
|
||||||
|
|
||||||
it('should support multiple content tags',
|
it('should support multiple content tags',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MainComp, new View({
|
tcb.overrideView(MainComp, new ViewMetadata({
|
||||||
template: '<multiple-content-tags>' +
|
template: '<multiple-content-tags>' +
|
||||||
'<div>B</div>' +
|
'<div>B</div>' +
|
||||||
'<div>C</div>' +
|
'<div>C</div>' +
|
||||||
|
@ -142,7 +143,7 @@ export function main() {
|
||||||
|
|
||||||
it('should redistribute only direct children',
|
it('should redistribute only direct children',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MainComp, new View({
|
tcb.overrideView(MainComp, new ViewMetadata({
|
||||||
template: '<multiple-content-tags>' +
|
template: '<multiple-content-tags>' +
|
||||||
'<div>B<div class="left">A</div></div>' +
|
'<div>B<div class="left">A</div></div>' +
|
||||||
'<div>C</div>' +
|
'<div>C</div>' +
|
||||||
|
@ -159,7 +160,7 @@ export function main() {
|
||||||
|
|
||||||
it("should redistribute direct child viewcontainers when the light dom changes",
|
it("should redistribute direct child viewcontainers when the light dom changes",
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MainComp, new View({
|
tcb.overrideView(MainComp, new ViewMetadata({
|
||||||
template: '<multiple-content-tags>' +
|
template: '<multiple-content-tags>' +
|
||||||
'<template manual class="left"><div>A1</div></template>' +
|
'<template manual class="left"><div>A1</div></template>' +
|
||||||
'<div>B</div>' +
|
'<div>B</div>' +
|
||||||
|
@ -185,7 +186,7 @@ export function main() {
|
||||||
|
|
||||||
it("should support nested components",
|
it("should support nested components",
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MainComp, new View({
|
tcb.overrideView(MainComp, new ViewMetadata({
|
||||||
template: '<outer-with-indirect-nested>' +
|
template: '<outer-with-indirect-nested>' +
|
||||||
'<div>A</div>' +
|
'<div>A</div>' +
|
||||||
'<div>B</div>' +
|
'<div>B</div>' +
|
||||||
|
@ -202,7 +203,7 @@ export function main() {
|
||||||
|
|
||||||
it("should support nesting with content being direct child of a nested component",
|
it("should support nesting with content being direct child of a nested component",
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MainComp, new View({
|
tcb.overrideView(MainComp, new ViewMetadata({
|
||||||
template: '<outer>' +
|
template: '<outer>' +
|
||||||
'<template manual class="left"><div>A</div></template>' +
|
'<template manual class="left"><div>A</div></template>' +
|
||||||
'<div>B</div>' +
|
'<div>B</div>' +
|
||||||
|
@ -226,7 +227,7 @@ export function main() {
|
||||||
|
|
||||||
it('should redistribute when the shadow dom changes',
|
it('should redistribute when the shadow dom changes',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MainComp, new View({
|
tcb.overrideView(MainComp, new ViewMetadata({
|
||||||
template: '<conditional-content>' +
|
template: '<conditional-content>' +
|
||||||
'<div class="left">A</div>' +
|
'<div class="left">A</div>' +
|
||||||
'<div>B</div>' +
|
'<div>B</div>' +
|
||||||
|
@ -260,7 +261,8 @@ export function main() {
|
||||||
|
|
||||||
tcb.overrideView(
|
tcb.overrideView(
|
||||||
MainComp,
|
MainComp,
|
||||||
new View({template: '<simple string-prop="text"></simple>', directives: [Simple]}))
|
new ViewMetadata(
|
||||||
|
{template: '<simple string-prop="text"></simple>', directives: [Simple]}))
|
||||||
.overrideTemplate(Simple, '<ng-content></ng-content><p>P,</p>{{stringProp}}')
|
.overrideTemplate(Simple, '<ng-content></ng-content><p>P,</p>{{stringProp}}')
|
||||||
.createAsync(MainComp)
|
.createAsync(MainComp)
|
||||||
.then((main) => {
|
.then((main) => {
|
||||||
|
@ -280,7 +282,8 @@ export function main() {
|
||||||
|
|
||||||
tcb.overrideView(
|
tcb.overrideView(
|
||||||
MainComp,
|
MainComp,
|
||||||
new View({template: '<simple string-prop="text"></simple>', directives: [Simple]}))
|
new ViewMetadata(
|
||||||
|
{template: '<simple string-prop="text"></simple>', directives: [Simple]}))
|
||||||
.overrideTemplate(Simple, '<style></style><p>P,</p>{{stringProp}}')
|
.overrideTemplate(Simple, '<style></style><p>P,</p>{{stringProp}}')
|
||||||
.createAsync(MainComp)
|
.createAsync(MainComp)
|
||||||
.then((main) => {
|
.then((main) => {
|
||||||
|
@ -293,7 +296,7 @@ export function main() {
|
||||||
|
|
||||||
it('should support moving non projected light dom around',
|
it('should support moving non projected light dom around',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MainComp, new View({
|
tcb.overrideView(MainComp, new ViewMetadata({
|
||||||
template: '<empty>' +
|
template: '<empty>' +
|
||||||
' <template manual><div>A</div></template>' +
|
' <template manual><div>A</div></template>' +
|
||||||
'</empty>' +
|
'</empty>' +
|
||||||
|
@ -318,7 +321,7 @@ export function main() {
|
||||||
|
|
||||||
it('should support moving projected light dom around',
|
it('should support moving projected light dom around',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MainComp, new View({
|
tcb.overrideView(MainComp, new ViewMetadata({
|
||||||
template: '<simple><template manual><div>A</div></template></simple>' +
|
template: '<simple><template manual><div>A</div></template></simple>' +
|
||||||
'START(<div project></div>)END',
|
'START(<div project></div>)END',
|
||||||
directives: [Simple, ProjectDirective, ManualViewportDirective],
|
directives: [Simple, ProjectDirective, ManualViewportDirective],
|
||||||
|
@ -342,7 +345,7 @@ export function main() {
|
||||||
it('should support moving ng-content around',
|
it('should support moving ng-content around',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(
|
tcb.overrideView(
|
||||||
MainComp, new View({
|
MainComp, new ViewMetadata({
|
||||||
template: '<conditional-content>' +
|
template: '<conditional-content>' +
|
||||||
'<div class="left">A</div>' +
|
'<div class="left">A</div>' +
|
||||||
'<div>B</div>' +
|
'<div>B</div>' +
|
||||||
|
@ -378,7 +381,8 @@ export function main() {
|
||||||
// the presence of ng-content elements!
|
// the presence of ng-content elements!
|
||||||
it('should still allow to implement a recursive trees',
|
it('should still allow to implement a recursive trees',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MainComp, new View({template: '<tree></tree>', directives: [Tree]}))
|
tcb.overrideView(MainComp,
|
||||||
|
new ViewMetadata({template: '<tree></tree>', directives: [Tree]}))
|
||||||
.createAsync(MainComp)
|
.createAsync(MainComp)
|
||||||
.then((main) => {
|
.then((main) => {
|
||||||
|
|
||||||
|
@ -397,7 +401,7 @@ export function main() {
|
||||||
if (DOM.supportsNativeShadowDOM()) {
|
if (DOM.supportsNativeShadowDOM()) {
|
||||||
it('should support native content projection',
|
it('should support native content projection',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MainComp, new View({
|
tcb.overrideView(MainComp, new ViewMetadata({
|
||||||
template: '<simple-native>' +
|
template: '<simple-native>' +
|
||||||
'<div>A</div>' +
|
'<div>A</div>' +
|
||||||
'</simple-native>',
|
'</simple-native>',
|
||||||
|
@ -417,7 +421,7 @@ export function main() {
|
||||||
it('should support nested conditionals that contain ng-contents',
|
it('should support nested conditionals that contain ng-contents',
|
||||||
inject(
|
inject(
|
||||||
[TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
[TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MainComp, new View({
|
tcb.overrideView(MainComp, new ViewMetadata({
|
||||||
template: `<conditional-text>a</conditional-text>`,
|
template: `<conditional-text>a</conditional-text>`,
|
||||||
directives: [ConditionalTextComponent]
|
directives: [ConditionalTextComponent]
|
||||||
}))
|
}))
|
||||||
|
|
|
@ -12,7 +12,7 @@ import {
|
||||||
TestComponentBuilder
|
TestComponentBuilder
|
||||||
} from 'angular2/test_lib';
|
} from 'angular2/test_lib';
|
||||||
|
|
||||||
import {Directive, Component, View, LifecycleEvent} from 'angular2/angular2';
|
import {Directive, Component, View, ViewMetadata, LifecycleEvent} from 'angular2/metadata';
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
describe('directive lifecycle integration spec', () => {
|
describe('directive lifecycle integration spec', () => {
|
||||||
|
@ -21,7 +21,7 @@ export function main() {
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(
|
tcb.overrideView(
|
||||||
MyComp,
|
MyComp,
|
||||||
new View(
|
new ViewMetadata(
|
||||||
{template: '<div [field]="123" lifecycle></div>', directives: [LifecycleDir]}))
|
{template: '<div [field]="123" lifecycle></div>', directives: [LifecycleDir]}))
|
||||||
.createAsync(MyComp)
|
.createAsync(MyComp)
|
||||||
.then((tc) => {
|
.then((tc) => {
|
||||||
|
|
|
@ -12,7 +12,7 @@ import {stringify} from 'angular2/src/facade/lang';
|
||||||
|
|
||||||
import {MockViewResolver} from 'angular2/src/mock/view_resolver_mock';
|
import {MockViewResolver} from 'angular2/src/mock/view_resolver_mock';
|
||||||
|
|
||||||
import {Component, View} from 'angular2/angular2';
|
import {Component, View, ViewMetadata} from 'angular2/metadata';
|
||||||
|
|
||||||
import {isBlank} from 'angular2/src/facade/lang';
|
import {isBlank} from 'angular2/src/facade/lang';
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ export function main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should allow overriding the @View', () => {
|
it('should allow overriding the @View', () => {
|
||||||
viewResolver.setView(SomeComponent, new View({template: 'overridden template'}));
|
viewResolver.setView(SomeComponent, new ViewMetadata({template: 'overridden template'}));
|
||||||
var view = viewResolver.resolve(SomeComponent);
|
var view = viewResolver.resolve(SomeComponent);
|
||||||
expect(view.template).toEqual('overridden template');
|
expect(view.template).toEqual('overridden template');
|
||||||
expect(isBlank(view.directives)).toBe(true);
|
expect(isBlank(view.directives)).toBe(true);
|
||||||
|
@ -40,7 +40,7 @@ export function main() {
|
||||||
it('should not allow overriding a view after it has been resolved', () => {
|
it('should not allow overriding a view after it has been resolved', () => {
|
||||||
viewResolver.resolve(SomeComponent);
|
viewResolver.resolve(SomeComponent);
|
||||||
expect(() => {
|
expect(() => {
|
||||||
viewResolver.setView(SomeComponent, new View({template: 'overridden template'}));
|
viewResolver.setView(SomeComponent, new ViewMetadata({template: 'overridden template'}));
|
||||||
})
|
})
|
||||||
.toThrowError(
|
.toThrowError(
|
||||||
`The component ${stringify(SomeComponent)} has already been compiled, its configuration can not be changed`);
|
`The component ${stringify(SomeComponent)} has already been compiled, its configuration can not be changed`);
|
||||||
|
@ -56,7 +56,7 @@ export function main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should allow overriding an overriden @View', () => {
|
it('should allow overriding an overriden @View', () => {
|
||||||
viewResolver.setView(SomeComponent, new View({template: 'overridden template'}));
|
viewResolver.setView(SomeComponent, new ViewMetadata({template: 'overridden template'}));
|
||||||
viewResolver.setInlineTemplate(SomeComponent, 'overridden template x 2');
|
viewResolver.setInlineTemplate(SomeComponent, 'overridden template x 2');
|
||||||
var view = viewResolver.resolve(SomeComponent);
|
var view = viewResolver.resolve(SomeComponent);
|
||||||
expect(view.template).toEqual('overridden template x 2');
|
expect(view.template).toEqual('overridden template x 2');
|
||||||
|
@ -80,7 +80,7 @@ export function main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should allow overriding a directive from an overriden @View', () => {
|
it('should allow overriding a directive from an overriden @View', () => {
|
||||||
viewResolver.setView(SomeComponent, new View({directives: [SomeOtherDirective]}));
|
viewResolver.setView(SomeComponent, new ViewMetadata({directives: [SomeOtherDirective]}));
|
||||||
viewResolver.overrideViewDirective(SomeComponent, SomeOtherDirective, SomeComponent);
|
viewResolver.overrideViewDirective(SomeComponent, SomeOtherDirective, SomeComponent);
|
||||||
var view = viewResolver.resolve(SomeComponent);
|
var view = viewResolver.resolve(SomeComponent);
|
||||||
expect(view.directives.length).toEqual(1);
|
expect(view.directives.length).toEqual(1);
|
||||||
|
|
|
@ -16,7 +16,7 @@ import {
|
||||||
} from 'angular2/test_lib';
|
} from 'angular2/test_lib';
|
||||||
|
|
||||||
import {Injector, Inject, bind} from 'angular2/di';
|
import {Injector, Inject, bind} from 'angular2/di';
|
||||||
import {Component, View} from 'angular2/metadata';
|
import {Component, View, ViewMetadata} from 'angular2/metadata';
|
||||||
import {CONST, NumberWrapper, isPresent, Json} from 'angular2/src/facade/lang';
|
import {CONST, NumberWrapper, isPresent, Json} from 'angular2/src/facade/lang';
|
||||||
import {
|
import {
|
||||||
Promise,
|
Promise,
|
||||||
|
@ -85,7 +85,7 @@ export function main() {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
function compile(template: string = "<router-outlet></router-outlet>") {
|
function compile(template: string = "<router-outlet></router-outlet>") {
|
||||||
return tcb.overrideView(MyComp, new View({
|
return tcb.overrideView(MyComp, new ViewMetadata({
|
||||||
template: ('<div>' + template + '</div>'),
|
template: ('<div>' + template + '</div>'),
|
||||||
directives: [RouterOutlet, RouterLink]
|
directives: [RouterOutlet, RouterLink]
|
||||||
}))
|
}))
|
||||||
|
|
|
@ -13,7 +13,7 @@ import {Compiler, CompilerCache} from 'angular2/src/core/compiler/compiler';
|
||||||
import {DirectiveResolver} from 'angular2/src/core/compiler/directive_resolver';
|
import {DirectiveResolver} from 'angular2/src/core/compiler/directive_resolver';
|
||||||
import {PipeResolver} from 'angular2/src/core/compiler/pipe_resolver';
|
import {PipeResolver} from 'angular2/src/core/compiler/pipe_resolver';
|
||||||
|
|
||||||
import {Component, Directive, View} from 'angular2/angular2';
|
import {Component, Directive, View, ViewMetadata} from 'angular2/metadata';
|
||||||
import {ViewResolver} from 'angular2/src/core/compiler/view_resolver';
|
import {ViewResolver} from 'angular2/src/core/compiler/view_resolver';
|
||||||
import {UrlResolver} from 'angular2/src/services/url_resolver';
|
import {UrlResolver} from 'angular2/src/services/url_resolver';
|
||||||
import {AppRootUrl} from 'angular2/src/services/app_root_url';
|
import {AppRootUrl} from 'angular2/src/services/app_root_url';
|
||||||
|
@ -121,11 +121,10 @@ class MultipleViewResolver extends ViewResolver {
|
||||||
this._cache.set(component, ListWrapper.join(multiplier, ''));
|
this._cache.set(component, ListWrapper.join(multiplier, ''));
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve(component: Type): View {
|
resolve(component: Type): ViewMetadata {
|
||||||
var view = super.resolve(component);
|
var view = super.resolve(component);
|
||||||
var myView =
|
return new ViewMetadata(
|
||||||
new View({template:<string>this._cache.get(component), directives: view.directives});
|
{template:<string>this._cache.get(component), directives: view.directives});
|
||||||
return myView;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue