
committed by
Misko Hevery

parent
0246b2a2cb
commit
787d1f955f
@ -29,41 +29,42 @@ export function main() {
|
||||
describe('DynamicComponentLoader', function() {
|
||||
describe("loading into a location", () => {
|
||||
it('should work',
|
||||
inject([DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter],
|
||||
(loader, tcb: TestComponentBuilder, async) => {
|
||||
tcb.overrideView(
|
||||
MyComp,
|
||||
new ViewMetadata(
|
||||
{template: '<location #loc></location>', directives: [Location]}))
|
||||
.createAsync(MyComp)
|
||||
.then((tc) => {
|
||||
inject(
|
||||
[DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter],
|
||||
(loader, tcb: TestComponentBuilder, async) => {
|
||||
tcb.overrideView(
|
||||
MyComp, new ViewMetadata(
|
||||
{template: '<location #loc></location>', directives: [Location]}))
|
||||
.createAsync(MyComp)
|
||||
.then((tc) => {
|
||||
|
||||
loader.loadIntoLocation(DynamicallyLoaded, tc.elementRef, 'loc')
|
||||
.then(ref => {
|
||||
expect(tc.nativeElement).toHaveText("Location;DynamicallyLoaded;");
|
||||
async.done();
|
||||
});
|
||||
});
|
||||
}));
|
||||
loader.loadIntoLocation(DynamicallyLoaded, tc.debugElement.elementRef, 'loc')
|
||||
.then(ref => {
|
||||
expect(tc.debugElement.nativeElement)
|
||||
.toHaveText("Location;DynamicallyLoaded;");
|
||||
async.done();
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
it('should return a disposable component ref',
|
||||
inject([DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter],
|
||||
(loader, tcb: TestComponentBuilder, async) => {
|
||||
tcb.overrideView(
|
||||
MyComp,
|
||||
new ViewMetadata(
|
||||
{template: '<location #loc></location>', directives: [Location]}))
|
||||
.createAsync(MyComp)
|
||||
.then((tc) => {
|
||||
inject(
|
||||
[DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter],
|
||||
(loader, tcb: TestComponentBuilder, async) => {
|
||||
tcb.overrideView(
|
||||
MyComp, new ViewMetadata(
|
||||
{template: '<location #loc></location>', directives: [Location]}))
|
||||
.createAsync(MyComp)
|
||||
.then((tc) => {
|
||||
|
||||
loader.loadIntoLocation(DynamicallyLoaded, tc.elementRef, 'loc')
|
||||
.then(ref => {
|
||||
ref.dispose();
|
||||
expect(tc.nativeElement).toHaveText("Location;");
|
||||
async.done();
|
||||
});
|
||||
});
|
||||
}));
|
||||
loader.loadIntoLocation(DynamicallyLoaded, tc.debugElement.elementRef, 'loc')
|
||||
.then(ref => {
|
||||
ref.dispose();
|
||||
expect(tc.debugElement.nativeElement).toHaveText("Location;");
|
||||
async.done();
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
it('should allow to dispose even if the location has been removed',
|
||||
inject([DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter],
|
||||
@ -78,45 +79,48 @@ export function main() {
|
||||
{template: '<location #loc></location>', directives: [Location]}))
|
||||
.createAsync(MyComp)
|
||||
.then((tc) => {
|
||||
tc.componentInstance.ctxBoolProp = true;
|
||||
tc.debugElement.componentInstance.ctxBoolProp = true;
|
||||
tc.detectChanges();
|
||||
var childCompEl = tc.query(By.css('child-cmp'));
|
||||
var childCompEl = tc.debugElement.query(By.css('child-cmp'));
|
||||
loader.loadIntoLocation(DynamicallyLoaded, childCompEl.elementRef, 'loc')
|
||||
.then(ref => {
|
||||
expect(tc.nativeElement).toHaveText("Location;DynamicallyLoaded;");
|
||||
expect(tc.debugElement.nativeElement)
|
||||
.toHaveText("Location;DynamicallyLoaded;");
|
||||
|
||||
tc.componentInstance.ctxBoolProp = false;
|
||||
tc.debugElement.componentInstance.ctxBoolProp = false;
|
||||
tc.detectChanges();
|
||||
expect(tc.nativeElement).toHaveText("");
|
||||
expect(tc.debugElement.nativeElement).toHaveText("");
|
||||
|
||||
ref.dispose();
|
||||
expect(tc.nativeElement).toHaveText("");
|
||||
expect(tc.debugElement.nativeElement).toHaveText("");
|
||||
async.done();
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
it('should update host properties',
|
||||
inject(
|
||||
[DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter],
|
||||
(loader, tcb: TestComponentBuilder, async) => {
|
||||
tcb.overrideView(
|
||||
MyComp, new ViewMetadata(
|
||||
{template: '<location #loc></location>', directives: [Location]}))
|
||||
.createAsync(MyComp)
|
||||
.then((tc) => {
|
||||
loader.loadIntoLocation(DynamicallyLoadedWithHostProps, tc.elementRef, 'loc')
|
||||
.then(ref => {
|
||||
ref.instance.id = "new value";
|
||||
inject([DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter],
|
||||
(loader, tcb: TestComponentBuilder, async) => {
|
||||
tcb.overrideView(
|
||||
MyComp,
|
||||
new ViewMetadata(
|
||||
{template: '<location #loc></location>', directives: [Location]}))
|
||||
.createAsync(MyComp)
|
||||
.then((tc) => {
|
||||
loader.loadIntoLocation(DynamicallyLoadedWithHostProps,
|
||||
tc.debugElement.elementRef, 'loc')
|
||||
.then(ref => {
|
||||
ref.instance.id = "new value";
|
||||
|
||||
tc.detectChanges();
|
||||
tc.detectChanges();
|
||||
|
||||
var newlyInsertedElement = DOM.childNodes(tc.nativeElement)[1];
|
||||
expect((<HTMLElement>newlyInsertedElement).id).toEqual("new value");
|
||||
async.done();
|
||||
});
|
||||
});
|
||||
}));
|
||||
var newlyInsertedElement =
|
||||
DOM.childNodes(tc.debugElement.nativeElement)[1];
|
||||
expect((<HTMLElement>newlyInsertedElement).id).toEqual("new value");
|
||||
async.done();
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
it('should throw if the variable does not exist',
|
||||
inject([DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter],
|
||||
@ -128,7 +132,8 @@ export function main() {
|
||||
.createAsync(MyComp)
|
||||
.then((tc) => {
|
||||
expect(() => loader.loadIntoLocation(DynamicallyLoadedWithHostProps,
|
||||
tc.elementRef, 'someUnknownVariable'))
|
||||
tc.debugElement.elementRef,
|
||||
'someUnknownVariable'))
|
||||
.toThrowError('Could not find variable someUnknownVariable');
|
||||
async.done();
|
||||
});
|
||||
@ -136,59 +141,60 @@ export function main() {
|
||||
});
|
||||
|
||||
describe("loading next to a location", () => {
|
||||
it('should work', inject([DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter],
|
||||
(loader, tcb: TestComponentBuilder, async) => {
|
||||
tcb.overrideView(
|
||||
MyComp, new ViewMetadata({
|
||||
template: '<div><location #loc></location></div>',
|
||||
directives: [Location]
|
||||
}))
|
||||
.createAsync(MyComp)
|
||||
.then((tc) => {
|
||||
loader.loadNextToLocation(DynamicallyLoaded, tc.elementRef)
|
||||
.then(ref => {
|
||||
expect(tc.nativeElement).toHaveText("Location;");
|
||||
expect(DOM.nextSibling(tc.nativeElement))
|
||||
.toHaveText('DynamicallyLoaded;');
|
||||
|
||||
async.done();
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
it('should return a disposable component ref',
|
||||
it('should work',
|
||||
inject([DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter],
|
||||
(loader, tcb: TestComponentBuilder, async) => {
|
||||
tcb.overrideView(MyComp, new ViewMetadata({
|
||||
template: '<div><location #loc></location></div>',
|
||||
directives: [Location]
|
||||
}))
|
||||
.
|
||||
|
||||
createAsync(MyComp)
|
||||
.createAsync(MyComp)
|
||||
.then((tc) => {
|
||||
loader.loadNextToLocation(DynamicallyLoaded, tc.elementRef)
|
||||
loader.loadNextToLocation(DynamicallyLoaded, tc.debugElement.elementRef)
|
||||
.then(ref => {
|
||||
loader.loadNextToLocation(DynamicallyLoaded2, tc.elementRef)
|
||||
.then(ref2 => {
|
||||
var firstSibling = DOM.nextSibling(tc.nativeElement);
|
||||
var secondSibling = DOM.nextSibling(firstSibling);
|
||||
expect(tc.nativeElement).toHaveText("Location;");
|
||||
expect(firstSibling).toHaveText("DynamicallyLoaded;");
|
||||
expect(secondSibling).toHaveText("DynamicallyLoaded2;");
|
||||
expect(tc.debugElement.nativeElement).toHaveText("Location;");
|
||||
expect(DOM.nextSibling(tc.debugElement.nativeElement))
|
||||
.toHaveText('DynamicallyLoaded;');
|
||||
|
||||
ref2.dispose();
|
||||
|
||||
firstSibling = DOM.nextSibling(tc.nativeElement);
|
||||
secondSibling = DOM.nextSibling(firstSibling);
|
||||
expect(secondSibling).toBeNull();
|
||||
|
||||
async.done();
|
||||
});
|
||||
async.done();
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
it('should return a disposable component ref',
|
||||
inject(
|
||||
[DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter],
|
||||
(loader, tcb: TestComponentBuilder, async) => {
|
||||
tcb.overrideView(MyComp, new ViewMetadata({
|
||||
template: '<div><location #loc></location></div>',
|
||||
directives: [Location]
|
||||
}))
|
||||
.
|
||||
|
||||
createAsync(MyComp)
|
||||
.then((tc) => {
|
||||
loader.loadNextToLocation(DynamicallyLoaded, tc.debugElement.elementRef)
|
||||
.then(ref => {
|
||||
loader.loadNextToLocation(DynamicallyLoaded2, tc.debugElement.elementRef)
|
||||
.then(ref2 => {
|
||||
var firstSibling = DOM.nextSibling(tc.debugElement.nativeElement);
|
||||
var secondSibling = DOM.nextSibling(firstSibling);
|
||||
expect(tc.debugElement.nativeElement).toHaveText("Location;");
|
||||
expect(firstSibling).toHaveText("DynamicallyLoaded;");
|
||||
expect(secondSibling).toHaveText("DynamicallyLoaded2;");
|
||||
|
||||
ref2.dispose();
|
||||
|
||||
firstSibling = DOM.nextSibling(tc.debugElement.nativeElement);
|
||||
secondSibling = DOM.nextSibling(firstSibling);
|
||||
expect(secondSibling).toBeNull();
|
||||
|
||||
async.done();
|
||||
});
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
it('should update host properties',
|
||||
inject([DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter],
|
||||
(loader, tcb: TestComponentBuilder, async) => {
|
||||
@ -200,13 +206,15 @@ export function main() {
|
||||
.createAsync(MyComp)
|
||||
.then((tc) => {
|
||||
|
||||
loader.loadNextToLocation(DynamicallyLoadedWithHostProps, tc.elementRef)
|
||||
loader.loadNextToLocation(DynamicallyLoadedWithHostProps,
|
||||
tc.debugElement.elementRef)
|
||||
.then(ref => {
|
||||
ref.instance.id = "new value";
|
||||
|
||||
tc.detectChanges();
|
||||
|
||||
var newlyInsertedElement = DOM.nextSibling(tc.nativeElement);
|
||||
var newlyInsertedElement =
|
||||
DOM.nextSibling(tc.debugElement.nativeElement);
|
||||
expect((<HTMLElement>newlyInsertedElement).id).toEqual("new value");
|
||||
|
||||
async.done();
|
||||
|
@ -56,7 +56,7 @@ main() {
|
||||
.createAsync(Dummy)
|
||||
.then((tc) {
|
||||
tc.detectChanges();
|
||||
expect(asNativeElements(tc.componentViewChildren))
|
||||
expect(asNativeElements(tc.debugElement.componentViewChildren))
|
||||
.toHaveText('[Hello, World]');
|
||||
async.done();
|
||||
});
|
||||
@ -112,7 +112,7 @@ main() {
|
||||
.createAsync(Dummy)
|
||||
.then((tc) {
|
||||
tc.detectChanges();
|
||||
expect(asNativeElements(tc.componentViewChildren))
|
||||
expect(asNativeElements(tc.debugElement.componentViewChildren))
|
||||
.toHaveText('prop:foo-prop;map:foo-map');
|
||||
async.done();
|
||||
});
|
||||
@ -149,7 +149,7 @@ main() {
|
||||
.createAsync(Dummy)
|
||||
.then((tc) {
|
||||
tc.detectChanges();
|
||||
var cmp = tc.componentViewChildren[0].inject(OnChangeComponent);
|
||||
var cmp = tc.debugElement.componentViewChildren[0].inject(OnChangeComponent);
|
||||
expect(cmp.prop).toEqual('hello');
|
||||
expect(cmp.changes.containsKey('prop')).toEqual(true);
|
||||
async.done();
|
||||
@ -171,19 +171,19 @@ main() {
|
||||
directives: [ComponentWithObservableList]))
|
||||
.createAsync(Dummy)
|
||||
.then((tc) {
|
||||
tc.componentInstance.value = new ObservableList.from([1, 2]);
|
||||
tc.debugElement.componentInstance.value = new ObservableList.from([1, 2]);
|
||||
|
||||
tc.detectChanges();
|
||||
|
||||
expect(log.result()).toEqual("check");
|
||||
expect(asNativeElements(tc.componentViewChildren)).toHaveText('12');
|
||||
expect(asNativeElements(tc.debugElement.componentViewChildren)).toHaveText('12');
|
||||
|
||||
tc.detectChanges();
|
||||
|
||||
// we did not change the list => no checks
|
||||
expect(log.result()).toEqual("check");
|
||||
|
||||
tc.componentInstance.value.add(3);
|
||||
tc.debugElement.componentInstance.value.add(3);
|
||||
|
||||
flushMicrotasks();
|
||||
|
||||
@ -191,16 +191,16 @@ main() {
|
||||
|
||||
// we changed the list => a check
|
||||
expect(log.result()).toEqual("check; check");
|
||||
expect(asNativeElements(tc.componentViewChildren))
|
||||
expect(asNativeElements(tc.debugElement.componentViewChildren))
|
||||
.toHaveText('123');
|
||||
|
||||
// we replaced the list => a check
|
||||
tc.componentInstance.value = new ObservableList.from([5, 6, 7]);
|
||||
tc.debugElement.componentInstance.value = new ObservableList.from([5, 6, 7]);
|
||||
|
||||
tc.detectChanges();
|
||||
|
||||
expect(log.result()).toEqual("check; check; check");
|
||||
expect(asNativeElements(tc.componentViewChildren))
|
||||
expect(asNativeElements(tc.debugElement.componentViewChildren))
|
||||
.toHaveText('567');
|
||||
});
|
||||
})));
|
||||
|
@ -17,7 +17,8 @@ import {
|
||||
TestComponentBuilder,
|
||||
fakeAsync,
|
||||
tick,
|
||||
clearPendingTimers
|
||||
clearPendingTimers,
|
||||
RootTestComponent
|
||||
} from 'angular2/test_lib';
|
||||
|
||||
|
||||
@ -105,10 +106,10 @@ export function main() {
|
||||
tcb.overrideView(MyComp, new ViewMetadata({template: '<div>{{ctxProp}}</div>'}))
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
rootTC.componentInstance.ctxProp = 'Hello World!';
|
||||
rootTC.debugElement.componentInstance.ctxProp = 'Hello World!';
|
||||
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.nativeElement).toHaveText('Hello World!');
|
||||
expect(rootTC.debugElement.nativeElement).toHaveText('Hello World!');
|
||||
async.done();
|
||||
|
||||
});
|
||||
@ -119,10 +120,10 @@ export function main() {
|
||||
tcb.overrideView(MyComp, new ViewMetadata({template: '<div>{{null}}{{ctxProp}}</div>'}))
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
rootTC.componentInstance.ctxProp = null;
|
||||
rootTC.debugElement.componentInstance.ctxProp = null;
|
||||
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.nativeElement).toHaveText('');
|
||||
expect(rootTC.debugElement.nativeElement).toHaveText('');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@ -133,10 +134,11 @@ export function main() {
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
|
||||
rootTC.componentInstance.ctxProp = 'Hello World!';
|
||||
rootTC.debugElement.componentInstance.ctxProp = 'Hello World!';
|
||||
rootTC.detectChanges();
|
||||
|
||||
expect(rootTC.componentViewChildren[0].nativeElement.id).toEqual('Hello World!');
|
||||
expect(rootTC.debugElement.componentViewChildren[0].nativeElement.id)
|
||||
.toEqual('Hello World!');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@ -149,16 +151,16 @@ export function main() {
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
|
||||
rootTC.componentInstance.ctxProp = 'Initial aria label';
|
||||
rootTC.debugElement.componentInstance.ctxProp = 'Initial aria label';
|
||||
rootTC.detectChanges();
|
||||
expect(
|
||||
DOM.getAttribute(rootTC.componentViewChildren[0].nativeElement, 'aria-label'))
|
||||
expect(DOM.getAttribute(rootTC.debugElement.componentViewChildren[0].nativeElement,
|
||||
'aria-label'))
|
||||
.toEqual('Initial aria label');
|
||||
|
||||
rootTC.componentInstance.ctxProp = 'Changed aria label';
|
||||
rootTC.debugElement.componentInstance.ctxProp = 'Changed aria label';
|
||||
rootTC.detectChanges();
|
||||
expect(
|
||||
DOM.getAttribute(rootTC.componentViewChildren[0].nativeElement, 'aria-label'))
|
||||
expect(DOM.getAttribute(rootTC.debugElement.componentViewChildren[0].nativeElement,
|
||||
'aria-label'))
|
||||
.toEqual('Changed aria label');
|
||||
|
||||
async.done();
|
||||
@ -174,11 +176,13 @@ export function main() {
|
||||
.then((rootTC) => {
|
||||
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.componentViewChildren[0].nativeElement.tabIndex).toEqual(0);
|
||||
expect(rootTC.debugElement.componentViewChildren[0].nativeElement.tabIndex)
|
||||
.toEqual(0);
|
||||
|
||||
rootTC.componentInstance.ctxNumProp = 5;
|
||||
rootTC.debugElement.componentInstance.ctxNumProp = 5;
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.componentViewChildren[0].nativeElement.tabIndex).toEqual(5);
|
||||
expect(rootTC.debugElement.componentViewChildren[0].nativeElement.tabIndex)
|
||||
.toEqual(5);
|
||||
|
||||
async.done();
|
||||
});
|
||||
@ -193,11 +197,13 @@ export function main() {
|
||||
.then((rootTC) => {
|
||||
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.componentViewChildren[0].nativeElement.readOnly).toBeFalsy();
|
||||
expect(rootTC.debugElement.componentViewChildren[0].nativeElement.readOnly)
|
||||
.toBeFalsy();
|
||||
|
||||
rootTC.componentInstance.ctxBoolProp = true;
|
||||
rootTC.debugElement.componentInstance.ctxBoolProp = true;
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.componentViewChildren[0].nativeElement.readOnly).toBeTruthy();
|
||||
expect(rootTC.debugElement.componentViewChildren[0].nativeElement.readOnly)
|
||||
.toBeTruthy();
|
||||
|
||||
async.done();
|
||||
});
|
||||
@ -211,14 +217,16 @@ export function main() {
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
|
||||
rootTC.componentInstance.ctxProp = 'Some <span>HTML</span>';
|
||||
rootTC.debugElement.componentInstance.ctxProp = 'Some <span>HTML</span>';
|
||||
rootTC.detectChanges();
|
||||
expect(DOM.getInnerHTML(rootTC.componentViewChildren[0].nativeElement))
|
||||
expect(
|
||||
DOM.getInnerHTML(rootTC.debugElement.componentViewChildren[0].nativeElement))
|
||||
.toEqual('Some <span>HTML</span>');
|
||||
|
||||
rootTC.componentInstance.ctxProp = 'Some other <div>HTML</div>';
|
||||
rootTC.debugElement.componentInstance.ctxProp = 'Some other <div>HTML</div>';
|
||||
rootTC.detectChanges();
|
||||
expect(DOM.getInnerHTML(rootTC.componentViewChildren[0].nativeElement))
|
||||
expect(
|
||||
DOM.getInnerHTML(rootTC.debugElement.componentViewChildren[0].nativeElement))
|
||||
.toEqual('Some other <div>HTML</div>');
|
||||
|
||||
async.done();
|
||||
@ -233,8 +241,8 @@ export function main() {
|
||||
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
var nativeEl = rootTC.componentViewChildren[0].nativeElement;
|
||||
rootTC.componentInstance.ctxProp = 'foo bar';
|
||||
var nativeEl = rootTC.debugElement.componentViewChildren[0].nativeElement;
|
||||
rootTC.debugElement.componentInstance.ctxProp = 'foo bar';
|
||||
rootTC.detectChanges();
|
||||
|
||||
expect(nativeEl).toHaveCssClass('foo');
|
||||
@ -258,14 +266,16 @@ export function main() {
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
|
||||
rootTC.componentInstance.ctxProp = 'Hello World!';
|
||||
rootTC.debugElement.componentInstance.ctxProp = 'Hello World!';
|
||||
rootTC.detectChanges();
|
||||
|
||||
expect(rootTC.componentViewChildren[0].inject(MyDir).dirProp)
|
||||
expect(rootTC.debugElement.componentViewChildren[0].inject(MyDir).dirProp)
|
||||
.toEqual('Hello World!');
|
||||
expect(rootTC.componentViewChildren[1].inject(MyDir).dirProp).toEqual('Hi there!');
|
||||
expect(rootTC.componentViewChildren[2].inject(MyDir).dirProp).toEqual('Hi there!');
|
||||
expect(rootTC.componentViewChildren[3].inject(MyDir).dirProp)
|
||||
expect(rootTC.debugElement.componentViewChildren[1].inject(MyDir).dirProp)
|
||||
.toEqual('Hi there!');
|
||||
expect(rootTC.debugElement.componentViewChildren[2].inject(MyDir).dirProp)
|
||||
.toEqual('Hi there!');
|
||||
expect(rootTC.debugElement.componentViewChildren[3].inject(MyDir).dirProp)
|
||||
.toEqual('One more Hello World!');
|
||||
async.done();
|
||||
});
|
||||
@ -284,10 +294,10 @@ export function main() {
|
||||
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
rootTC.componentInstance.ctxProp = 'a';
|
||||
rootTC.debugElement.componentInstance.ctxProp = 'a';
|
||||
rootTC.detectChanges();
|
||||
|
||||
var dir = rootTC.componentViewChildren[0].getLocal('dir');
|
||||
var dir = rootTC.debugElement.componentViewChildren[0].getLocal('dir');
|
||||
expect(dir.dirProp).toEqual('aa');
|
||||
async.done();
|
||||
});
|
||||
@ -305,7 +315,7 @@ export function main() {
|
||||
|
||||
rootTC.detectChanges();
|
||||
|
||||
expect(rootTC.nativeElement).toHaveText('hello');
|
||||
expect(rootTC.debugElement.nativeElement).toHaveText('hello');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@ -321,10 +331,10 @@ export function main() {
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
|
||||
rootTC.componentInstance.ctxProp = 'Hello World!';
|
||||
rootTC.debugElement.componentInstance.ctxProp = 'Hello World!';
|
||||
rootTC.detectChanges();
|
||||
|
||||
var tc = rootTC.componentViewChildren[0];
|
||||
var tc = rootTC.debugElement.componentViewChildren[0];
|
||||
|
||||
expect(tc.inject(MyDir).dirProp).toEqual('Hello World!');
|
||||
expect(tc.inject(ChildComp).dirProp).toEqual(null);
|
||||
@ -358,7 +368,7 @@ export function main() {
|
||||
}))
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
expect(rootTC.nativeElement).toHaveText('noduplicate');
|
||||
expect(rootTC.debugElement.nativeElement).toHaveText('noduplicate');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@ -375,7 +385,7 @@ export function main() {
|
||||
}))
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
expect(rootTC.nativeElement).toHaveText('othernoduplicate');
|
||||
expect(rootTC.debugElement.nativeElement).toHaveText('othernoduplicate');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@ -387,14 +397,14 @@ export function main() {
|
||||
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
var tc = rootTC.componentViewChildren[0];
|
||||
var tc = rootTC.debugElement.componentViewChildren[0];
|
||||
var idDir = tc.inject(IdDir);
|
||||
|
||||
rootTC.componentInstance.ctxProp = 'some_id';
|
||||
rootTC.debugElement.componentInstance.ctxProp = 'some_id';
|
||||
rootTC.detectChanges();
|
||||
expect(idDir.id).toEqual('some_id');
|
||||
|
||||
rootTC.componentInstance.ctxProp = 'other_id';
|
||||
rootTC.debugElement.componentInstance.ctxProp = 'other_id';
|
||||
rootTC.detectChanges();
|
||||
expect(idDir.id).toEqual('other_id');
|
||||
|
||||
@ -413,7 +423,7 @@ export function main() {
|
||||
.then((rootTC) => {
|
||||
rootTC.detectChanges();
|
||||
|
||||
expect(rootTC.nativeElement).toHaveText('hello');
|
||||
expect(rootTC.debugElement.nativeElement).toHaveText('hello');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@ -443,7 +453,7 @@ export function main() {
|
||||
|
||||
rootTC.detectChanges();
|
||||
|
||||
var childNodesOfWrapper = rootTC.componentViewChildren;
|
||||
var childNodesOfWrapper = rootTC.debugElement.componentViewChildren;
|
||||
// 1 template + 2 copies.
|
||||
expect(childNodesOfWrapper.length).toBe(3);
|
||||
expect(childNodesOfWrapper[1].nativeElement).toHaveText('hello');
|
||||
@ -465,7 +475,7 @@ export function main() {
|
||||
.then((rootTC) => {
|
||||
rootTC.detectChanges();
|
||||
|
||||
var childNodesOfWrapper = rootTC.componentViewChildren;
|
||||
var childNodesOfWrapper = rootTC.debugElement.componentViewChildren;
|
||||
// 1 template + 2 copies.
|
||||
expect(childNodesOfWrapper.length).toBe(3);
|
||||
expect(childNodesOfWrapper[1].nativeElement).toHaveText('hello');
|
||||
@ -484,10 +494,10 @@ export function main() {
|
||||
}))
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
rootTC.componentInstance.ctxProp = 'From myComp';
|
||||
rootTC.debugElement.componentInstance.ctxProp = 'From myComp';
|
||||
rootTC.detectChanges();
|
||||
|
||||
expect(rootTC.nativeElement)
|
||||
expect(rootTC.debugElement.nativeElement)
|
||||
.toHaveText(
|
||||
'TOOLBAR(From myComp,From toolbar,Component with an injected host)');
|
||||
|
||||
@ -506,7 +516,7 @@ export function main() {
|
||||
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
expect(rootTC.componentViewChildren[0].getLocal('alice'))
|
||||
expect(rootTC.debugElement.componentViewChildren[0].getLocal('alice'))
|
||||
.toBeAnInstanceOf(ChildComp);
|
||||
|
||||
async.done();
|
||||
@ -522,7 +532,7 @@ export function main() {
|
||||
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
expect(rootTC.componentViewChildren[0].getLocal('localdir'))
|
||||
expect(rootTC.debugElement.componentViewChildren[0].getLocal('localdir'))
|
||||
.toBeAnInstanceOf(ExportDir);
|
||||
|
||||
async.done();
|
||||
@ -543,7 +553,7 @@ export function main() {
|
||||
.then((rootTC) => {
|
||||
rootTC.detectChanges();
|
||||
|
||||
expect(rootTC.nativeElement)
|
||||
expect(rootTC.debugElement.nativeElement)
|
||||
.toHaveText('hellohello'); // this first one is the
|
||||
// component, the second one is
|
||||
// the text binding
|
||||
@ -563,32 +573,33 @@ export function main() {
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
|
||||
expect(rootTC.componentViewChildren[0].getLocal('alice'))
|
||||
expect(rootTC.debugElement.componentViewChildren[0].getLocal('alice'))
|
||||
.toBeAnInstanceOf(ChildComp);
|
||||
expect(rootTC.componentViewChildren[0].getLocal('bob'))
|
||||
expect(rootTC.debugElement.componentViewChildren[0].getLocal('bob'))
|
||||
.toBeAnInstanceOf(ChildComp);
|
||||
expect(rootTC.componentViewChildren[0].getLocal('alice'))
|
||||
.not.toBe(rootTC.componentViewChildren[0].getLocal('bob'));
|
||||
expect(rootTC.debugElement.componentViewChildren[0].getLocal('alice'))
|
||||
.not.toBe(
|
||||
rootTC.debugElement.componentViewChildren[0].getLocal('bob'));
|
||||
|
||||
async.done();
|
||||
})}));
|
||||
|
||||
it('should assign the component instance to a var- with shorthand syntax',
|
||||
inject([TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder,
|
||||
async) => {tcb.overrideView(MyComp, new ViewMetadata({
|
||||
template: '<child-cmp #alice></child-cmp>',
|
||||
directives: [ChildComp]
|
||||
}))
|
||||
(tcb: TestComponentBuilder, async) => {
|
||||
tcb.overrideView(MyComp, new ViewMetadata({
|
||||
template: '<child-cmp #alice></child-cmp>',
|
||||
directives: [ChildComp]
|
||||
}))
|
||||
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
|
||||
expect(rootTC.componentViewChildren[0].getLocal('alice'))
|
||||
.toBeAnInstanceOf(ChildComp);
|
||||
expect(rootTC.debugElement.componentViewChildren[0].getLocal('alice'))
|
||||
.toBeAnInstanceOf(ChildComp);
|
||||
|
||||
async.done();
|
||||
})}));
|
||||
async.done();
|
||||
})}));
|
||||
|
||||
it('should assign the element instance to a user-defined variable',
|
||||
inject([TestComponentBuilder, AsyncTestCompleter],
|
||||
@ -600,7 +611,8 @@ export function main() {
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
|
||||
var value = rootTC.componentViewChildren[0].getLocal('alice');
|
||||
var value =
|
||||
rootTC.debugElement.componentViewChildren[0].getLocal('alice');
|
||||
expect(value).not.toBe(null);
|
||||
expect(value.tagName.toLowerCase()).toEqual('div');
|
||||
|
||||
@ -608,21 +620,21 @@ export function main() {
|
||||
})}));
|
||||
|
||||
it('should change dash-case to camel-case',
|
||||
inject([TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async) => {
|
||||
tcb.overrideView(MyComp, new ViewMetadata({
|
||||
template: '<p><child-cmp var-super-alice></child-cmp></p>',
|
||||
directives: [ChildComp]
|
||||
}))
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||
tcb.overrideView(MyComp, new ViewMetadata({
|
||||
template: '<p><child-cmp var-super-alice></child-cmp></p>',
|
||||
directives: [ChildComp]
|
||||
}))
|
||||
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
expect(rootTC.componentViewChildren[0].getLocal('superAlice'))
|
||||
.toBeAnInstanceOf(ChildComp);
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
expect(rootTC.debugElement.componentViewChildren[0].getLocal('superAlice'))
|
||||
.toBeAnInstanceOf(ChildComp);
|
||||
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should allow to use variables in a for loop',
|
||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder,
|
||||
@ -639,7 +651,8 @@ export function main() {
|
||||
rootTC.detectChanges();
|
||||
|
||||
// Get the element at index 1, since index 0 is the <template>.
|
||||
expect(rootTC.componentViewChildren[1].nativeElement).toHaveText("1-hello");
|
||||
expect(rootTC.debugElement.componentViewChildren[1].nativeElement)
|
||||
.toHaveText("1-hello");
|
||||
|
||||
async.done();
|
||||
});
|
||||
@ -659,7 +672,7 @@ export function main() {
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
|
||||
var cmp = rootTC.componentViewChildren[0].getLocal('cmp');
|
||||
var cmp = rootTC.debugElement.componentViewChildren[0].getLocal('cmp');
|
||||
|
||||
rootTC.detectChanges();
|
||||
expect(cmp.numberOfChecks).toEqual(1);
|
||||
@ -685,13 +698,13 @@ export function main() {
|
||||
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
var cmp = rootTC.componentViewChildren[0].getLocal('cmp');
|
||||
var cmp = rootTC.debugElement.componentViewChildren[0].getLocal('cmp');
|
||||
|
||||
rootTC.componentInstance.ctxProp = "one";
|
||||
rootTC.debugElement.componentInstance.ctxProp = "one";
|
||||
rootTC.detectChanges();
|
||||
expect(cmp.numberOfChecks).toEqual(1);
|
||||
|
||||
rootTC.componentInstance.ctxProp = "two";
|
||||
rootTC.debugElement.componentInstance.ctxProp = "two";
|
||||
rootTC.detectChanges();
|
||||
expect(cmp.numberOfChecks).toEqual(2);
|
||||
|
||||
@ -711,13 +724,13 @@ export function main() {
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
|
||||
var cmp = rootTC.componentViewChildren[0].getLocal('cmp');
|
||||
var cmp = rootTC.debugElement.componentViewChildren[0].getLocal('cmp');
|
||||
|
||||
rootTC.componentInstance.ctxProp = "one";
|
||||
rootTC.debugElement.componentInstance.ctxProp = "one";
|
||||
rootTC.detectChanges();
|
||||
expect(cmp.prop).toEqual("one");
|
||||
|
||||
rootTC.componentInstance.ctxProp = "two";
|
||||
rootTC.debugElement.componentInstance.ctxProp = "two";
|
||||
rootTC.detectChanges();
|
||||
expect(cmp.prop).toEqual("two");
|
||||
|
||||
@ -733,11 +746,11 @@ export function main() {
|
||||
directives: [[[PushCmpWithAsyncPipe]]]
|
||||
}));
|
||||
|
||||
var rootTC;
|
||||
var rootTC: RootTestComponent;
|
||||
tcb.createAsync(MyComp).then(root => { rootTC = root; });
|
||||
tick();
|
||||
|
||||
var cmp = rootTC.componentViewChildren[0].getLocal('cmp');
|
||||
var cmp = rootTC.debugElement.componentViewChildren[0].getLocal('cmp');
|
||||
rootTC.detectChanges();
|
||||
expect(cmp.numberOfChecks).toEqual(1);
|
||||
|
||||
@ -770,7 +783,8 @@ export function main() {
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
|
||||
var childComponent = rootTC.componentViewChildren[0].getLocal('child');
|
||||
var childComponent =
|
||||
rootTC.debugElement.componentViewChildren[0].getLocal('child');
|
||||
expect(childComponent.myHost).toBeAnInstanceOf(SomeDirective);
|
||||
|
||||
async.done();
|
||||
@ -792,7 +806,7 @@ export function main() {
|
||||
.then((rootTC) => {
|
||||
rootTC.detectChanges();
|
||||
|
||||
var tc = rootTC.componentViewChildren[0].children[1];
|
||||
var tc = rootTC.debugElement.componentViewChildren[0].children[1];
|
||||
|
||||
var childComponent = tc.getLocal('child');
|
||||
expect(childComponent.myHost).toBeAnInstanceOf(SomeDirective);
|
||||
@ -811,7 +825,7 @@ export function main() {
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
|
||||
var tc = rootTC.componentViewChildren[0];
|
||||
var tc = rootTC.debugElement.componentViewChildren[0];
|
||||
var emitter = tc.inject(DirectiveEmitingEvent);
|
||||
var listener = tc.inject(DirectiveListeningEvent);
|
||||
|
||||
@ -835,16 +849,16 @@ export function main() {
|
||||
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
var tc = rootTC.componentViewChildren[0];
|
||||
var tc = rootTC.debugElement.componentViewChildren[0];
|
||||
var dir = tc.inject(DirectiveWithTwoWayBinding);
|
||||
|
||||
rootTC.componentInstance.ctxProp = 'one';
|
||||
rootTC.debugElement.componentInstance.ctxProp = 'one';
|
||||
rootTC.detectChanges();
|
||||
|
||||
expect(dir.value).toEqual('one');
|
||||
|
||||
ObservableWrapper.subscribe(dir.control, (_) => {
|
||||
expect(rootTC.componentInstance.ctxProp).toEqual('two');
|
||||
expect(rootTC.debugElement.componentInstance.ctxProp).toEqual('two');
|
||||
async.done();
|
||||
});
|
||||
|
||||
@ -862,7 +876,7 @@ export function main() {
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
|
||||
var tc = rootTC.componentViewChildren[0];
|
||||
var tc = rootTC.debugElement.componentViewChildren[0];
|
||||
var listener = tc.inject(DirectiveListeningDomEvent);
|
||||
|
||||
dispatchEvent(tc.nativeElement, 'domEvent');
|
||||
@ -884,7 +898,7 @@ export function main() {
|
||||
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
var tc = rootTC.componentViewChildren[0];
|
||||
var tc = rootTC.debugElement.componentViewChildren[0];
|
||||
var listener = tc.inject(DirectiveListeningDomEvent);
|
||||
dispatchEvent(DOM.getGlobalEventTarget("window"), 'domEvent');
|
||||
expect(listener.eventTypes).toEqual(['window_domEvent']);
|
||||
@ -913,7 +927,8 @@ export function main() {
|
||||
.then((rootTC) => {
|
||||
rootTC.detectChanges();
|
||||
|
||||
expect(DOM.getAttribute(rootTC.componentViewChildren[0].nativeElement, "role"))
|
||||
expect(DOM.getAttribute(rootTC.debugElement.componentViewChildren[0].nativeElement,
|
||||
"role"))
|
||||
.toEqual("button");
|
||||
|
||||
async.done();
|
||||
@ -929,7 +944,7 @@ export function main() {
|
||||
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
var tc = rootTC.componentViewChildren[0];
|
||||
var tc = rootTC.debugElement.componentViewChildren[0];
|
||||
var updateHost = tc.inject(DirectiveUpdatingHostProperties);
|
||||
|
||||
updateHost.id = "newId";
|
||||
@ -961,15 +976,17 @@ export function main() {
|
||||
.then((rootTC) => {
|
||||
var dispatchedEvent = DOM.createMouseEvent('click');
|
||||
var dispatchedEvent2 = DOM.createMouseEvent('click');
|
||||
DOM.dispatchEvent(rootTC.componentViewChildren[0].nativeElement,
|
||||
DOM.dispatchEvent(rootTC.debugElement.componentViewChildren[0].nativeElement,
|
||||
dispatchedEvent);
|
||||
DOM.dispatchEvent(rootTC.componentViewChildren[1].nativeElement,
|
||||
DOM.dispatchEvent(rootTC.debugElement.componentViewChildren[1].nativeElement,
|
||||
dispatchedEvent2);
|
||||
expect(DOM.isPrevented(dispatchedEvent)).toBe(true);
|
||||
expect(DOM.isPrevented(dispatchedEvent2)).toBe(false);
|
||||
expect(DOM.getChecked(rootTC.componentViewChildren[0].nativeElement))
|
||||
expect(
|
||||
DOM.getChecked(rootTC.debugElement.componentViewChildren[0].nativeElement))
|
||||
.toBeFalsy();
|
||||
expect(DOM.getChecked(rootTC.componentViewChildren[1].nativeElement))
|
||||
expect(
|
||||
DOM.getChecked(rootTC.debugElement.componentViewChildren[1].nativeElement))
|
||||
.toBeTruthy();
|
||||
async.done();
|
||||
});
|
||||
@ -988,10 +1005,10 @@ export function main() {
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
globalCounter = 0;
|
||||
rootTC.componentInstance.ctxBoolProp = true;
|
||||
rootTC.debugElement.componentInstance.ctxBoolProp = true;
|
||||
rootTC.detectChanges();
|
||||
|
||||
var tc = rootTC.componentViewChildren[1];
|
||||
var tc = rootTC.debugElement.componentViewChildren[1];
|
||||
|
||||
var listener = tc.inject(DirectiveListeningDomEvent);
|
||||
var listenerother = tc.inject(DirectiveListeningDomEventOther);
|
||||
@ -1001,12 +1018,12 @@ export function main() {
|
||||
expect(globalCounter).toEqual(1);
|
||||
|
||||
|
||||
rootTC.componentInstance.ctxBoolProp = false;
|
||||
rootTC.debugElement.componentInstance.ctxBoolProp = false;
|
||||
rootTC.detectChanges();
|
||||
dispatchEvent(DOM.getGlobalEventTarget("window"), 'domEvent');
|
||||
expect(globalCounter).toEqual(1);
|
||||
|
||||
rootTC.componentInstance.ctxBoolProp = true;
|
||||
rootTC.debugElement.componentInstance.ctxBoolProp = true;
|
||||
rootTC.detectChanges();
|
||||
dispatchEvent(DOM.getGlobalEventTarget("window"), 'domEvent');
|
||||
expect(globalCounter).toEqual(2);
|
||||
@ -1027,11 +1044,11 @@ export function main() {
|
||||
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
var tc = rootTC.componentViewChildren[0];
|
||||
var tc = rootTC.debugElement.componentViewChildren[0];
|
||||
var dynamicVp = tc.inject(DynamicViewport);
|
||||
dynamicVp.done.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.componentViewChildren[1].nativeElement)
|
||||
expect(rootTC.debugElement.componentViewChildren[1].nativeElement)
|
||||
.toHaveText('dynamic greet');
|
||||
async.done();
|
||||
});
|
||||
@ -1048,7 +1065,7 @@ export function main() {
|
||||
{template: '<input static type="text" title>', directives: [NeedsAttribute]}))
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
var tc = rootTC.componentViewChildren[0];
|
||||
var tc = rootTC.debugElement.componentViewChildren[0];
|
||||
var needsAttribute = tc.inject(NeedsAttribute);
|
||||
expect(needsAttribute.typeAttribute).toEqual('text');
|
||||
expect(needsAttribute.staticAttribute).toEqual('');
|
||||
@ -1074,7 +1091,7 @@ export function main() {
|
||||
}))
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
var comp = rootTC.componentViewChildren[0].getLocal("consuming");
|
||||
var comp = rootTC.debugElement.componentViewChildren[0].getLocal("consuming");
|
||||
expect(comp.injectable).toBeAnInstanceOf(InjectableService);
|
||||
|
||||
async.done();
|
||||
@ -1092,7 +1109,7 @@ export function main() {
|
||||
}))
|
||||
.createAsync(DirectiveProvidingInjectableInView)
|
||||
.then((rootTC) => {
|
||||
var comp = rootTC.componentViewChildren[0].getLocal("consuming");
|
||||
var comp = rootTC.debugElement.componentViewChildren[0].getLocal("consuming");
|
||||
expect(comp.injectable).toBeAnInstanceOf(InjectableService);
|
||||
|
||||
async.done();
|
||||
@ -1122,7 +1139,7 @@ export function main() {
|
||||
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
var comp = rootTC.componentViewChildren[0].getLocal("dir");
|
||||
var comp = rootTC.debugElement.componentViewChildren[0].getLocal("dir");
|
||||
expect(comp.directive.injectable).toBeAnInstanceOf(InjectableService);
|
||||
|
||||
async.done();
|
||||
@ -1148,7 +1165,7 @@ export function main() {
|
||||
}))
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
var gpComp = rootTC.componentViewChildren[0];
|
||||
var gpComp = rootTC.debugElement.componentViewChildren[0];
|
||||
var parentComp = gpComp.children[0];
|
||||
var childComp = parentComp.children[0];
|
||||
|
||||
@ -1180,10 +1197,10 @@ export function main() {
|
||||
}))
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
var providing = rootTC.componentViewChildren[0].getLocal("providing");
|
||||
var providing = rootTC.debugElement.componentViewChildren[0].getLocal("providing");
|
||||
expect(providing.created).toBe(false);
|
||||
|
||||
rootTC.componentInstance.ctxBoolProp = true;
|
||||
rootTC.debugElement.componentInstance.ctxBoolProp = true;
|
||||
rootTC.detectChanges();
|
||||
|
||||
expect(providing.created).toBe(true);
|
||||
@ -1203,7 +1220,8 @@ export function main() {
|
||||
}))
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
expect(DOM.querySelectorAll(rootTC.nativeElement, 'script').length).toEqual(0);
|
||||
expect(DOM.querySelectorAll(rootTC.debugElement.nativeElement, 'script').length)
|
||||
.toEqual(0);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@ -1281,7 +1299,7 @@ export function main() {
|
||||
expect(DOM.nodeName(c.componentElement).toUpperCase()).toEqual("DIV");
|
||||
expect(c.injector).toBeAnInstanceOf(Injector);
|
||||
expect(c.expression).toContain("one.two.three");
|
||||
expect(c.context).toBe(rootTC.componentInstance);
|
||||
expect(c.context).toBe(rootTC.debugElement.componentInstance);
|
||||
expect(c.locals["local"]).toBeDefined();
|
||||
}
|
||||
|
||||
@ -1318,11 +1336,11 @@ export function main() {
|
||||
directives: [DirectiveEmitingEvent, DirectiveListeningEvent]
|
||||
}));
|
||||
|
||||
var rootTC;
|
||||
var rootTC: RootTestComponent;
|
||||
tcb.createAsync(MyComp).then(root => { rootTC = root; });
|
||||
tick();
|
||||
|
||||
var tc = rootTC.componentViewChildren[0];
|
||||
var tc = rootTC.debugElement.componentViewChildren[0];
|
||||
tc.inject(DirectiveEmitingEvent).fireEvent("boom");
|
||||
|
||||
try {
|
||||
@ -1335,7 +1353,7 @@ export function main() {
|
||||
expect(DOM.nodeName(c.element).toUpperCase()).toEqual("SPAN");
|
||||
expect(DOM.nodeName(c.componentElement).toUpperCase()).toEqual("DIV");
|
||||
expect(c.injector).toBeAnInstanceOf(Injector);
|
||||
expect(c.context).toBe(rootTC.componentInstance);
|
||||
expect(c.context).toBe(rootTC.debugElement.componentInstance);
|
||||
expect(c.locals["local"]).toBeDefined();
|
||||
}
|
||||
})));
|
||||
@ -1411,7 +1429,7 @@ export function main() {
|
||||
}))
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
expect(rootTC.nativeElement).toHaveText('hello imp view');
|
||||
expect(rootTC.debugElement.nativeElement).toHaveText('hello imp view');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@ -1424,18 +1442,18 @@ export function main() {
|
||||
directives: [SomeImperativeViewport]
|
||||
}))
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
.then((rootTC: RootTestComponent) => {
|
||||
rootTC.detectChanges();
|
||||
expect(anchorElement).toHaveText('');
|
||||
|
||||
rootTC.componentInstance.ctxBoolProp = true;
|
||||
rootTC.debugElement.componentInstance.ctxBoolProp = true;
|
||||
rootTC.detectChanges();
|
||||
|
||||
expect(anchorElement).toHaveText('hello');
|
||||
|
||||
rootTC.componentInstance.ctxBoolProp = false;
|
||||
rootTC.debugElement.componentInstance.ctxBoolProp = false;
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.nativeElement).toHaveText('');
|
||||
expect(rootTC.debugElement.nativeElement).toHaveText('');
|
||||
|
||||
async.done();
|
||||
});
|
||||
@ -1478,10 +1496,10 @@ export function main() {
|
||||
}))
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
rootTC.componentInstance.ctxProp = "TITLE";
|
||||
rootTC.debugElement.componentInstance.ctxProp = "TITLE";
|
||||
rootTC.detectChanges();
|
||||
|
||||
var el = DOM.querySelector(rootTC.nativeElement, "span");
|
||||
var el = DOM.querySelector(rootTC.debugElement.nativeElement, "span");
|
||||
expect(isBlank(el.title) || el.title == '').toBeTruthy();
|
||||
|
||||
async.done();
|
||||
@ -1497,10 +1515,10 @@ export function main() {
|
||||
}))
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
rootTC.componentInstance.ctxProp = "TITLE";
|
||||
rootTC.debugElement.componentInstance.ctxProp = "TITLE";
|
||||
rootTC.detectChanges();
|
||||
|
||||
var el = DOM.querySelector(rootTC.nativeElement, "span");
|
||||
var el = DOM.querySelector(rootTC.debugElement.nativeElement, "span");
|
||||
expect(el.title).toEqual("TITLE");
|
||||
|
||||
async.done();
|
||||
@ -1525,10 +1543,10 @@ export function main() {
|
||||
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
rootTC.componentInstance.ctxProp = 'hello';
|
||||
rootTC.debugElement.componentInstance.ctxProp = 'hello';
|
||||
rootTC.detectChanges();
|
||||
|
||||
expect(DOM.getInnerHTML(rootTC.nativeElement))
|
||||
expect(DOM.getInnerHTML(rootTC.debugElement.nativeElement))
|
||||
.toContain('ng-reflect-dir-prop="hello"');
|
||||
async.done();
|
||||
});
|
||||
@ -1543,10 +1561,10 @@ export function main() {
|
||||
new ViewMetadata({template: `<!--${mode}--><div>{{ctxProp}}</div>`}))
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
rootTC.componentInstance.ctxProp = 'Hello World!';
|
||||
rootTC.debugElement.componentInstance.ctxProp = 'Hello World!';
|
||||
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.nativeElement).toHaveText('Hello World!');
|
||||
expect(rootTC.debugElement.nativeElement).toHaveText('Hello World!');
|
||||
async.done();
|
||||
});
|
||||
});
|
||||
@ -1621,7 +1639,8 @@ export function main() {
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
rootTC.detectChanges();
|
||||
var dir = rootTC.componentViewChildren[0].inject(DirectiveWithPropDecorators);
|
||||
var dir = rootTC.debugElement.componentViewChildren[0].inject(
|
||||
DirectiveWithPropDecorators);
|
||||
expect(dir.dirProp).toEqual("aaa");
|
||||
async.done();
|
||||
});
|
||||
@ -1636,11 +1655,13 @@ export function main() {
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
rootTC.detectChanges();
|
||||
var dir = rootTC.componentViewChildren[0].inject(DirectiveWithPropDecorators);
|
||||
var dir = rootTC.debugElement.componentViewChildren[0].inject(
|
||||
DirectiveWithPropDecorators);
|
||||
dir.myAttr = "aaa";
|
||||
|
||||
rootTC.detectChanges();
|
||||
expect(DOM.getOuterHTML(rootTC.componentViewChildren[0].nativeElement))
|
||||
expect(
|
||||
DOM.getOuterHTML(rootTC.debugElement.componentViewChildren[0].nativeElement))
|
||||
.toContain('my-attr="aaa"');
|
||||
async.done();
|
||||
});
|
||||
@ -1655,38 +1676,39 @@ export function main() {
|
||||
directives: [DirectiveWithPropDecorators]
|
||||
}));
|
||||
|
||||
var rootTC;
|
||||
var rootTC: RootTestComponent;
|
||||
tcb.createAsync(MyComp).then(root => { rootTC = root; });
|
||||
tick();
|
||||
|
||||
var emitter =
|
||||
rootTC.componentViewChildren[0].inject(DirectiveWithPropDecorators);
|
||||
var emitter = rootTC.debugElement.componentViewChildren[0].inject(
|
||||
DirectiveWithPropDecorators);
|
||||
emitter.fireEvent('fired !');
|
||||
|
||||
tick();
|
||||
|
||||
expect(rootTC.componentInstance.ctxProp).toEqual("called");
|
||||
expect(rootTC.debugElement.componentInstance.ctxProp).toEqual("called");
|
||||
})));
|
||||
|
||||
|
||||
it('should support host listener decorators',
|
||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder,
|
||||
async) => {
|
||||
tcb.overrideView(MyComp, new ViewMetadata({
|
||||
template: '<with-prop-decorators></with-prop-decorators>',
|
||||
directives: [DirectiveWithPropDecorators]
|
||||
}))
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
rootTC.detectChanges();
|
||||
var dir = rootTC.componentViewChildren[0].inject(DirectiveWithPropDecorators);
|
||||
var native = rootTC.componentViewChildren[0].nativeElement;
|
||||
native.click();
|
||||
inject([TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async) => {
|
||||
tcb.overrideView(MyComp, new ViewMetadata({
|
||||
template: '<with-prop-decorators></with-prop-decorators>',
|
||||
directives: [DirectiveWithPropDecorators]
|
||||
}))
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
rootTC.detectChanges();
|
||||
var dir = rootTC.debugElement.componentViewChildren[0].inject(
|
||||
DirectiveWithPropDecorators);
|
||||
var native = rootTC.debugElement.componentViewChildren[0].nativeElement;
|
||||
native.click();
|
||||
|
||||
expect(dir.target).toBe(native);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
expect(dir.target).toBe(native);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -2255,4 +2277,4 @@ class DirectiveWithPropDecorators {
|
||||
}
|
||||
|
||||
fireEvent(msg) { ObservableWrapper.callNext(this.event, msg); }
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ export function main() {
|
||||
}))
|
||||
.createAsync(MainComp)
|
||||
.then((main) => {
|
||||
expect(main.nativeElement).toHaveText('SIMPLE(A)');
|
||||
expect(main.debugElement.nativeElement).toHaveText('SIMPLE(A)');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@ -65,9 +65,9 @@ export function main() {
|
||||
.createAsync(MainComp)
|
||||
.then((main) => {
|
||||
|
||||
main.componentInstance.text = 'A';
|
||||
main.debugElement.componentInstance.text = 'A';
|
||||
main.detectChanges();
|
||||
expect(main.nativeElement).toHaveText('START(SIMPLE(A))END');
|
||||
expect(main.debugElement.nativeElement).toHaveText('START(SIMPLE(A))END');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@ -84,9 +84,9 @@ export function main() {
|
||||
.createAsync(MainComp)
|
||||
.then((main) => {
|
||||
|
||||
main.componentInstance.text = 'A';
|
||||
main.debugElement.componentInstance.text = 'A';
|
||||
main.detectChanges();
|
||||
expect(main.nativeElement).toHaveText('SIMPLE(A)');
|
||||
expect(main.debugElement.nativeElement).toHaveText('SIMPLE(A)');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@ -106,9 +106,9 @@ export function main() {
|
||||
.createAsync(MainComp)
|
||||
.then((main) => {
|
||||
|
||||
main.componentInstance.text = 'A';
|
||||
main.debugElement.componentInstance.text = 'A';
|
||||
main.detectChanges();
|
||||
expect(main.nativeElement).toHaveText('SIMPLE(AEL)');
|
||||
expect(main.debugElement.nativeElement).toHaveText('SIMPLE(AEL)');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@ -120,7 +120,7 @@ export function main() {
|
||||
.createAsync(MainComp)
|
||||
.then((main) => {
|
||||
|
||||
expect(main.nativeElement).toHaveText('');
|
||||
expect(main.debugElement.nativeElement).toHaveText('');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@ -138,7 +138,7 @@ export function main() {
|
||||
.createAsync(MainComp)
|
||||
.then((main) => {
|
||||
|
||||
expect(main.nativeElement).toHaveText('(A, BC)');
|
||||
expect(main.debugElement.nativeElement).toHaveText('(A, BC)');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@ -155,7 +155,7 @@ export function main() {
|
||||
.createAsync(MainComp)
|
||||
.then((main) => {
|
||||
|
||||
expect(main.nativeElement).toHaveText('(, BAC)');
|
||||
expect(main.debugElement.nativeElement).toHaveText('(, BAC)');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@ -172,16 +172,17 @@ export function main() {
|
||||
.createAsync(MainComp)
|
||||
.then((main) => {
|
||||
|
||||
var viewportDirectives = main.queryAll(By.directive(ManualViewportDirective))
|
||||
.map(de => de.inject(ManualViewportDirective));
|
||||
var viewportDirectives =
|
||||
main.debugElement.queryAll(By.directive(ManualViewportDirective))
|
||||
.map(de => de.inject(ManualViewportDirective));
|
||||
|
||||
expect(main.nativeElement).toHaveText('(, B)');
|
||||
expect(main.debugElement.nativeElement).toHaveText('(, B)');
|
||||
viewportDirectives.forEach(d => d.show());
|
||||
expect(main.nativeElement).toHaveText('(A1, B)');
|
||||
expect(main.debugElement.nativeElement).toHaveText('(A1, B)');
|
||||
|
||||
viewportDirectives.forEach(d => d.hide());
|
||||
|
||||
expect(main.nativeElement).toHaveText('(, B)');
|
||||
expect(main.debugElement.nativeElement).toHaveText('(, B)');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@ -198,7 +199,7 @@ export function main() {
|
||||
.createAsync(MainComp)
|
||||
.then((main) => {
|
||||
|
||||
expect(main.nativeElement).toHaveText('OUTER(SIMPLE(AB))');
|
||||
expect(main.debugElement.nativeElement).toHaveText('OUTER(SIMPLE(AB))');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@ -216,13 +217,14 @@ export function main() {
|
||||
.createAsync(MainComp)
|
||||
.then((main) => {
|
||||
|
||||
var viewportDirective = main.query(By.directive(ManualViewportDirective))
|
||||
.inject(ManualViewportDirective);
|
||||
var viewportDirective =
|
||||
main.debugElement.query(By.directive(ManualViewportDirective))
|
||||
.inject(ManualViewportDirective);
|
||||
|
||||
expect(main.nativeElement).toHaveText('OUTER(INNER(INNERINNER(,BC)))');
|
||||
expect(main.debugElement.nativeElement).toHaveText('OUTER(INNER(INNERINNER(,BC)))');
|
||||
viewportDirective.show();
|
||||
|
||||
expect(main.nativeElement).toHaveText('OUTER(INNER(INNERINNER(A,BC)))');
|
||||
expect(main.debugElement.nativeElement).toHaveText('OUTER(INNER(INNERINNER(A,BC)))');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@ -240,17 +242,18 @@ export function main() {
|
||||
.createAsync(MainComp)
|
||||
.then((main) => {
|
||||
|
||||
var viewportDirective = main.query(By.directive(ManualViewportDirective))
|
||||
.inject(ManualViewportDirective);
|
||||
var viewportDirective =
|
||||
main.debugElement.query(By.directive(ManualViewportDirective))
|
||||
.inject(ManualViewportDirective);
|
||||
|
||||
expect(main.nativeElement).toHaveText('(, BC)');
|
||||
expect(main.debugElement.nativeElement).toHaveText('(, BC)');
|
||||
|
||||
viewportDirective.show();
|
||||
expect(main.nativeElement).toHaveText('(A, BC)');
|
||||
expect(main.debugElement.nativeElement).toHaveText('(A, BC)');
|
||||
|
||||
viewportDirective.hide();
|
||||
|
||||
expect(main.nativeElement).toHaveText('(, BC)');
|
||||
expect(main.debugElement.nativeElement).toHaveText('(, BC)');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@ -267,11 +270,11 @@ export function main() {
|
||||
{template: '<simple string-prop="text"></simple>', directives: [Simple]}))
|
||||
.overrideTemplate(Simple, '<ng-content></ng-content><p>P,</p>{{stringProp}}')
|
||||
.createAsync(MainComp)
|
||||
.then((main) => {
|
||||
.then((main: RootTestComponent) => {
|
||||
|
||||
main.detectChanges();
|
||||
|
||||
expect(main.nativeElement).toHaveText('P,text');
|
||||
expect(main.debugElement.nativeElement).toHaveText('P,text');
|
||||
async.done();
|
||||
});
|
||||
|
||||
@ -288,10 +291,10 @@ export function main() {
|
||||
{template: '<simple string-prop="text"></simple>', directives: [Simple]}))
|
||||
.overrideTemplate(Simple, '<style></style><p>P,</p>{{stringProp}}')
|
||||
.createAsync(MainComp)
|
||||
.then((main) => {
|
||||
.then((main: RootTestComponent) => {
|
||||
|
||||
main.detectChanges();
|
||||
expect(main.nativeElement).toHaveText('P,text');
|
||||
expect(main.debugElement.nativeElement).toHaveText('P,text');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@ -309,14 +312,14 @@ export function main() {
|
||||
.then((main) => {
|
||||
|
||||
var sourceDirective: ManualViewportDirective =
|
||||
main.query(By.directive(ManualViewportDirective))
|
||||
main.debugElement.query(By.directive(ManualViewportDirective))
|
||||
.inject(ManualViewportDirective);
|
||||
var projectDirective: ProjectDirective =
|
||||
main.query(By.directive(ProjectDirective)).inject(ProjectDirective);
|
||||
expect(main.nativeElement).toHaveText('START()END');
|
||||
main.debugElement.query(By.directive(ProjectDirective)).inject(ProjectDirective);
|
||||
expect(main.debugElement.nativeElement).toHaveText('START()END');
|
||||
|
||||
projectDirective.show(sourceDirective.templateRef);
|
||||
expect(main.nativeElement).toHaveText('START(A)END');
|
||||
expect(main.debugElement.nativeElement).toHaveText('START(A)END');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@ -332,14 +335,14 @@ export function main() {
|
||||
.then((main) => {
|
||||
|
||||
var sourceDirective: ManualViewportDirective =
|
||||
main.query(By.directive(ManualViewportDirective))
|
||||
main.debugElement.query(By.directive(ManualViewportDirective))
|
||||
.inject(ManualViewportDirective);
|
||||
var projectDirective: ProjectDirective =
|
||||
main.query(By.directive(ProjectDirective)).inject(ProjectDirective);
|
||||
expect(main.nativeElement).toHaveText('SIMPLE()START()END');
|
||||
main.debugElement.query(By.directive(ProjectDirective)).inject(ProjectDirective);
|
||||
expect(main.debugElement.nativeElement).toHaveText('SIMPLE()START()END');
|
||||
|
||||
projectDirective.show(sourceDirective.templateRef);
|
||||
expect(main.nativeElement).toHaveText('SIMPLE()START(A)END');
|
||||
expect(main.debugElement.nativeElement).toHaveText('SIMPLE()START(A)END');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@ -360,19 +363,19 @@ export function main() {
|
||||
.then((main) => {
|
||||
|
||||
var sourceDirective: ManualViewportDirective =
|
||||
main.query(By.directive(ManualViewportDirective))
|
||||
main.debugElement.query(By.directive(ManualViewportDirective))
|
||||
.inject(ManualViewportDirective);
|
||||
var projectDirective: ProjectDirective =
|
||||
main.query(By.directive(ProjectDirective)).inject(ProjectDirective);
|
||||
expect(main.nativeElement).toHaveText('(, B)START()END');
|
||||
main.debugElement.query(By.directive(ProjectDirective)).inject(ProjectDirective);
|
||||
expect(main.debugElement.nativeElement).toHaveText('(, B)START()END');
|
||||
|
||||
projectDirective.show(sourceDirective.templateRef);
|
||||
expect(main.nativeElement).toHaveText('(, B)START(A)END');
|
||||
expect(main.debugElement.nativeElement).toHaveText('(, B)START(A)END');
|
||||
|
||||
// Stamping ng-content multiple times should not produce the content multiple
|
||||
// times...
|
||||
projectDirective.show(sourceDirective.templateRef);
|
||||
expect(main.nativeElement).toHaveText('(, B)START(A)END');
|
||||
expect(main.debugElement.nativeElement).toHaveText('(, B)START(A)END');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@ -390,12 +393,12 @@ export function main() {
|
||||
|
||||
main.detectChanges();
|
||||
var manualDirective: ManualViewportDirective =
|
||||
main.query(By.directive(ManualViewportDirective))
|
||||
main.debugElement.query(By.directive(ManualViewportDirective))
|
||||
.inject(ManualViewportDirective);
|
||||
expect(main.nativeElement).toHaveText('TREE(0:)');
|
||||
expect(main.debugElement.nativeElement).toHaveText('TREE(0:)');
|
||||
manualDirective.show();
|
||||
main.detectChanges();
|
||||
expect(main.nativeElement).toHaveText('TREE(0:TREE(1:))');
|
||||
expect(main.debugElement.nativeElement).toHaveText('TREE(0:TREE(1:))');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@ -412,7 +415,7 @@ export function main() {
|
||||
.createAsync(MainComp)
|
||||
.then((main) => {
|
||||
|
||||
expect(main.nativeElement).toHaveText('SIMPLE(A)');
|
||||
expect(main.debugElement.nativeElement).toHaveText('SIMPLE(A)');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@ -429,15 +432,17 @@ export function main() {
|
||||
}))
|
||||
.createAsync(MainComp)
|
||||
.then((main) => {
|
||||
expect(main.nativeElement).toHaveText('MAIN()');
|
||||
expect(main.debugElement.nativeElement).toHaveText('MAIN()');
|
||||
|
||||
var viewportElement = main.componentViewChildren[0].componentViewChildren[0];
|
||||
var viewportElement =
|
||||
main.debugElement.componentViewChildren[0].componentViewChildren[0];
|
||||
viewportElement.inject(ManualViewportDirective).show();
|
||||
expect(main.nativeElement).toHaveText('MAIN(FIRST())');
|
||||
expect(main.debugElement.nativeElement).toHaveText('MAIN(FIRST())');
|
||||
|
||||
viewportElement = main.componentViewChildren[0].componentViewChildren[1];
|
||||
viewportElement =
|
||||
main.debugElement.componentViewChildren[0].componentViewChildren[1];
|
||||
viewportElement.inject(ManualViewportDirective).show();
|
||||
expect(main.nativeElement).toHaveText('MAIN(FIRST(SECOND(a)))');
|
||||
expect(main.debugElement.nativeElement).toHaveText('MAIN(FIRST(SECOND(a)))');
|
||||
|
||||
async.done();
|
||||
});
|
||||
|
@ -49,7 +49,8 @@ export function main() {
|
||||
.then((view) => {
|
||||
view.detectChanges();
|
||||
|
||||
expect(asNativeElements(view.componentViewChildren)).toHaveText('2|3|');
|
||||
expect(asNativeElements(view.debugElement.componentViewChildren))
|
||||
.toHaveText('2|3|');
|
||||
|
||||
async.done();
|
||||
});
|
||||
@ -67,7 +68,8 @@ export function main() {
|
||||
.createAsync(MyComp)
|
||||
.then((view) => {
|
||||
view.detectChanges();
|
||||
expect(asNativeElements(view.componentViewChildren)).toHaveText('2|3|4|');
|
||||
expect(asNativeElements(view.debugElement.componentViewChildren))
|
||||
.toHaveText('2|3|4|');
|
||||
|
||||
async.done();
|
||||
});
|
||||
@ -83,7 +85,8 @@ export function main() {
|
||||
.createAsync(MyComp)
|
||||
.then((view) => {
|
||||
view.detectChanges();
|
||||
expect(asNativeElements(view.componentViewChildren)).toHaveText('2|3|');
|
||||
expect(asNativeElements(view.debugElement.componentViewChildren))
|
||||
.toHaveText('2|3|');
|
||||
|
||||
async.done();
|
||||
});
|
||||
@ -101,11 +104,12 @@ export function main() {
|
||||
.then((view) => {
|
||||
|
||||
view.detectChanges();
|
||||
expect(asNativeElements(view.componentViewChildren)).toHaveText('2|');
|
||||
expect(asNativeElements(view.debugElement.componentViewChildren)).toHaveText('2|');
|
||||
|
||||
view.componentInstance.shouldShow = true;
|
||||
view.debugElement.componentInstance.shouldShow = true;
|
||||
view.detectChanges();
|
||||
expect(asNativeElements(view.componentViewChildren)).toHaveText('2|3|');
|
||||
expect(asNativeElements(view.debugElement.componentViewChildren))
|
||||
.toHaveText('2|3|');
|
||||
|
||||
async.done();
|
||||
});
|
||||
@ -121,7 +125,7 @@ export function main() {
|
||||
tcb.overrideTemplate(MyComp, template)
|
||||
.createAsync(MyComp)
|
||||
.then((rtc) => {
|
||||
rtc.componentInstance.shouldShow = true;
|
||||
rtc.debugElement.componentInstance.shouldShow = true;
|
||||
rtc.detectChanges();
|
||||
rtc.destroy();
|
||||
|
||||
@ -141,11 +145,13 @@ export function main() {
|
||||
.then((view) => {
|
||||
view.detectChanges();
|
||||
|
||||
expect(asNativeElements(view.componentViewChildren)).toHaveText('2|1d|2d|3d|');
|
||||
expect(asNativeElements(view.debugElement.componentViewChildren))
|
||||
.toHaveText('2|1d|2d|3d|');
|
||||
|
||||
view.componentInstance.list = ['3d', '2d'];
|
||||
view.debugElement.componentInstance.list = ['3d', '2d'];
|
||||
view.detectChanges();
|
||||
expect(asNativeElements(view.componentViewChildren)).toHaveText('2|3d|2d|');
|
||||
expect(asNativeElements(view.debugElement.componentViewChildren))
|
||||
.toHaveText('2|3d|2d|');
|
||||
|
||||
async.done();
|
||||
});
|
||||
@ -160,7 +166,8 @@ export function main() {
|
||||
.createAsync(MyComp)
|
||||
.then((view) => {
|
||||
view.detectChanges();
|
||||
var needsTpl: NeedsTpl = view.componentViewChildren[0].inject(NeedsTpl);
|
||||
var needsTpl: NeedsTpl =
|
||||
view.debugElement.componentViewChildren[0].inject(NeedsTpl);
|
||||
expect(needsTpl.query.first.hasLocal('light')).toBe(true);
|
||||
expect(needsTpl.viewQuery.first.hasLocal('shadow')).toBe(true);
|
||||
|
||||
@ -181,7 +188,7 @@ export function main() {
|
||||
tcb.overrideTemplate(MyComp, template)
|
||||
.createAsync(MyComp)
|
||||
.then((view) => {
|
||||
var q = view.componentViewChildren[0].getLocal("q");
|
||||
var q = view.debugElement.componentViewChildren[0].getLocal("q");
|
||||
view.detectChanges();
|
||||
|
||||
q.query.onChange(() => {
|
||||
@ -190,7 +197,7 @@ export function main() {
|
||||
async.done();
|
||||
});
|
||||
|
||||
view.componentInstance.shouldShow = true;
|
||||
view.debugElement.componentInstance.shouldShow = true;
|
||||
view.detectChanges();
|
||||
});
|
||||
}));
|
||||
@ -206,8 +213,8 @@ export function main() {
|
||||
tcb.overrideTemplate(MyComp, template)
|
||||
.createAsync(MyComp)
|
||||
.then((view) => {
|
||||
var q1 = view.componentViewChildren[0].getLocal("q1");
|
||||
var q2 = view.componentViewChildren[0].getLocal("q2");
|
||||
var q1 = view.debugElement.componentViewChildren[0].getLocal("q1");
|
||||
var q2 = view.debugElement.componentViewChildren[0].getLocal("q2");
|
||||
|
||||
var firedQ2 = false;
|
||||
|
||||
@ -229,19 +236,19 @@ export function main() {
|
||||
tcb.overrideTemplate(MyComp, template)
|
||||
.createAsync(MyComp)
|
||||
.then((view) => {
|
||||
view.componentInstance.shouldShow = true;
|
||||
view.debugElement.componentInstance.shouldShow = true;
|
||||
view.detectChanges();
|
||||
|
||||
var q: NeedsQuery = view.componentViewChildren[1].getLocal('q');
|
||||
var q: NeedsQuery = view.debugElement.componentViewChildren[1].getLocal('q');
|
||||
expect(q.query.length).toEqual(1);
|
||||
|
||||
view.componentInstance.shouldShow = false;
|
||||
view.debugElement.componentInstance.shouldShow = false;
|
||||
view.detectChanges();
|
||||
|
||||
view.componentInstance.shouldShow = true;
|
||||
view.debugElement.componentInstance.shouldShow = true;
|
||||
view.detectChanges();
|
||||
|
||||
var q2: NeedsQuery = view.componentViewChildren[1].getLocal('q');
|
||||
var q2: NeedsQuery = view.debugElement.componentViewChildren[1].getLocal('q');
|
||||
|
||||
expect(q2.query.length).toEqual(1);
|
||||
|
||||
@ -261,9 +268,9 @@ export function main() {
|
||||
tcb.overrideTemplate(MyComp, template)
|
||||
.createAsync(MyComp)
|
||||
.then((view) => {
|
||||
var q = view.componentViewChildren[0].getLocal("q");
|
||||
var q = view.debugElement.componentViewChildren[0].getLocal("q");
|
||||
|
||||
view.componentInstance.list = ['1d', '2d'];
|
||||
view.debugElement.componentInstance.list = ['1d', '2d'];
|
||||
|
||||
view.detectChanges();
|
||||
|
||||
@ -284,7 +291,7 @@ export function main() {
|
||||
tcb.overrideTemplate(MyComp, template)
|
||||
.createAsync(MyComp)
|
||||
.then((view) => {
|
||||
var q = view.componentViewChildren[0].getLocal("q");
|
||||
var q = view.debugElement.componentViewChildren[0].getLocal("q");
|
||||
view.detectChanges();
|
||||
|
||||
expect(q.query.first.text).toEqual("one");
|
||||
@ -304,13 +311,13 @@ export function main() {
|
||||
tcb.overrideTemplate(MyComp, template)
|
||||
.createAsync(MyComp)
|
||||
.then((view) => {
|
||||
var q = view.componentViewChildren[0].getLocal("q");
|
||||
var q = view.debugElement.componentViewChildren[0].getLocal("q");
|
||||
|
||||
view.componentInstance.list = ['1d', '2d'];
|
||||
view.debugElement.componentInstance.list = ['1d', '2d'];
|
||||
|
||||
view.detectChanges();
|
||||
|
||||
view.componentInstance.list = ['2d', '1d'];
|
||||
view.debugElement.componentInstance.list = ['2d', '1d'];
|
||||
|
||||
view.detectChanges();
|
||||
|
||||
@ -331,9 +338,9 @@ export function main() {
|
||||
tcb.overrideTemplate(MyComp, template)
|
||||
.createAsync(MyComp)
|
||||
.then((view) => {
|
||||
var q = view.componentViewChildren[0].getLocal("q");
|
||||
var q = view.debugElement.componentViewChildren[0].getLocal("q");
|
||||
|
||||
view.componentInstance.list = ['1d', '2d'];
|
||||
view.debugElement.componentInstance.list = ['1d', '2d'];
|
||||
|
||||
view.detectChanges();
|
||||
|
||||
@ -355,7 +362,8 @@ export function main() {
|
||||
.then((view) => {
|
||||
view.detectChanges();
|
||||
|
||||
expect(asNativeElements(view.componentViewChildren)).toHaveText('hello|world|');
|
||||
expect(asNativeElements(view.debugElement.componentViewChildren))
|
||||
.toHaveText('hello|world|');
|
||||
|
||||
async.done();
|
||||
});
|
||||
@ -368,7 +376,8 @@ export function main() {
|
||||
tcb.overrideTemplate(MyComp, template)
|
||||
.createAsync(MyComp)
|
||||
.then((view) => {
|
||||
var q: NeedsViewQueryByLabel = view.componentViewChildren[0].getLocal("q");
|
||||
var q: NeedsViewQueryByLabel =
|
||||
view.debugElement.componentViewChildren[0].getLocal("q");
|
||||
view.detectChanges();
|
||||
|
||||
expect(q.query.first.nativeElement).toHaveText("text");
|
||||
@ -386,7 +395,7 @@ export function main() {
|
||||
tcb.overrideTemplate(MyComp, template)
|
||||
.createAsync(MyComp)
|
||||
.then((view) => {
|
||||
var q: NeedsViewQuery = view.componentViewChildren[0].getLocal("q");
|
||||
var q: NeedsViewQuery = view.debugElement.componentViewChildren[0].getLocal("q");
|
||||
|
||||
view.detectChanges();
|
||||
|
||||
@ -403,7 +412,7 @@ export function main() {
|
||||
tcb.overrideTemplate(MyComp, template)
|
||||
.createAsync(MyComp)
|
||||
.then((view) => {
|
||||
var q: NeedsViewQuery = view.componentViewChildren[0].getLocal("q");
|
||||
var q: NeedsViewQuery = view.debugElement.componentViewChildren[0].getLocal("q");
|
||||
|
||||
view.detectChanges();
|
||||
|
||||
@ -420,7 +429,7 @@ export function main() {
|
||||
tcb.overrideTemplate(MyComp, template)
|
||||
.createAsync(MyComp)
|
||||
.then((view) => {
|
||||
var q: NeedsViewQueryIf = view.componentViewChildren[0].getLocal("q");
|
||||
var q: NeedsViewQueryIf = view.debugElement.componentViewChildren[0].getLocal("q");
|
||||
|
||||
view.detectChanges();
|
||||
|
||||
@ -443,7 +452,8 @@ export function main() {
|
||||
tcb.overrideTemplate(MyComp, template)
|
||||
.createAsync(MyComp)
|
||||
.then((view) => {
|
||||
var q: NeedsViewQueryNestedIf = view.componentViewChildren[0].getLocal("q");
|
||||
var q: NeedsViewQueryNestedIf =
|
||||
view.debugElement.componentViewChildren[0].getLocal("q");
|
||||
|
||||
view.detectChanges();
|
||||
|
||||
@ -468,7 +478,8 @@ export function main() {
|
||||
tcb.overrideTemplate(MyComp, template)
|
||||
.createAsync(MyComp)
|
||||
.then((view) => {
|
||||
var q: NeedsViewQueryOrder = view.componentViewChildren[0].getLocal("q");
|
||||
var q: NeedsViewQueryOrder =
|
||||
view.debugElement.componentViewChildren[0].getLocal("q");
|
||||
|
||||
view.detectChanges();
|
||||
|
||||
@ -491,7 +502,8 @@ export function main() {
|
||||
tcb.overrideTemplate(MyComp, template)
|
||||
.createAsync(MyComp)
|
||||
.then((view) => {
|
||||
var q: NeedsViewQueryOrderWithParent = view.componentViewChildren[0].getLocal("q");
|
||||
var q: NeedsViewQueryOrderWithParent =
|
||||
view.debugElement.componentViewChildren[0].getLocal("q");
|
||||
|
||||
view.detectChanges();
|
||||
|
||||
@ -514,7 +526,8 @@ export function main() {
|
||||
tcb.overrideTemplate(MyComp, template)
|
||||
.createAsync(MyComp)
|
||||
.then((view) => {
|
||||
var q: NeedsViewQueryOrder = view.componentViewChildren[0].getLocal('q');
|
||||
var q: NeedsViewQueryOrder =
|
||||
view.debugElement.componentViewChildren[0].getLocal('q');
|
||||
|
||||
// no significance to 50, just a reasonably large cycle.
|
||||
for (var i = 0; i < 50; i++) {
|
||||
|
Reference in New Issue
Block a user