feat(testing): export useful properties from componentFixture

The component fixture returned from the test component builder
now exports `nativeElement` and `componentInstance` members
directly. They are also still available on the `debugElement`.

See #5385
This commit is contained in:
Julie Ralph
2015-11-30 12:49:22 -08:00
committed by Jeremy Elbourn
parent 25a2d7b5db
commit e9f873a365
2 changed files with 32 additions and 10 deletions

View File

@ -99,7 +99,7 @@ export function main() {
tcb.createAsync(ChildComp).then((componentFixture) => {
componentFixture.detectChanges();
expect(componentFixture.debugElement.nativeElement).toHaveText('Original Child');
expect(componentFixture.nativeElement).toHaveText('Original Child');
async.done();
});
}));
@ -109,11 +109,11 @@ export function main() {
tcb.createAsync(MyIfComp).then((componentFixture) => {
componentFixture.detectChanges();
expect(componentFixture.debugElement.nativeElement).toHaveText('MyIf()');
expect(componentFixture.nativeElement).toHaveText('MyIf()');
componentFixture.debugElement.componentInstance.showMore = true;
componentFixture.componentInstance.showMore = true;
componentFixture.detectChanges();
expect(componentFixture.debugElement.nativeElement).toHaveText('MyIf(More)');
expect(componentFixture.nativeElement).toHaveText('MyIf(More)');
async.done();
});
@ -126,7 +126,7 @@ export function main() {
.createAsync(MockChildComp)
.then((componentFixture) => {
componentFixture.detectChanges();
expect(componentFixture.debugElement.nativeElement).toHaveText('Mock');
expect(componentFixture.nativeElement).toHaveText('Mock');
async.done();
});
@ -140,7 +140,7 @@ export function main() {
.createAsync(ChildComp)
.then((componentFixture) => {
componentFixture.detectChanges();
expect(componentFixture.debugElement.nativeElement).toHaveText('Modified Child');
expect(componentFixture.nativeElement).toHaveText('Modified Child');
async.done();
});
@ -153,7 +153,7 @@ export function main() {
.createAsync(ParentComp)
.then((componentFixture) => {
componentFixture.detectChanges();
expect(componentFixture.debugElement.nativeElement).toHaveText('Parent(Mock)');
expect(componentFixture.nativeElement).toHaveText('Parent(Mock)');
async.done();
});
@ -168,7 +168,7 @@ export function main() {
.createAsync(ParentComp)
.then((componentFixture) => {
componentFixture.detectChanges();
expect(componentFixture.debugElement.nativeElement)
expect(componentFixture.nativeElement)
.toHaveText('Parent(Original Child(ChildChild Mock))');
async.done();
@ -183,7 +183,7 @@ export function main() {
.createAsync(TestBindingsComp)
.then((componentFixture) => {
componentFixture.detectChanges();
expect(componentFixture.debugElement.nativeElement)
expect(componentFixture.nativeElement)
.toHaveText('injected value: mocked out value');
async.done();
});
@ -198,7 +198,7 @@ export function main() {
.createAsync(TestViewBindingsComp)
.then((componentFixture) => {
componentFixture.detectChanges();
expect(componentFixture.debugElement.nativeElement)
expect(componentFixture.nativeElement)
.toHaveText('injected value: mocked out value');
async.done();
});