chore(test): rename RootTestComponent to ComponentFixture

BREAKING CHANGE:

Before:

```
testComponentBuilder.createAsync(MyComponent).then(root: RootTestComponent => {
}
```

After:

```
testComponentBuilder.createAsync(MyComponent).then(fixture: ComponentFixture => {
}
```

Closes #4711
This commit is contained in:
Julie Ralph
2015-10-31 09:50:19 -07:00
parent a16214c614
commit 686457890d
25 changed files with 1128 additions and 1121 deletions

View File

@ -137,14 +137,14 @@ export function main() {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.createAsync(ParentComp)
.then((rootTestComponent) => {
rootTestComponent.detectChanges();
.then((componentFixture) => {
componentFixture.detectChanges();
var childEls = rootTestComponent.debugElement.children;
var childEls = componentFixture.debugElement.children;
// The root is a lone component, and has no children in the light dom.
expect(childEls.length).toEqual(0);
var rootCompChildren = rootTestComponent.debugElement.componentViewChildren;
var rootCompChildren = componentFixture.debugElement.componentViewChildren;
// The root component has 4 elements in its shadow view.
expect(rootCompChildren.length).toEqual(4);
expect(DOM.hasClass(rootCompChildren[0].nativeElement, 'parent')).toBe(true);
@ -185,10 +185,10 @@ export function main() {
it('should list child elements within viewports',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.createAsync(UsingFor).then((rootTestComponent) => {
rootTestComponent.detectChanges();
tcb.createAsync(UsingFor).then((componentFixture) => {
componentFixture.detectChanges();
var childEls = rootTestComponent.debugElement.componentViewChildren;
var childEls = componentFixture.debugElement.componentViewChildren;
// TODO should this count include the <template> element?
expect(childEls.length).toEqual(5);
@ -203,10 +203,10 @@ export function main() {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.createAsync(ParentComp)
.then((rootTestComponent) => {
rootTestComponent.detectChanges();
.then((componentFixture) => {
componentFixture.detectChanges();
var childTestEls = rootTestComponent.debugElement.queryAll(By.directive(MessageDir));
var childTestEls = componentFixture.debugElement.queryAll(By.directive(MessageDir));
expect(childTestEls.length).toBe(4);
expect(DOM.hasClass(childTestEls[0].nativeElement, 'parent')).toBe(true);
@ -221,10 +221,10 @@ export function main() {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.createAsync(ParentComp)
.then((rootTestComponent) => {
rootTestComponent.detectChanges();
.then((componentFixture) => {
componentFixture.detectChanges();
var parentEl = rootTestComponent.debugElement.componentViewChildren[0];
var parentEl = componentFixture.debugElement.componentViewChildren[0];
var childTestEls = parentEl.queryAll(By.directive(MessageDir), Scope.light);
@ -239,11 +239,11 @@ export function main() {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.createAsync(ParentComp)
.then((rootTestComponent) => {
rootTestComponent.detectChanges();
.then((componentFixture) => {
componentFixture.detectChanges();
var childTestEls =
rootTestComponent.debugElement.queryAll(By.directive(MessageDir), Scope.view);
componentFixture.debugElement.queryAll(By.directive(MessageDir), Scope.view);
expect(childTestEls.length).toBe(2);
expect(DOM.hasClass(childTestEls[0].nativeElement, 'parent')).toBe(true);
@ -257,10 +257,10 @@ export function main() {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.createAsync(ParentComp)
.then((rootTestComponent) => {
rootTestComponent.detectChanges();
.then((componentFixture) => {
componentFixture.detectChanges();
expect(rootTestComponent.debugElement.componentViewChildren[0].inject(Logger).log)
expect(componentFixture.debugElement.componentViewChildren[0].inject(Logger).log)
.toEqual(['parent', 'nestedparent', 'child', 'nestedchild']);
async.done();
@ -271,19 +271,19 @@ export function main() {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.createAsync(EventsComp)
.then((rootTestComponent) => {
rootTestComponent.detectChanges();
.then((componentFixture) => {
componentFixture.detectChanges();
expect(rootTestComponent.debugElement.componentInstance.clicked).toBe(false);
expect(rootTestComponent.debugElement.componentInstance.customed).toBe(false);
expect(componentFixture.debugElement.componentInstance.clicked).toBe(false);
expect(componentFixture.debugElement.componentInstance.customed).toBe(false);
rootTestComponent.debugElement.componentViewChildren[0].triggerEventHandler(
componentFixture.debugElement.componentViewChildren[0].triggerEventHandler(
'click', <Event>{});
expect(rootTestComponent.debugElement.componentInstance.clicked).toBe(true);
expect(componentFixture.debugElement.componentInstance.clicked).toBe(true);
rootTestComponent.debugElement.componentViewChildren[1].triggerEventHandler(
componentFixture.debugElement.componentViewChildren[1].triggerEventHandler(
'myevent', <Event>{});
expect(rootTestComponent.debugElement.componentInstance.customed).toBe(true);
expect(componentFixture.debugElement.componentInstance.customed).toBe(true);
async.done();
});

View File

@ -34,8 +34,8 @@ export function main() {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideTemplate(MyComp, '<div some-dir></div>')
.createAsync(MyComp)
.then((rootTestComponent) => {
expect(inspectNativeElement(rootTestComponent.debugElement.nativeElement)
.then((componentFixture) => {
expect(inspectNativeElement(componentFixture.debugElement.nativeElement)
.componentInstance)
.toBeAnInstanceOf(MyComp);
@ -47,10 +47,9 @@ export function main() {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideTemplate(MyComp, '')
.createAsync(MyComp)
.then((rootTestComponent) => {
rootTestComponent.destroy();
expect(inspectNativeElement(rootTestComponent.debugElement.nativeElement))
.toBe(null);
.then((componentFixture) => {
componentFixture.destroy();
expect(inspectNativeElement(componentFixture.debugElement.nativeElement)).toBe(null);
async.done();
});
@ -62,8 +61,8 @@ export function main() {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideTemplate(MyComp, '')
.createAsync(MyComp)
.then((rootTestComponent) => {
expect(global['ng']['probe'](rootTestComponent.debugElement.nativeElement)
.then((componentFixture) => {
expect(global['ng']['probe'](componentFixture.debugElement.nativeElement)
.componentInstance)
.toBeAnInstanceOf(MyComp);

View File

@ -1,5 +1,5 @@
import {
RootTestComponent,
ComponentFixture,
AsyncTestCompleter,
TestComponentBuilder,
beforeEach,
@ -19,9 +19,9 @@ import {Component, View, NgFor, provide} from 'angular2/angular2';
import {NgClass} from 'angular2/src/core/directives/ng_class';
import {APP_VIEW_POOL_CAPACITY} from 'angular2/src/core/linker/view_pool';
function detectChangesAndCheck(rootTC: RootTestComponent, classes: string, elIndex: number = 0) {
rootTC.detectChanges();
expect(rootTC.debugElement.componentViewChildren[elIndex].nativeElement.className)
function detectChangesAndCheck(fixture: ComponentFixture, classes: string, elIndex: number = 0) {
fixture.detectChanges();
expect(fixture.debugElement.componentViewChildren[elIndex].nativeElement.className)
.toEqual(classes);
}
@ -36,12 +36,12 @@ export function main() {
var template = '<div *ng-for="var item of items" [ng-class]="item"></div>';
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.debugElement.componentInstance.items = [['0']];
rootTC.detectChanges();
rootTC.debugElement.componentInstance.items = [['1']];
.then((fixture) => {
fixture.debugElement.componentInstance.items = [['0']];
fixture.detectChanges();
fixture.debugElement.componentInstance.items = [['1']];
detectChangesAndCheck(rootTC, '1', 1);
detectChangesAndCheck(fixture, '1', 1);
async.done();
});
@ -57,8 +57,8 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
detectChangesAndCheck(rootTC, 'foo');
.then((fixture) => {
detectChangesAndCheck(fixture, 'foo');
async.done();
});
}));
@ -70,8 +70,8 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
detectChangesAndCheck(rootTC, 'foo-bar fooBar');
.then((fixture) => {
detectChangesAndCheck(fixture, 'foo-bar fooBar');
async.done();
});
}));
@ -82,11 +82,11 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
detectChangesAndCheck(rootTC, 'foo');
.then((fixture) => {
detectChangesAndCheck(fixture, 'foo');
rootTC.debugElement.componentInstance.condition = false;
detectChangesAndCheck(rootTC, 'bar');
fixture.debugElement.componentInstance.condition = false;
detectChangesAndCheck(fixture, 'bar');
async.done();
});
@ -98,17 +98,17 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
detectChangesAndCheck(rootTC, 'foo');
.then((fixture) => {
detectChangesAndCheck(fixture, 'foo');
StringMapWrapper.set(rootTC.debugElement.componentInstance.objExpr, 'bar', true);
detectChangesAndCheck(rootTC, 'foo bar');
StringMapWrapper.set(fixture.debugElement.componentInstance.objExpr, 'bar', true);
detectChangesAndCheck(fixture, 'foo bar');
StringMapWrapper.set(rootTC.debugElement.componentInstance.objExpr, 'baz', true);
detectChangesAndCheck(rootTC, 'foo bar baz');
StringMapWrapper.set(fixture.debugElement.componentInstance.objExpr, 'baz', true);
detectChangesAndCheck(fixture, 'foo bar baz');
StringMapWrapper.delete(rootTC.debugElement.componentInstance.objExpr, 'bar');
detectChangesAndCheck(rootTC, 'foo baz');
StringMapWrapper.delete(fixture.debugElement.componentInstance.objExpr, 'bar');
detectChangesAndCheck(fixture, 'foo baz');
async.done();
});
@ -120,14 +120,14 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
detectChangesAndCheck(rootTC, 'foo');
.then((fixture) => {
detectChangesAndCheck(fixture, 'foo');
rootTC.debugElement.componentInstance.objExpr = {foo: true, bar: true};
detectChangesAndCheck(rootTC, 'foo bar');
fixture.debugElement.componentInstance.objExpr = {foo: true, bar: true};
detectChangesAndCheck(fixture, 'foo bar');
rootTC.debugElement.componentInstance.objExpr = {baz: true};
detectChangesAndCheck(rootTC, 'baz');
fixture.debugElement.componentInstance.objExpr = {baz: true};
detectChangesAndCheck(fixture, 'baz');
async.done();
});
@ -139,14 +139,14 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
detectChangesAndCheck(rootTC, 'foo');
.then((fixture) => {
detectChangesAndCheck(fixture, 'foo');
rootTC.debugElement.componentInstance.objExpr = null;
detectChangesAndCheck(rootTC, '');
fixture.debugElement.componentInstance.objExpr = null;
detectChangesAndCheck(fixture, '');
rootTC.debugElement.componentInstance.objExpr = {'foo': false, 'bar': true};
detectChangesAndCheck(rootTC, 'bar');
fixture.debugElement.componentInstance.objExpr = {'foo': false, 'bar': true};
detectChangesAndCheck(fixture, 'bar');
async.done();
});
@ -161,8 +161,8 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
detectChangesAndCheck(rootTC, 'foo bar foo-bar fooBar');
.then((fixture) => {
detectChangesAndCheck(fixture, 'foo bar foo-bar fooBar');
async.done();
});
}));
@ -173,18 +173,18 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
var arrExpr: string[] = rootTC.debugElement.componentInstance.arrExpr;
detectChangesAndCheck(rootTC, 'foo');
.then((fixture) => {
var arrExpr: string[] = fixture.debugElement.componentInstance.arrExpr;
detectChangesAndCheck(fixture, 'foo');
arrExpr.push('bar');
detectChangesAndCheck(rootTC, 'foo bar');
detectChangesAndCheck(fixture, 'foo bar');
arrExpr[1] = 'baz';
detectChangesAndCheck(rootTC, 'foo baz');
detectChangesAndCheck(fixture, 'foo baz');
ListWrapper.remove(rootTC.debugElement.componentInstance.arrExpr, 'baz');
detectChangesAndCheck(rootTC, 'foo');
ListWrapper.remove(fixture.debugElement.componentInstance.arrExpr, 'baz');
detectChangesAndCheck(fixture, 'foo');
async.done();
});
@ -196,11 +196,11 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
detectChangesAndCheck(rootTC, 'foo');
.then((fixture) => {
detectChangesAndCheck(fixture, 'foo');
rootTC.debugElement.componentInstance.arrExpr = ['bar'];
detectChangesAndCheck(rootTC, 'bar');
fixture.debugElement.componentInstance.arrExpr = ['bar'];
detectChangesAndCheck(fixture, 'bar');
async.done();
});
@ -212,11 +212,11 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
detectChangesAndCheck(rootTC, 'foo');
.then((fixture) => {
detectChangesAndCheck(fixture, 'foo');
rootTC.debugElement.componentInstance.arrExpr = ['bar'];
detectChangesAndCheck(rootTC, 'foo bar');
fixture.debugElement.componentInstance.arrExpr = ['bar'];
detectChangesAndCheck(fixture, 'foo bar');
async.done();
});
@ -228,10 +228,10 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
.then((fixture) => {
rootTC.debugElement.componentInstance.arrExpr = ['', ' '];
detectChangesAndCheck(rootTC, 'foo');
fixture.debugElement.componentInstance.arrExpr = ['', ' '];
detectChangesAndCheck(fixture, 'foo');
async.done();
});
@ -243,10 +243,10 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
.then((fixture) => {
rootTC.debugElement.componentInstance.arrExpr = [' bar '];
detectChangesAndCheck(rootTC, 'foo bar');
fixture.debugElement.componentInstance.arrExpr = [' bar '];
detectChangesAndCheck(fixture, 'foo bar');
async.done();
});
@ -261,16 +261,16 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
.then((fixture) => {
var setExpr = new Set<string>();
setExpr.add('bar');
rootTC.debugElement.componentInstance.setExpr = setExpr;
detectChangesAndCheck(rootTC, 'bar');
fixture.debugElement.componentInstance.setExpr = setExpr;
detectChangesAndCheck(fixture, 'bar');
setExpr = new Set<string>();
setExpr.add('baz');
rootTC.debugElement.componentInstance.setExpr = setExpr;
detectChangesAndCheck(rootTC, 'baz');
fixture.debugElement.componentInstance.setExpr = setExpr;
detectChangesAndCheck(fixture, 'baz');
async.done();
});
@ -284,8 +284,8 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
detectChangesAndCheck(rootTC, 'foo bar foo-bar fooBar');
.then((fixture) => {
detectChangesAndCheck(fixture, 'foo bar foo-bar fooBar');
async.done();
});
}));
@ -296,15 +296,15 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
detectChangesAndCheck(rootTC, 'foo');
.then((fixture) => {
detectChangesAndCheck(fixture, 'foo');
rootTC.debugElement.componentInstance.strExpr = 'foo bar';
detectChangesAndCheck(rootTC, 'foo bar');
fixture.debugElement.componentInstance.strExpr = 'foo bar';
detectChangesAndCheck(fixture, 'foo bar');
rootTC.debugElement.componentInstance.strExpr = 'baz';
detectChangesAndCheck(rootTC, 'baz');
fixture.debugElement.componentInstance.strExpr = 'baz';
detectChangesAndCheck(fixture, 'baz');
async.done();
});
@ -316,11 +316,11 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
detectChangesAndCheck(rootTC, 'foo');
.then((fixture) => {
detectChangesAndCheck(fixture, 'foo');
rootTC.debugElement.componentInstance.strExpr = null;
detectChangesAndCheck(rootTC, '');
fixture.debugElement.componentInstance.strExpr = null;
detectChangesAndCheck(fixture, '');
async.done();
});
@ -332,11 +332,11 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
detectChangesAndCheck(rootTC, 'foo');
.then((fixture) => {
detectChangesAndCheck(fixture, 'foo');
rootTC.debugElement.componentInstance.strExpr = null;
detectChangesAndCheck(rootTC, 'foo');
fixture.debugElement.componentInstance.strExpr = null;
detectChangesAndCheck(fixture, 'foo');
async.done();
});
@ -348,9 +348,9 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.debugElement.componentInstance.strExpr = '';
detectChangesAndCheck(rootTC, 'foo');
.then((fixture) => {
fixture.debugElement.componentInstance.strExpr = '';
detectChangesAndCheck(fixture, 'foo');
async.done();
});
@ -366,15 +366,15 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
StringMapWrapper.set(rootTC.debugElement.componentInstance.objExpr, 'bar', true);
detectChangesAndCheck(rootTC, 'init foo bar');
.then((fixture) => {
StringMapWrapper.set(fixture.debugElement.componentInstance.objExpr, 'bar', true);
detectChangesAndCheck(fixture, 'init foo bar');
StringMapWrapper.set(rootTC.debugElement.componentInstance.objExpr, 'foo', false);
detectChangesAndCheck(rootTC, 'init bar');
StringMapWrapper.set(fixture.debugElement.componentInstance.objExpr, 'foo', false);
detectChangesAndCheck(fixture, 'init bar');
rootTC.debugElement.componentInstance.objExpr = null;
detectChangesAndCheck(rootTC, 'init foo');
fixture.debugElement.componentInstance.objExpr = null;
detectChangesAndCheck(fixture, 'init foo');
async.done();
});
@ -386,15 +386,15 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
StringMapWrapper.set(rootTC.debugElement.componentInstance.objExpr, 'bar', true);
detectChangesAndCheck(rootTC, `init foo bar`);
.then((fixture) => {
StringMapWrapper.set(fixture.debugElement.componentInstance.objExpr, 'bar', true);
detectChangesAndCheck(fixture, `init foo bar`);
StringMapWrapper.set(rootTC.debugElement.componentInstance.objExpr, 'foo', false);
detectChangesAndCheck(rootTC, `init bar`);
StringMapWrapper.set(fixture.debugElement.componentInstance.objExpr, 'foo', false);
detectChangesAndCheck(fixture, `init bar`);
rootTC.debugElement.componentInstance.objExpr = null;
detectChangesAndCheck(rootTC, `init foo`);
fixture.debugElement.componentInstance.objExpr = null;
detectChangesAndCheck(fixture, `init foo`);
async.done();
});
@ -406,15 +406,15 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
StringMapWrapper.set(rootTC.debugElement.componentInstance.objExpr, 'bar', true);
detectChangesAndCheck(rootTC, `init foo bar`);
.then((fixture) => {
StringMapWrapper.set(fixture.debugElement.componentInstance.objExpr, 'bar', true);
detectChangesAndCheck(fixture, `init foo bar`);
StringMapWrapper.set(rootTC.debugElement.componentInstance.objExpr, 'foo', false);
detectChangesAndCheck(rootTC, `init bar`);
StringMapWrapper.set(fixture.debugElement.componentInstance.objExpr, 'foo', false);
detectChangesAndCheck(fixture, `init bar`);
rootTC.debugElement.componentInstance.objExpr = null;
detectChangesAndCheck(rootTC, `init foo`);
fixture.debugElement.componentInstance.objExpr = null;
detectChangesAndCheck(fixture, `init foo`);
async.done();
});
@ -427,17 +427,17 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
detectChangesAndCheck(rootTC, 'init foo baz');
.then((fixture) => {
detectChangesAndCheck(fixture, 'init foo baz');
StringMapWrapper.set(rootTC.debugElement.componentInstance.objExpr, 'bar', true);
detectChangesAndCheck(rootTC, 'init foo baz bar');
StringMapWrapper.set(fixture.debugElement.componentInstance.objExpr, 'bar', true);
detectChangesAndCheck(fixture, 'init foo baz bar');
StringMapWrapper.set(rootTC.debugElement.componentInstance.objExpr, 'foo', false);
detectChangesAndCheck(rootTC, 'init baz bar');
StringMapWrapper.set(fixture.debugElement.componentInstance.objExpr, 'foo', false);
detectChangesAndCheck(fixture, 'init baz bar');
rootTC.debugElement.componentInstance.condition = false;
detectChangesAndCheck(rootTC, 'init bar');
fixture.debugElement.componentInstance.condition = false;
detectChangesAndCheck(fixture, 'init bar');
async.done();
});
@ -449,17 +449,17 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
detectChangesAndCheck(rootTC, 'init foo');
.then((fixture) => {
detectChangesAndCheck(fixture, 'init foo');
StringMapWrapper.set(rootTC.debugElement.componentInstance.objExpr, 'bar', true);
detectChangesAndCheck(rootTC, 'init foo bar');
StringMapWrapper.set(fixture.debugElement.componentInstance.objExpr, 'bar', true);
detectChangesAndCheck(fixture, 'init foo bar');
rootTC.debugElement.componentInstance.strExpr = 'baz';
detectChangesAndCheck(rootTC, 'init bar baz foo');
fixture.debugElement.componentInstance.strExpr = 'baz';
detectChangesAndCheck(fixture, 'init bar baz foo');
rootTC.debugElement.componentInstance.objExpr = null;
detectChangesAndCheck(rootTC, 'init baz');
fixture.debugElement.componentInstance.objExpr = null;
detectChangesAndCheck(fixture, 'init baz');
async.done();
});

View File

@ -29,9 +29,9 @@ export function main() {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideTemplate(TestComponent, TEMPLATE)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.detectChanges();
expect(rootTC.debugElement.nativeElement).toHaveText('1;2;');
.then((fixture) => {
fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('1;2;');
async.done();
});
}));
@ -40,13 +40,13 @@ export function main() {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideTemplate(TestComponent, TEMPLATE)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.detectChanges();
.then((fixture) => {
fixture.detectChanges();
(<number[]>rootTC.debugElement.componentInstance.items).push(3);
rootTC.detectChanges();
(<number[]>fixture.debugElement.componentInstance.items).push(3);
fixture.detectChanges();
expect(rootTC.debugElement.nativeElement).toHaveText('1;2;3;');
expect(fixture.debugElement.nativeElement).toHaveText('1;2;3;');
async.done();
});
}));
@ -55,13 +55,13 @@ export function main() {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideTemplate(TestComponent, TEMPLATE)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.detectChanges();
.then((fixture) => {
fixture.detectChanges();
ListWrapper.removeAt(rootTC.debugElement.componentInstance.items, 1);
rootTC.detectChanges();
ListWrapper.removeAt(fixture.debugElement.componentInstance.items, 1);
fixture.detectChanges();
expect(rootTC.debugElement.nativeElement).toHaveText('1;');
expect(fixture.debugElement.nativeElement).toHaveText('1;');
async.done();
});
}));
@ -70,14 +70,14 @@ export function main() {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideTemplate(TestComponent, TEMPLATE)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.detectChanges();
.then((fixture) => {
fixture.detectChanges();
ListWrapper.removeAt(rootTC.debugElement.componentInstance.items, 0);
(<number[]>rootTC.debugElement.componentInstance.items).push(1);
rootTC.detectChanges();
ListWrapper.removeAt(fixture.debugElement.componentInstance.items, 0);
(<number[]>fixture.debugElement.componentInstance.items).push(1);
fixture.detectChanges();
expect(rootTC.debugElement.nativeElement).toHaveText('2;1;');
expect(fixture.debugElement.nativeElement).toHaveText('2;1;');
async.done();
});
}));
@ -86,14 +86,14 @@ export function main() {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideTemplate(TestComponent, TEMPLATE)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.debugElement.componentInstance.items = [0, 1, 2, 3, 4, 5];
rootTC.detectChanges();
.then((fixture) => {
fixture.debugElement.componentInstance.items = [0, 1, 2, 3, 4, 5];
fixture.detectChanges();
rootTC.debugElement.componentInstance.items = [6, 2, 7, 0, 4, 8];
rootTC.detectChanges();
fixture.debugElement.componentInstance.items = [6, 2, 7, 0, 4, 8];
fixture.detectChanges();
expect(rootTC.debugElement.nativeElement).toHaveText('6;2;7;0;4;8;');
expect(fixture.debugElement.nativeElement).toHaveText('6;2;7;0;4;8;');
async.done();
});
}));
@ -104,25 +104,26 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
.then((fixture) => {
// INIT
rootTC.debugElement.componentInstance.items = [{'name': 'misko'}, {'name': 'shyam'}];
rootTC.detectChanges();
expect(rootTC.debugElement.nativeElement).toHaveText('misko;shyam;');
fixture.debugElement.componentInstance.items =
[{'name': 'misko'}, {'name': 'shyam'}];
fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('misko;shyam;');
// GROW
(<any[]>rootTC.debugElement.componentInstance.items).push({'name': 'adam'});
rootTC.detectChanges();
(<any[]>fixture.debugElement.componentInstance.items).push({'name': 'adam'});
fixture.detectChanges();
expect(rootTC.debugElement.nativeElement).toHaveText('misko;shyam;adam;');
expect(fixture.debugElement.nativeElement).toHaveText('misko;shyam;adam;');
// SHRINK
ListWrapper.removeAt(rootTC.debugElement.componentInstance.items, 2);
ListWrapper.removeAt(rootTC.debugElement.componentInstance.items, 0);
rootTC.detectChanges();
ListWrapper.removeAt(fixture.debugElement.componentInstance.items, 2);
ListWrapper.removeAt(fixture.debugElement.componentInstance.items, 0);
fixture.detectChanges();
expect(rootTC.debugElement.nativeElement).toHaveText('shyam;');
expect(fixture.debugElement.nativeElement).toHaveText('shyam;');
async.done();
});
}));
@ -132,9 +133,9 @@ export function main() {
var template = '<ul><li template="ng-for #item of null">{{item}};</li></ul>';
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.detectChanges();
expect(rootTC.debugElement.nativeElement).toHaveText('');
.then((fixture) => {
fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('');
async.done();
});
}));
@ -143,17 +144,17 @@ export function main() {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideTemplate(TestComponent, TEMPLATE)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.detectChanges();
expect(rootTC.debugElement.nativeElement).toHaveText('1;2;');
.then((fixture) => {
fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('1;2;');
rootTC.debugElement.componentInstance.items = null;
rootTC.detectChanges();
expect(rootTC.debugElement.nativeElement).toHaveText('');
fixture.debugElement.componentInstance.items = null;
fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('');
rootTC.debugElement.componentInstance.items = [1, 2, 3];
rootTC.detectChanges();
expect(rootTC.debugElement.nativeElement).toHaveText('1;2;3;');
fixture.debugElement.componentInstance.items = [1, 2, 3];
fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('1;2;3;');
async.done();
});
}));
@ -162,12 +163,12 @@ export function main() {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideTemplate(TestComponent, TEMPLATE)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.detectChanges();
expect(rootTC.debugElement.nativeElement).toHaveText('1;2;');
.then((fixture) => {
fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('1;2;');
rootTC.debugElement.componentInstance.items = 'whaaa';
expect(() => rootTC.detectChanges()).toThrowError();
fixture.debugElement.componentInstance.items = 'whaaa';
expect(() => fixture.detectChanges()).toThrowError();
async.done();
});
}));
@ -176,11 +177,11 @@ export function main() {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideTemplate(TestComponent, TEMPLATE)
.createAsync(TestComponent)
.then((rootTC) => {
.then((fixture) => {
var a = new Foo();
rootTC.debugElement.componentInstance.items = [a, a];
rootTC.detectChanges();
expect(rootTC.debugElement.nativeElement).toHaveText('foo;foo;');
fixture.debugElement.componentInstance.items = [a, a];
fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('foo;foo;');
async.done();
});
}));
@ -197,16 +198,16 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.debugElement.componentInstance.items = [['a', 'b'], ['c']];
rootTC.detectChanges();
rootTC.detectChanges();
rootTC.detectChanges();
expect(rootTC.debugElement.nativeElement).toHaveText('a-2;b-2;|c-1;|');
.then((fixture) => {
fixture.debugElement.componentInstance.items = [['a', 'b'], ['c']];
fixture.detectChanges();
fixture.detectChanges();
fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('a-2;b-2;|c-1;|');
rootTC.debugElement.componentInstance.items = [['e'], ['f', 'g']];
rootTC.detectChanges();
expect(rootTC.debugElement.nativeElement).toHaveText('e-1;|f-2;g-2;|');
fixture.debugElement.componentInstance.items = [['e'], ['f', 'g']];
fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('e-1;|f-2;g-2;|');
async.done();
});
@ -221,14 +222,14 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.debugElement.componentInstance.items = [['a', 'b'], ['c']];
rootTC.detectChanges();
expect(rootTC.debugElement.nativeElement).toHaveText('a-2;b-2;c-1;');
.then((fixture) => {
fixture.debugElement.componentInstance.items = [['a', 'b'], ['c']];
fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('a-2;b-2;c-1;');
rootTC.debugElement.componentInstance.items = [['e'], ['f', 'g']];
rootTC.detectChanges();
expect(rootTC.debugElement.nativeElement).toHaveText('e-1;f-2;g-2;');
fixture.debugElement.componentInstance.items = [['e'], ['f', 'g']];
fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('e-1;f-2;g-2;');
async.done();
});
}));
@ -240,14 +241,14 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.debugElement.componentInstance.items = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
rootTC.detectChanges();
expect(rootTC.debugElement.nativeElement).toHaveText('0123456789');
.then((fixture) => {
fixture.debugElement.componentInstance.items = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('0123456789');
rootTC.debugElement.componentInstance.items = [1, 2, 6, 7, 4, 3, 5, 8, 9, 0];
rootTC.detectChanges();
expect(rootTC.debugElement.nativeElement).toHaveText('0123456789');
fixture.debugElement.componentInstance.items = [1, 2, 6, 7, 4, 3, 5, 8, 9, 0];
fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('0123456789');
async.done();
});
}));
@ -259,14 +260,14 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.debugElement.componentInstance.items = [0, 1, 2];
rootTC.detectChanges();
expect(rootTC.debugElement.nativeElement).toHaveText('falsefalsetrue');
.then((fixture) => {
fixture.debugElement.componentInstance.items = [0, 1, 2];
fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('falsefalsetrue');
rootTC.debugElement.componentInstance.items = [2, 1];
rootTC.detectChanges();
expect(rootTC.debugElement.nativeElement).toHaveText('falsetrue');
fixture.debugElement.componentInstance.items = [2, 1];
fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('falsetrue');
async.done();
});
}));
@ -278,14 +279,14 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.debugElement.componentInstance.items = [0, 1, 2];
rootTC.detectChanges();
expect(rootTC.debugElement.nativeElement).toHaveText('truefalsetrue');
.then((fixture) => {
fixture.debugElement.componentInstance.items = [0, 1, 2];
fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('truefalsetrue');
rootTC.debugElement.componentInstance.items = [2, 1];
rootTC.detectChanges();
expect(rootTC.debugElement.nativeElement).toHaveText('truefalse');
fixture.debugElement.componentInstance.items = [2, 1];
fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('truefalse');
async.done();
});
}));
@ -297,14 +298,14 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.debugElement.componentInstance.items = [0, 1, 2, 3];
rootTC.detectChanges();
expect(rootTC.debugElement.nativeElement).toHaveText('falsetruefalsetrue');
.then((fixture) => {
fixture.debugElement.componentInstance.items = [0, 1, 2, 3];
fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('falsetruefalsetrue');
rootTC.debugElement.componentInstance.items = [2, 1];
rootTC.detectChanges();
expect(rootTC.debugElement.nativeElement).toHaveText('falsetrue');
fixture.debugElement.componentInstance.items = [2, 1];
fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('falsetrue');
async.done();
});
}));
@ -318,10 +319,10 @@ export function main() {
ComponentUsingTestComponent,
'<test-cmp><li template="#item #i=index">{{i}}: {{item}};</li></test-cmp>')
.createAsync(ComponentUsingTestComponent)
.then((rootTC) => {
var testComponent = rootTC.debugElement.componentViewChildren[0];
.then((fixture) => {
var testComponent = fixture.debugElement.componentViewChildren[0];
testComponent.componentInstance.items = ['a', 'b', 'c'];
rootTC.detectChanges();
fixture.detectChanges();
expect(testComponent.nativeElement).toHaveText('0: a;1: b;2: c;');
async.done();

View File

@ -26,11 +26,11 @@ export function main() {
tcb.overrideTemplate(TestComponent, html)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.detectChanges();
expect(DOM.querySelectorAll(rootTC.debugElement.nativeElement, 'copy-me').length)
.then((fixture) => {
fixture.detectChanges();
expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
.toEqual(1);
expect(rootTC.debugElement.nativeElement).toHaveText('hello');
expect(fixture.debugElement.nativeElement).toHaveText('hello');
async.done();
});
}));
@ -42,11 +42,11 @@ export function main() {
tcb.overrideTemplate(TestComponent, html)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.detectChanges();
expect(DOM.querySelectorAll(rootTC.debugElement.nativeElement, 'copy-me').length)
.then((fixture) => {
fixture.detectChanges();
expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
.toEqual(1);
expect(rootTC.debugElement.nativeElement).toHaveText('hello2');
expect(fixture.debugElement.nativeElement).toHaveText('hello2');
async.done();
});
}));
@ -57,24 +57,24 @@ export function main() {
tcb.overrideTemplate(TestComponent, html)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.debugElement.componentInstance.booleanCondition = false;
rootTC.detectChanges();
expect(DOM.querySelectorAll(rootTC.debugElement.nativeElement, 'copy-me').length)
.then((fixture) => {
fixture.debugElement.componentInstance.booleanCondition = false;
fixture.detectChanges();
expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
.toEqual(0);
expect(rootTC.debugElement.nativeElement).toHaveText('');
expect(fixture.debugElement.nativeElement).toHaveText('');
rootTC.debugElement.componentInstance.booleanCondition = true;
rootTC.detectChanges();
expect(DOM.querySelectorAll(rootTC.debugElement.nativeElement, 'copy-me').length)
fixture.debugElement.componentInstance.booleanCondition = true;
fixture.detectChanges();
expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
.toEqual(1);
expect(rootTC.debugElement.nativeElement).toHaveText('hello');
expect(fixture.debugElement.nativeElement).toHaveText('hello');
rootTC.debugElement.componentInstance.booleanCondition = false;
rootTC.detectChanges();
expect(DOM.querySelectorAll(rootTC.debugElement.nativeElement, 'copy-me').length)
fixture.debugElement.componentInstance.booleanCondition = false;
fixture.detectChanges();
expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
.toEqual(0);
expect(rootTC.debugElement.nativeElement).toHaveText('');
expect(fixture.debugElement.nativeElement).toHaveText('');
async.done();
});
@ -87,36 +87,36 @@ export function main() {
tcb.overrideTemplate(TestComponent, html)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.debugElement.componentInstance.booleanCondition = false;
rootTC.detectChanges();
expect(DOM.querySelectorAll(rootTC.debugElement.nativeElement, 'copy-me').length)
.then((fixture) => {
fixture.debugElement.componentInstance.booleanCondition = false;
fixture.detectChanges();
expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
.toEqual(0);
expect(rootTC.debugElement.nativeElement).toHaveText('');
expect(fixture.debugElement.nativeElement).toHaveText('');
rootTC.debugElement.componentInstance.booleanCondition = true;
rootTC.detectChanges();
expect(DOM.querySelectorAll(rootTC.debugElement.nativeElement, 'copy-me').length)
fixture.debugElement.componentInstance.booleanCondition = true;
fixture.detectChanges();
expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
.toEqual(1);
expect(rootTC.debugElement.nativeElement).toHaveText('hello');
expect(fixture.debugElement.nativeElement).toHaveText('hello');
rootTC.debugElement.componentInstance.nestedBooleanCondition = false;
rootTC.detectChanges();
expect(DOM.querySelectorAll(rootTC.debugElement.nativeElement, 'copy-me').length)
fixture.debugElement.componentInstance.nestedBooleanCondition = false;
fixture.detectChanges();
expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
.toEqual(0);
expect(rootTC.debugElement.nativeElement).toHaveText('');
expect(fixture.debugElement.nativeElement).toHaveText('');
rootTC.debugElement.componentInstance.nestedBooleanCondition = true;
rootTC.detectChanges();
expect(DOM.querySelectorAll(rootTC.debugElement.nativeElement, 'copy-me').length)
fixture.debugElement.componentInstance.nestedBooleanCondition = true;
fixture.detectChanges();
expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
.toEqual(1);
expect(rootTC.debugElement.nativeElement).toHaveText('hello');
expect(fixture.debugElement.nativeElement).toHaveText('hello');
rootTC.debugElement.componentInstance.booleanCondition = false;
rootTC.detectChanges();
expect(DOM.querySelectorAll(rootTC.debugElement.nativeElement, 'copy-me').length)
fixture.debugElement.componentInstance.booleanCondition = false;
fixture.detectChanges();
expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
.toEqual(0);
expect(rootTC.debugElement.nativeElement).toHaveText('');
expect(fixture.debugElement.nativeElement).toHaveText('');
async.done();
});
@ -133,25 +133,25 @@ export function main() {
tcb.overrideTemplate(TestComponent, html)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.detectChanges();
expect(DOM.querySelectorAll(rootTC.debugElement.nativeElement, 'copy-me').length)
.then((fixture) => {
fixture.detectChanges();
expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
.toEqual(3);
expect(DOM.getText(rootTC.debugElement.nativeElement))
expect(DOM.getText(fixture.debugElement.nativeElement))
.toEqual('helloNumberhelloStringhelloFunction');
rootTC.debugElement.componentInstance.numberCondition = 0;
rootTC.detectChanges();
expect(DOM.querySelectorAll(rootTC.debugElement.nativeElement, 'copy-me').length)
fixture.debugElement.componentInstance.numberCondition = 0;
fixture.detectChanges();
expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
.toEqual(1);
expect(rootTC.debugElement.nativeElement).toHaveText('helloString');
expect(fixture.debugElement.nativeElement).toHaveText('helloString');
rootTC.debugElement.componentInstance.numberCondition = 1;
rootTC.debugElement.componentInstance.stringCondition = "bar";
rootTC.detectChanges();
expect(DOM.querySelectorAll(rootTC.debugElement.nativeElement, 'copy-me').length)
fixture.debugElement.componentInstance.numberCondition = 1;
fixture.debugElement.componentInstance.stringCondition = "bar";
fixture.detectChanges();
expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
.toEqual(1);
expect(rootTC.debugElement.nativeElement).toHaveText('helloNumber');
expect(fixture.debugElement.nativeElement).toHaveText('helloNumber');
async.done();
});
}));
@ -164,17 +164,17 @@ export function main() {
tcb.overrideTemplate(TestComponent, html)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.detectChanges();
expect(DOM.querySelectorAll(rootTC.debugElement.nativeElement, 'copy-me').length)
.then((fixture) => {
fixture.detectChanges();
expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
.toEqual(1);
expect(rootTC.debugElement.nativeElement).toHaveText('hello');
expect(fixture.debugElement.nativeElement).toHaveText('hello');
rootTC.debugElement.componentInstance.numberCondition = 2;
rootTC.detectChanges();
expect(DOM.querySelectorAll(rootTC.debugElement.nativeElement, 'copy-me').length)
fixture.debugElement.componentInstance.numberCondition = 2;
fixture.detectChanges();
expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
.toEqual(1);
expect(rootTC.debugElement.nativeElement).toHaveText('hello');
expect(fixture.debugElement.nativeElement).toHaveText('hello');
async.done();
});
@ -186,15 +186,16 @@ export function main() {
tcb.overrideTemplate(TestComponent, html)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.detectChanges();
DOM.addClass(DOM.querySelector(rootTC.debugElement.nativeElement, 'copy-me'),
.then((fixture) => {
fixture.detectChanges();
DOM.addClass(DOM.querySelector(fixture.debugElement.nativeElement, 'copy-me'),
"foo");
rootTC.debugElement.componentInstance.numberCondition = 2;
rootTC.detectChanges();
expect(DOM.hasClass(
DOM.querySelector(rootTC.debugElement.nativeElement, 'copy-me'), "foo"))
fixture.debugElement.componentInstance.numberCondition = 2;
fixture.detectChanges();
expect(
DOM.hasClass(DOM.querySelector(fixture.debugElement.nativeElement, 'copy-me'),
"foo"))
.toBe(true);
async.done();
@ -209,11 +210,11 @@ export function main() {
tcb.overrideTemplate(TestComponent, html)
.createAsync(TestComponent)
.then((rootTC) => {
expect(() => rootTC.detectChanges()).toThrowError();
expect(DOM.querySelectorAll(rootTC.debugElement.nativeElement, 'copy-me').length)
.then((fixture) => {
expect(() => fixture.detectChanges()).toThrowError();
expect(DOM.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me').length)
.toEqual(0);
expect(rootTC.debugElement.nativeElement).toHaveText('');
expect(fixture.debugElement.nativeElement).toHaveText('');
async.done();
});
}));

View File

@ -30,9 +30,9 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.detectChanges();
expect(DOM.getStyle(rootTC.debugElement.componentViewChildren[0].nativeElement,
.then((fixture) => {
fixture.detectChanges();
expect(DOM.getStyle(fixture.debugElement.componentViewChildren[0].nativeElement,
'max-width'))
.toEqual('40px');
@ -46,19 +46,19 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
.then((fixture) => {
var expr: Map<string, any>;
rootTC.debugElement.componentInstance.expr = {'max-width': '40px'};
rootTC.detectChanges();
expect(DOM.getStyle(rootTC.debugElement.componentViewChildren[0].nativeElement,
fixture.debugElement.componentInstance.expr = {'max-width': '40px'};
fixture.detectChanges();
expect(DOM.getStyle(fixture.debugElement.componentViewChildren[0].nativeElement,
'max-width'))
.toEqual('40px');
expr = rootTC.debugElement.componentInstance.expr;
expr = fixture.debugElement.componentInstance.expr;
expr['max-width'] = '30%';
rootTC.detectChanges();
expect(DOM.getStyle(rootTC.debugElement.componentViewChildren[0].nativeElement,
fixture.detectChanges();
expect(DOM.getStyle(fixture.debugElement.componentViewChildren[0].nativeElement,
'max-width'))
.toEqual('30%');
@ -72,16 +72,16 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.debugElement.componentInstance.expr = {'max-width': '40px'};
rootTC.detectChanges();
expect(DOM.getStyle(rootTC.debugElement.componentViewChildren[0].nativeElement,
.then((fixture) => {
fixture.debugElement.componentInstance.expr = {'max-width': '40px'};
fixture.detectChanges();
expect(DOM.getStyle(fixture.debugElement.componentViewChildren[0].nativeElement,
'max-width'))
.toEqual('40px');
StringMapWrapper.delete(rootTC.debugElement.componentInstance.expr, 'max-width');
rootTC.detectChanges();
expect(DOM.getStyle(rootTC.debugElement.componentViewChildren[0].nativeElement,
StringMapWrapper.delete(fixture.debugElement.componentInstance.expr, 'max-width');
fixture.detectChanges();
expect(DOM.getStyle(fixture.debugElement.componentViewChildren[0].nativeElement,
'max-width'))
.toEqual('');
@ -95,22 +95,22 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.debugElement.componentInstance.expr = {'max-width': '40px'};
rootTC.detectChanges();
expect(DOM.getStyle(rootTC.debugElement.componentViewChildren[0].nativeElement,
.then((fixture) => {
fixture.debugElement.componentInstance.expr = {'max-width': '40px'};
fixture.detectChanges();
expect(DOM.getStyle(fixture.debugElement.componentViewChildren[0].nativeElement,
'max-width'))
.toEqual('40px');
expect(DOM.getStyle(rootTC.debugElement.componentViewChildren[0].nativeElement,
expect(DOM.getStyle(fixture.debugElement.componentViewChildren[0].nativeElement,
'font-size'))
.toEqual('12px');
StringMapWrapper.delete(rootTC.debugElement.componentInstance.expr, 'max-width');
rootTC.detectChanges();
expect(DOM.getStyle(rootTC.debugElement.componentViewChildren[0].nativeElement,
StringMapWrapper.delete(fixture.debugElement.componentInstance.expr, 'max-width');
fixture.detectChanges();
expect(DOM.getStyle(fixture.debugElement.componentViewChildren[0].nativeElement,
'max-width'))
.toEqual('');
expect(DOM.getStyle(rootTC.debugElement.componentViewChildren[0].nativeElement,
expect(DOM.getStyle(fixture.debugElement.componentViewChildren[0].nativeElement,
'font-size'))
.toEqual('12px');
@ -124,23 +124,23 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.debugElement.componentInstance.expr = {'max-width': '40px'};
rootTC.detectChanges();
expect(DOM.getStyle(rootTC.debugElement.componentViewChildren[0].nativeElement,
.then((fixture) => {
fixture.debugElement.componentInstance.expr = {'max-width': '40px'};
fixture.detectChanges();
expect(DOM.getStyle(fixture.debugElement.componentViewChildren[0].nativeElement,
'max-width'))
.toEqual('40px');
expect(DOM.getStyle(rootTC.debugElement.componentViewChildren[0].nativeElement,
expect(DOM.getStyle(fixture.debugElement.componentViewChildren[0].nativeElement,
'font-size'))
.toEqual('12px');
StringMapWrapper.delete(rootTC.debugElement.componentInstance.expr, 'max-width');
expect(DOM.getStyle(rootTC.debugElement.componentViewChildren[0].nativeElement,
StringMapWrapper.delete(fixture.debugElement.componentInstance.expr, 'max-width');
expect(DOM.getStyle(fixture.debugElement.componentViewChildren[0].nativeElement,
'font-size'))
.toEqual('12px');
rootTC.detectChanges();
expect(DOM.getStyle(rootTC.debugElement.componentViewChildren[0].nativeElement,
fixture.detectChanges();
expect(DOM.getStyle(fixture.debugElement.componentViewChildren[0].nativeElement,
'max-width'))
.toEqual('');

View File

@ -29,17 +29,17 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.detectChanges();
expect(rootTC.debugElement.nativeElement).toHaveText('');
.then((fixture) => {
fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('');
rootTC.debugElement.componentInstance.switchValue = 'a';
rootTC.detectChanges();
expect(rootTC.debugElement.nativeElement).toHaveText('when a');
fixture.debugElement.componentInstance.switchValue = 'a';
fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('when a');
rootTC.debugElement.componentInstance.switchValue = 'b';
rootTC.detectChanges();
expect(rootTC.debugElement.nativeElement).toHaveText('when b');
fixture.debugElement.componentInstance.switchValue = 'b';
fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('when b');
async.done();
});
@ -55,17 +55,17 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.detectChanges();
expect(rootTC.debugElement.nativeElement).toHaveText('when default');
.then((fixture) => {
fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('when default');
rootTC.debugElement.componentInstance.switchValue = 'a';
rootTC.detectChanges();
expect(rootTC.debugElement.nativeElement).toHaveText('when a');
fixture.debugElement.componentInstance.switchValue = 'a';
fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('when a');
rootTC.debugElement.componentInstance.switchValue = 'b';
rootTC.detectChanges();
expect(rootTC.debugElement.nativeElement).toHaveText('when default');
fixture.debugElement.componentInstance.switchValue = 'b';
fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('when default');
async.done();
});
@ -85,18 +85,18 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.detectChanges();
expect(rootTC.debugElement.nativeElement)
.then((fixture) => {
fixture.detectChanges();
expect(fixture.debugElement.nativeElement)
.toHaveText('when default1;when default2;');
rootTC.debugElement.componentInstance.switchValue = 'a';
rootTC.detectChanges();
expect(rootTC.debugElement.nativeElement).toHaveText('when a1;when a2;');
fixture.debugElement.componentInstance.switchValue = 'a';
fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('when a1;when a2;');
rootTC.debugElement.componentInstance.switchValue = 'b';
rootTC.detectChanges();
expect(rootTC.debugElement.nativeElement).toHaveText('when b1;when b2;');
fixture.debugElement.componentInstance.switchValue = 'b';
fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('when b1;when b2;');
async.done();
});
@ -115,28 +115,28 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.debugElement.componentInstance.when1 = 'a';
rootTC.debugElement.componentInstance.when2 = 'b';
rootTC.debugElement.componentInstance.switchValue = 'a';
rootTC.detectChanges();
expect(rootTC.debugElement.nativeElement).toHaveText('when 1;');
.then((fixture) => {
fixture.debugElement.componentInstance.when1 = 'a';
fixture.debugElement.componentInstance.when2 = 'b';
fixture.debugElement.componentInstance.switchValue = 'a';
fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('when 1;');
rootTC.debugElement.componentInstance.switchValue = 'b';
rootTC.detectChanges();
expect(rootTC.debugElement.nativeElement).toHaveText('when 2;');
fixture.debugElement.componentInstance.switchValue = 'b';
fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('when 2;');
rootTC.debugElement.componentInstance.switchValue = 'c';
rootTC.detectChanges();
expect(rootTC.debugElement.nativeElement).toHaveText('when default;');
fixture.debugElement.componentInstance.switchValue = 'c';
fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('when default;');
rootTC.debugElement.componentInstance.when1 = 'c';
rootTC.detectChanges();
expect(rootTC.debugElement.nativeElement).toHaveText('when 1;');
fixture.debugElement.componentInstance.when1 = 'c';
fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('when 1;');
rootTC.debugElement.componentInstance.when1 = 'd';
rootTC.detectChanges();
expect(rootTC.debugElement.nativeElement).toHaveText('when default;');
fixture.debugElement.componentInstance.when1 = 'd';
fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('when default;');
async.done();
});

View File

@ -22,9 +22,9 @@ export function main() {
var template = '<div>{{text}}<span ng-non-bindable>{{text}}</span></div>';
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.detectChanges();
expect(rootTC.debugElement.nativeElement).toHaveText('foo{{text}}');
.then((fixture) => {
fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('foo{{text}}');
async.done();
});
}));
@ -34,12 +34,12 @@ export function main() {
var template = '<div ng-non-bindable><span id=child test-dec>{{text}}</span></div>';
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.detectChanges();
.then((fixture) => {
fixture.detectChanges();
// We must use DOM.querySelector instead of rootTC.query here
// We must use DOM.querySelector instead of fixture.query here
// since the elements inside are not compiled.
var span = DOM.querySelector(rootTC.debugElement.nativeElement, '#child');
var span = DOM.querySelector(fixture.debugElement.nativeElement, '#child');
expect(DOM.hasClass(span, 'compiled')).toBeFalsy();
async.done();
});
@ -50,9 +50,9 @@ export function main() {
var template = '<div><span id=child ng-non-bindable test-dec>{{text}}</span></div>';
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.detectChanges();
var span = DOM.querySelector(rootTC.debugElement.nativeElement, '#child');
.then((fixture) => {
fixture.detectChanges();
var span = DOM.querySelector(fixture.debugElement.nativeElement, '#child');
expect(DOM.hasClass(span, 'compiled')).toBeTruthy();
async.done();
});

View File

@ -1,6 +1,6 @@
import {Component, Directive, View, Output, EventEmitter} from 'angular2/angular2';
import {
RootTestComponent,
ComponentFixture,
afterEach,
AsyncTestCompleter,
TestComponentBuilder,
@ -51,12 +51,12 @@ export function main() {
<input type="text" ng-control="login">
</div>`;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((rootTC) => {
rootTC.debugElement.componentInstance.form =
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((fixture) => {
fixture.debugElement.componentInstance.form =
new ControlGroup({"login": new Control("loginValue")});
rootTC.detectChanges();
fixture.detectChanges();
var input = rootTC.debugElement.query(By.css("input"));
var input = fixture.debugElement.query(By.css("input"));
expect(input.nativeElement.value).toEqual("loginValue");
async.done();
});
@ -70,10 +70,10 @@ export function main() {
<input type="text" ng-control="login">
</div>`;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((rootTC) => {
rootTC.debugElement.componentInstance.form = form;
rootTC.detectChanges();
var input = rootTC.debugElement.query(By.css("input"));
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((fixture) => {
fixture.debugElement.componentInstance.form = form;
fixture.detectChanges();
var input = fixture.debugElement.query(By.css("input"));
input.nativeElement.value = "updatedValue";
dispatchEvent(input.nativeElement, "change");
@ -90,22 +90,22 @@ export function main() {
<span>{{name}}</span>
</div>`;
var rootTC: RootTestComponent;
var fixture: ComponentFixture;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then(
(root) => { rootTC = root; });
(root) => { fixture = root; });
tick();
rootTC.debugElement.componentInstance.form = new ControlGroup({});
rootTC.debugElement.componentInstance.name = 'old';
fixture.debugElement.componentInstance.form = new ControlGroup({});
fixture.debugElement.componentInstance.name = 'old';
tick();
var form = rootTC.debugElement.query(By.css("form"));
var form = fixture.debugElement.query(By.css("form"));
dispatchEvent(form.nativeElement, "submit");
tick();
expect(rootTC.debugElement.componentInstance.name).toEqual('updated');
expect(fixture.debugElement.componentInstance.name).toEqual('updated');
})));
it("should work with single controls",
@ -114,11 +114,11 @@ export function main() {
var t = `<div><input type="text" [ng-form-control]="form"></div>`;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((rootTC) => {
rootTC.debugElement.componentInstance.form = control;
rootTC.detectChanges();
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((fixture) => {
fixture.debugElement.componentInstance.form = control;
fixture.detectChanges();
var input = rootTC.debugElement.query(By.css("input"));
var input = fixture.debugElement.query(By.css("input"));
expect(input.nativeElement.value).toEqual("loginValue");
input.nativeElement.value = "updatedValue";
@ -135,16 +135,16 @@ export function main() {
<input type="text" ng-control="login">
</div>`;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((rootTC) => {
rootTC.debugElement.componentInstance.form =
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((fixture) => {
fixture.debugElement.componentInstance.form =
new ControlGroup({"login": new Control("oldValue")});
rootTC.detectChanges();
fixture.detectChanges();
rootTC.debugElement.componentInstance.form =
fixture.debugElement.componentInstance.form =
new ControlGroup({"login": new Control("newValue")});
rootTC.detectChanges();
fixture.detectChanges();
var input = rootTC.debugElement.query(By.css("input"));
var input = fixture.debugElement.query(By.css("input"));
expect(input.nativeElement.value).toEqual("newValue");
async.done();
});
@ -159,15 +159,15 @@ export function main() {
<input type="text" ng-control="login">
</div>`;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((rootTC) => {
rootTC.debugElement.componentInstance.form = form;
rootTC.detectChanges();
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((fixture) => {
fixture.debugElement.componentInstance.form = form;
fixture.detectChanges();
login.updateValue("newValue");
rootTC.detectChanges();
fixture.detectChanges();
var input = rootTC.debugElement.query(By.css("input"));
var input = fixture.debugElement.query(By.css("input"));
expect(input.nativeElement.value).toEqual("newValue");
async.done();
});
@ -182,11 +182,11 @@ export function main() {
<input type="text" ng-control="login">
</div>`;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((rootTC) => {
rootTC.debugElement.componentInstance.form = form;
rootTC.detectChanges();
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((fixture) => {
fixture.debugElement.componentInstance.form = form;
fixture.detectChanges();
var loginEl = rootTC.debugElement.query(By.css("input"));
var loginEl = fixture.debugElement.query(By.css("input"));
expect(login.touched).toBe(false);
dispatchEvent(loginEl.nativeElement, "blur");
@ -204,18 +204,18 @@ export function main() {
<input type="text" ng-control="text">
</div>`;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((rootTC) => {
rootTC.debugElement.componentInstance.form =
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((fixture) => {
fixture.debugElement.componentInstance.form =
new ControlGroup({"text": new Control("old")});
rootTC.detectChanges();
fixture.detectChanges();
var input = rootTC.debugElement.query(By.css("input"));
var input = fixture.debugElement.query(By.css("input"));
expect(input.nativeElement.value).toEqual("old");
input.nativeElement.value = "new";
dispatchEvent(input.nativeElement, "input");
expect(rootTC.debugElement.componentInstance.form.value).toEqual({"text": "new"});
expect(fixture.debugElement.componentInstance.form.value).toEqual({"text": "new"});
async.done();
});
}));
@ -226,17 +226,17 @@ export function main() {
<input ng-control="text">
</div>`;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((rootTC) => {
rootTC.debugElement.componentInstance.form =
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((fixture) => {
fixture.debugElement.componentInstance.form =
new ControlGroup({"text": new Control("old")});
rootTC.detectChanges();
var input = rootTC.debugElement.query(By.css("input"));
fixture.detectChanges();
var input = fixture.debugElement.query(By.css("input"));
expect(input.nativeElement.value).toEqual("old");
input.nativeElement.value = "new";
dispatchEvent(input.nativeElement, "input");
expect(rootTC.debugElement.componentInstance.form.value).toEqual({"text": "new"});
expect(fixture.debugElement.componentInstance.form.value).toEqual({"text": "new"});
async.done();
});
}));
@ -247,18 +247,18 @@ export function main() {
<textarea ng-control="text"></textarea>
</div>`;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((rootTC) => {
rootTC.debugElement.componentInstance.form =
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((fixture) => {
fixture.debugElement.componentInstance.form =
new ControlGroup({"text": new Control('old')});
rootTC.detectChanges();
fixture.detectChanges();
var textarea = rootTC.debugElement.query(By.css("textarea"));
var textarea = fixture.debugElement.query(By.css("textarea"));
expect(textarea.nativeElement.value).toEqual("old");
textarea.nativeElement.value = "new";
dispatchEvent(textarea.nativeElement, "input");
expect(rootTC.debugElement.componentInstance.form.value).toEqual({"text": 'new'});
expect(fixture.debugElement.componentInstance.form.value).toEqual({"text": 'new'});
async.done();
});
}));
@ -269,18 +269,18 @@ export function main() {
<input type="checkbox" ng-control="checkbox">
</div>`;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((rootTC) => {
rootTC.debugElement.componentInstance.form =
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((fixture) => {
fixture.debugElement.componentInstance.form =
new ControlGroup({"checkbox": new Control(true)});
rootTC.detectChanges();
fixture.detectChanges();
var input = rootTC.debugElement.query(By.css("input"));
var input = fixture.debugElement.query(By.css("input"));
expect(input.nativeElement.checked).toBe(true);
input.nativeElement.checked = false;
dispatchEvent(input.nativeElement, "change");
expect(rootTC.debugElement.componentInstance.form.value).toEqual({"checkbox": false});
expect(fixture.debugElement.componentInstance.form.value).toEqual({"checkbox": false});
async.done();
});
}));
@ -291,18 +291,18 @@ export function main() {
<input type="number" ng-control="num">
</div>`;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((rootTC) => {
rootTC.debugElement.componentInstance.form =
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((fixture) => {
fixture.debugElement.componentInstance.form =
new ControlGroup({"num": new Control(10)});
rootTC.detectChanges();
fixture.detectChanges();
var input = rootTC.debugElement.query(By.css("input"));
var input = fixture.debugElement.query(By.css("input"));
expect(input.nativeElement.value).toEqual("10");
input.nativeElement.value = "20";
dispatchEvent(input.nativeElement, "change");
expect(rootTC.debugElement.componentInstance.form.value).toEqual({"num": 20});
expect(fixture.debugElement.componentInstance.form.value).toEqual({"num": 20});
async.done();
});
}));
@ -316,20 +316,20 @@ export function main() {
</select>
</div>`;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((rootTC) => {
rootTC.debugElement.componentInstance.form =
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((fixture) => {
fixture.debugElement.componentInstance.form =
new ControlGroup({"city": new Control("SF")});
rootTC.detectChanges();
fixture.detectChanges();
var select = rootTC.debugElement.query(By.css("select"));
var sfOption = rootTC.debugElement.query(By.css("option"));
var select = fixture.debugElement.query(By.css("select"));
var sfOption = fixture.debugElement.query(By.css("option"));
expect(select.nativeElement.value).toEqual('SF');
expect(sfOption.nativeElement.selected).toBe(true);
select.nativeElement.value = 'NYC';
dispatchEvent(select.nativeElement, "change");
expect(rootTC.debugElement.componentInstance.form.value).toEqual({"city": 'NYC'});
expect(fixture.debugElement.componentInstance.form.value).toEqual({"city": 'NYC'});
expect(sfOption.nativeElement.selected).toBe(false);
async.done();
});
@ -343,17 +343,18 @@ export function main() {
</select>
</div>`;
var rootTC;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((rtc) => rootTC = rtc);
var fixture;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then(
(compFixture) => fixture = compFixture);
tick();
rootTC.debugElement.componentInstance.form =
fixture.debugElement.componentInstance.form =
new ControlGroup({"city": new Control("NYC")});
rootTC.debugElement.componentInstance.data = ['SF', 'NYC'];
rootTC.detectChanges();
fixture.debugElement.componentInstance.data = ['SF', 'NYC'];
fixture.detectChanges();
tick();
var select = rootTC.debugElement.query(By.css('select'));
var select = fixture.debugElement.query(By.css('select'));
expect(select.nativeElement.value).toEqual('NYC');
})));
@ -363,17 +364,17 @@ export function main() {
<input type="text" ng-control="name" wrapped-value>
</div>`;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((rootTC) => {
rootTC.debugElement.componentInstance.form =
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((fixture) => {
fixture.debugElement.componentInstance.form =
new ControlGroup({"name": new Control("aa")});
rootTC.detectChanges();
var input = rootTC.debugElement.query(By.css("input"));
fixture.detectChanges();
var input = fixture.debugElement.query(By.css("input"));
expect(input.nativeElement.value).toEqual("!aa!");
input.nativeElement.value = "!bb!";
dispatchEvent(input.nativeElement, "change");
expect(rootTC.debugElement.componentInstance.form.value).toEqual({"name": "bb"});
expect(fixture.debugElement.componentInstance.form.value).toEqual({"name": "bb"});
async.done();
});
}));
@ -384,16 +385,16 @@ export function main() {
<my-input ng-control="name"></my-input>
</div>`;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((rootTC) => {
rootTC.debugElement.componentInstance.form =
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((fixture) => {
fixture.debugElement.componentInstance.form =
new ControlGroup({"name": new Control("aa")});
rootTC.detectChanges();
var input = rootTC.debugElement.query(By.css("my-input"));
fixture.detectChanges();
var input = fixture.debugElement.query(By.css("my-input"));
expect(input.componentInstance.value).toEqual("!aa!");
input.componentInstance.value = "!bb!";
ObservableWrapper.subscribe(input.componentInstance.onChange, (value) => {
expect(rootTC.debugElement.componentInstance.form.value).toEqual({"name": "bb"});
expect(fixture.debugElement.componentInstance.form.value).toEqual({"name": "bb"});
async.done();
});
input.componentInstance.dispatchChangeEvent();
@ -414,13 +415,13 @@ export function main() {
<input type="text" ng-control="max" maxlength="3">
</div>`;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((rootTC) => {
rootTC.debugElement.componentInstance.form = form;
rootTC.detectChanges();
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((fixture) => {
fixture.debugElement.componentInstance.form = form;
fixture.detectChanges();
var required = rootTC.debugElement.query(By.css("[required]"));
var minLength = rootTC.debugElement.query(By.css("[minlength]"));
var maxLength = rootTC.debugElement.query(By.css("[maxlength]"));
var required = fixture.debugElement.query(By.css("[required]"));
var minLength = fixture.debugElement.query(By.css("[minlength]"));
var maxLength = fixture.debugElement.query(By.css("[maxlength]"));
required.nativeElement.value = "";
minLength.nativeElement.value = "1";
@ -485,12 +486,12 @@ export function main() {
<input type="text" ng-control="login">
</div>`;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((rootTC) => {
rootTC.debugElement.componentInstance.form = form;
rootTC.detectChanges();
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((fixture) => {
fixture.debugElement.componentInstance.form = form;
fixture.detectChanges();
expect(form.valid).toEqual(true);
var input = rootTC.debugElement.query(By.css("input"));
var input = fixture.debugElement.query(By.css("input"));
input.nativeElement.value = "";
dispatchEvent(input.nativeElement, "change");
@ -510,16 +511,17 @@ export function main() {
<input type="text" ng-control="login">
</div>`;
var rootTC;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((root) => rootTC = root);
var fixture;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((root) => fixture =
root);
tick();
rootTC.debugElement.componentInstance.form = form;
rootTC.detectChanges();
fixture.debugElement.componentInstance.form = form;
fixture.detectChanges();
expect(form.hasError("required", ["login"])).toEqual(true);
var input = rootTC.debugElement.query(By.css("input"));
var input = fixture.debugElement.query(By.css("input"));
input.nativeElement.value = "wrong value";
dispatchEvent(input.nativeElement, "change");
@ -548,11 +550,11 @@ export function main() {
</div>
</div>`;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((rootTC) => {
rootTC.debugElement.componentInstance.form = form;
rootTC.detectChanges();
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((fixture) => {
fixture.debugElement.componentInstance.form = form;
fixture.detectChanges();
var input = rootTC.debugElement.query(By.css("input"));
var input = fixture.debugElement.query(By.css("input"));
expect(input.nativeElement.value).toEqual("value");
async.done();
});
@ -569,10 +571,10 @@ export function main() {
</div>
</div>`;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((rootTC) => {
rootTC.debugElement.componentInstance.form = form;
rootTC.detectChanges();
var input = rootTC.debugElement.query(By.css("input"));
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((fixture) => {
fixture.debugElement.componentInstance.form = form;
fixture.detectChanges();
var input = fixture.debugElement.query(By.css("input"));
input.nativeElement.value = "updatedValue";
dispatchEvent(input.nativeElement, "change");
@ -591,47 +593,49 @@ export function main() {
var t =
`<div [ng-form-model]="form"><input type="text" ng-control="name" [(ng-model)]="name"></div>`;
var rootTC: RootTestComponent;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((root) => { rootTC = root; });
var fixture: ComponentFixture;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then(
(root) => { fixture = root; });
tick();
rootTC.debugElement.componentInstance.name = 'oldValue';
rootTC.debugElement.componentInstance.form = form;
rootTC.detectChanges();
fixture.debugElement.componentInstance.name = 'oldValue';
fixture.debugElement.componentInstance.form = form;
fixture.detectChanges();
var input = rootTC.debugElement.query(By.css("input")).nativeElement;
var input = fixture.debugElement.query(By.css("input")).nativeElement;
expect(input.value).toEqual("oldValue");
input.value = "updatedValue";
dispatchEvent(input, "change");
tick();
expect(rootTC.debugElement.componentInstance.name).toEqual("updatedValue");
expect(fixture.debugElement.componentInstance.name).toEqual("updatedValue");
})));
it("should support ng-model for single fields",
inject(
[TestComponentBuilder], fakeAsync((tcb: TestComponentBuilder) => {
var form = new Control("");
inject([TestComponentBuilder], fakeAsync((tcb: TestComponentBuilder) => {
var form = new Control("");
var t = `<div><input type="text" [ng-form-control]="form" [(ng-model)]="name"></div>`;
var t =
`<div><input type="text" [ng-form-control]="form" [(ng-model)]="name"></div>`;
var rootTC: RootTestComponent;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((root) => { rootTC = root; });
tick();
rootTC.debugElement.componentInstance.form = form;
rootTC.debugElement.componentInstance.name = "oldValue";
rootTC.detectChanges();
var fixture: ComponentFixture;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then(
(root) => { fixture = root; });
tick();
fixture.debugElement.componentInstance.form = form;
fixture.debugElement.componentInstance.name = "oldValue";
fixture.detectChanges();
var input = rootTC.debugElement.query(By.css("input")).nativeElement;
expect(input.value).toEqual("oldValue");
var input = fixture.debugElement.query(By.css("input")).nativeElement;
expect(input.value).toEqual("oldValue");
input.value = "updatedValue";
dispatchEvent(input, "change");
tick();
input.value = "updatedValue";
dispatchEvent(input, "change");
tick();
expect(rootTC.debugElement.componentInstance.name).toEqual("updatedValue");
})));
expect(fixture.debugElement.componentInstance.name).toEqual("updatedValue");
})));
describe("template-driven forms", () => {
it("should add new controls and control groups",
@ -642,14 +646,14 @@ export function main() {
</div>
</form>`;
var rootTC: RootTestComponent;
var fixture: ComponentFixture;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then(
(root) => { rootTC = root; });
(root) => { fixture = root; });
tick();
rootTC.debugElement.componentInstance.name = null;
rootTC.detectChanges();
fixture.debugElement.componentInstance.name = null;
fixture.detectChanges();
var form = rootTC.debugElement.componentViewChildren[0].inject(NgForm);
var form = fixture.debugElement.componentViewChildren[0].inject(NgForm);
expect(form.controls['user']).not.toBeDefined();
tick();
@ -662,17 +666,17 @@ export function main() {
inject([TestComponentBuilder], fakeAsync((tcb: TestComponentBuilder) => {
var t = `<div><form (ng-submit)="name='updated'"></form></div>`;
var rootTC: RootTestComponent;
var fixture: ComponentFixture;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then(
(root) => { rootTC = root; });
(root) => { fixture = root; });
tick();
rootTC.debugElement.componentInstance.name = 'old';
var form = rootTC.debugElement.query(By.css("form"));
fixture.debugElement.componentInstance.name = 'old';
var form = fixture.debugElement.query(By.css("form"));
dispatchEvent(form.nativeElement, "submit");
tick();
expect(rootTC.debugElement.componentInstance.name).toEqual("updated");
expect(fixture.debugElement.componentInstance.name).toEqual("updated");
})));
it("should not create a template-driven form when ng-no-form is used",
@ -680,11 +684,11 @@ export function main() {
var t = `<form ng-no-form>
</form>`;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((rootTC) => {
rootTC.debugElement.componentInstance.name = null;
rootTC.detectChanges();
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((fixture) => {
fixture.debugElement.componentInstance.name = null;
fixture.detectChanges();
expect(rootTC.debugElement.componentViewChildren.length).toEqual(0);
expect(fixture.debugElement.componentViewChildren.length).toEqual(0);
async.done();
});
}));
@ -697,20 +701,20 @@ export function main() {
</div>
</form>`;
var rootTC: RootTestComponent;
var fixture: ComponentFixture;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then(
(root) => { rootTC = root; });
(root) => { fixture = root; });
tick();
rootTC.debugElement.componentInstance.name = 'show';
rootTC.detectChanges();
fixture.debugElement.componentInstance.name = 'show';
fixture.detectChanges();
tick();
var form = rootTC.debugElement.componentViewChildren[0].inject(NgForm);
var form = fixture.debugElement.componentViewChildren[0].inject(NgForm);
expect(form.controls['login']).toBeDefined();
rootTC.debugElement.componentInstance.name = 'hide';
rootTC.detectChanges();
fixture.debugElement.componentInstance.name = 'hide';
fixture.detectChanges();
tick();
expect(form.controls['login']).not.toBeDefined();
@ -725,19 +729,19 @@ export function main() {
</form>`;
var rootTC: RootTestComponent;
var fixture: ComponentFixture;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then(
(root) => { rootTC = root; });
(root) => { fixture = root; });
tick();
rootTC.debugElement.componentInstance.name = 'show';
rootTC.detectChanges();
fixture.debugElement.componentInstance.name = 'show';
fixture.detectChanges();
tick();
var form = rootTC.debugElement.componentViewChildren[0].inject(NgForm);
var form = fixture.debugElement.componentViewChildren[0].inject(NgForm);
expect(form.controls['user']).toBeDefined();
rootTC.debugElement.componentInstance.name = 'hide';
rootTC.detectChanges();
fixture.debugElement.componentInstance.name = 'hide';
fixture.detectChanges();
tick();
expect(form.controls['user']).not.toBeDefined();
@ -749,22 +753,22 @@ export function main() {
<input type="text" ng-control="name" [(ng-model)]="name">
</form>`;
var rootTC: RootTestComponent;
var fixture: ComponentFixture;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then(
(root) => { rootTC = root; });
(root) => { fixture = root; });
tick();
rootTC.debugElement.componentInstance.name = "oldValue";
rootTC.detectChanges();
fixture.debugElement.componentInstance.name = "oldValue";
fixture.detectChanges();
tick();
var input = rootTC.debugElement.query(By.css("input")).nativeElement;
var input = fixture.debugElement.query(By.css("input")).nativeElement;
expect(input.value).toEqual("oldValue");
input.value = "updatedValue";
dispatchEvent(input, "change");
tick();
expect(rootTC.debugElement.componentInstance.name).toEqual("updatedValue");
expect(fixture.debugElement.componentInstance.name).toEqual("updatedValue");
})));
@ -772,21 +776,21 @@ export function main() {
inject([TestComponentBuilder], fakeAsync((tcb: TestComponentBuilder) => {
var t = `<div><input type="text" [(ng-model)]="name"></div>`;
var rootTC: RootTestComponent;
var fixture: ComponentFixture;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then(
(root) => { rootTC = root; });
(root) => { fixture = root; });
tick();
rootTC.debugElement.componentInstance.name = "oldValue";
rootTC.detectChanges();
fixture.debugElement.componentInstance.name = "oldValue";
fixture.detectChanges();
var input = rootTC.debugElement.query(By.css("input")).nativeElement;
var input = fixture.debugElement.query(By.css("input")).nativeElement;
expect(input.value).toEqual("oldValue");
input.value = "updatedValue";
dispatchEvent(input, "change");
tick();
expect(rootTC.debugElement.componentInstance.name).toEqual("updatedValue");
expect(fixture.debugElement.componentInstance.name).toEqual("updatedValue");
})));
});
@ -798,21 +802,21 @@ export function main() {
var t = `<div><input type="text" [ng-form-control]="form"></div>`;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((rootTC) => {
rootTC.debugElement.componentInstance.form = form;
rootTC.detectChanges();
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((fixture) => {
fixture.debugElement.componentInstance.form = form;
fixture.detectChanges();
var input = rootTC.debugElement.query(By.css("input")).nativeElement;
var input = fixture.debugElement.query(By.css("input")).nativeElement;
expect(sortedClassList(input)).toEqual(['ng-invalid', 'ng-pristine', 'ng-untouched']);
dispatchEvent(input, "blur");
rootTC.detectChanges();
fixture.detectChanges();
expect(sortedClassList(input)).toEqual(["ng-invalid", "ng-pristine", "ng-touched"]);
input.value = "updatedValue";
dispatchEvent(input, "change");
rootTC.detectChanges();
fixture.detectChanges();
expect(sortedClassList(input)).toEqual(["ng-dirty", "ng-touched", "ng-valid"]);
async.done();
@ -825,21 +829,21 @@ export function main() {
var t = `<form [ng-form-model]="form"><input type="text" ng-control="name"></form>`;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((rootTC) => {
rootTC.debugElement.componentInstance.form = form;
rootTC.detectChanges();
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((fixture) => {
fixture.debugElement.componentInstance.form = form;
fixture.detectChanges();
var input = rootTC.debugElement.query(By.css("input")).nativeElement;
var input = fixture.debugElement.query(By.css("input")).nativeElement;
expect(sortedClassList(input)).toEqual(["ng-invalid", "ng-pristine", "ng-untouched"]);
dispatchEvent(input, "blur");
rootTC.detectChanges();
fixture.detectChanges();
expect(sortedClassList(input)).toEqual(["ng-invalid", "ng-pristine", "ng-touched"]);
input.value = "updatedValue";
dispatchEvent(input, "change");
rootTC.detectChanges();
fixture.detectChanges();
expect(sortedClassList(input)).toEqual(["ng-dirty", "ng-touched", "ng-valid"]);
async.done();
@ -850,21 +854,21 @@ export function main() {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
var t = `<div><input [(ng-model)]="name" required></div>`;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((rootTC) => {
rootTC.debugElement.componentInstance.name = "";
rootTC.detectChanges();
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((fixture) => {
fixture.debugElement.componentInstance.name = "";
fixture.detectChanges();
var input = rootTC.debugElement.query(By.css("input")).nativeElement;
var input = fixture.debugElement.query(By.css("input")).nativeElement;
expect(sortedClassList(input)).toEqual(["ng-invalid", "ng-pristine", "ng-untouched"]);
dispatchEvent(input, "blur");
rootTC.detectChanges();
fixture.detectChanges();
expect(sortedClassList(input)).toEqual(["ng-invalid", "ng-pristine", "ng-touched"]);
input.value = "updatedValue";
dispatchEvent(input, "change");
rootTC.detectChanges();
fixture.detectChanges();
expect(sortedClassList(input)).toEqual(["ng-dirty", "ng-touched", "ng-valid"]);
async.done();
@ -879,27 +883,27 @@ export function main() {
var t =
`<div><input type="text" [ng-form-control]="form" [(ng-model)]="name"></div>`;
var rootTC: RootTestComponent;
var fixture: ComponentFixture;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then(
(root) => { rootTC = root; });
(root) => { fixture = root; });
tick();
rootTC.debugElement.componentInstance.form = form;
rootTC.detectChanges();
fixture.debugElement.componentInstance.form = form;
fixture.detectChanges();
// In Firefox, effective text selection in the real DOM requires an actual focus
// of the field. This is not an issue in a new HTML document.
if (browserDetection.isFirefox) {
var fakeDoc = DOM.createHtmlDocument();
DOM.appendChild(fakeDoc.body, rootTC.debugElement.nativeElement);
DOM.appendChild(fakeDoc.body, fixture.debugElement.nativeElement);
}
var input = rootTC.debugElement.query(By.css("input")).nativeElement;
var input = fixture.debugElement.query(By.css("input")).nativeElement;
input.value = "aa";
input.selectionStart = 1;
dispatchEvent(input, "change");
tick();
rootTC.detectChanges();
fixture.detectChanges();
// selection start has not changed because we did not reset the value
expect(input.selectionStart).toEqual(1);
@ -908,33 +912,33 @@ export function main() {
it("should update the view when the model is set back to what used to be in the view",
inject([TestComponentBuilder], fakeAsync((tcb: TestComponentBuilder) => {
var t = `<input type="text" [(ng-model)]="name">`;
var rootTC: RootTestComponent;
var fixture: ComponentFixture;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then(
(root) => { rootTC = root; });
(root) => { fixture = root; });
tick();
rootTC.debugElement.componentInstance.name = "";
rootTC.detectChanges();
fixture.debugElement.componentInstance.name = "";
fixture.detectChanges();
// Type "aa" into the input.
var input = rootTC.debugElement.query(By.css("input")).nativeElement;
var input = fixture.debugElement.query(By.css("input")).nativeElement;
input.value = "aa";
input.selectionStart = 1;
dispatchEvent(input, "change");
tick();
rootTC.detectChanges();
expect(rootTC.debugElement.componentInstance.name).toEqual("aa");
fixture.detectChanges();
expect(fixture.debugElement.componentInstance.name).toEqual("aa");
// Programatically update the input value to be "bb".
rootTC.debugElement.componentInstance.name = "bb";
fixture.debugElement.componentInstance.name = "bb";
tick();
rootTC.detectChanges();
fixture.detectChanges();
expect(input.value).toEqual("bb");
// Programatically set it back to "aa".
rootTC.debugElement.componentInstance.name = "aa";
fixture.debugElement.componentInstance.name = "aa";
tick();
rootTC.detectChanges();
fixture.detectChanges();
expect(input.value).toEqual("aa");
})));
it("should not crash when validity is checked from a binding",
@ -944,11 +948,11 @@ export function main() {
// fixed.
var t = `<form><div ng-control-group="x" #x="form">
<input type="text" ng-control="test"></div>{{x.valid}}</form>`;
var rootTC: RootTestComponent;
var fixture: ComponentFixture;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then(
(root) => { rootTC = root; });
(root) => { fixture = root; });
tick();
rootTC.detectChanges();
fixture.detectChanges();
})));
});
});

View File

@ -13,7 +13,7 @@ import {
it,
xit,
TestComponentBuilder,
RootTestComponent
ComponentFixture
} from 'angular2/testing_internal';
import {OnDestroy} from 'angular2/lifecycle_hooks';
@ -24,7 +24,7 @@ import {DynamicComponentLoader} from 'angular2/src/core/linker/dynamic_component
import {ElementRef} from 'angular2/src/core/linker/element_ref';
import {DOCUMENT} from 'angular2/src/core/render/render';
import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {RootTestComponent_} from "angular2/src/testing/test_component_builder";
import {ComponentFixture_} from "angular2/src/testing/test_component_builder";
export function main() {
describe('DynamicComponentLoader', function() {
@ -232,7 +232,7 @@ export function main() {
DOM.appendChild(doc.body, rootEl);
loader.loadAsRoot(ChildComp, null, injector)
.then((componentRef) => {
var el = new RootTestComponent_(componentRef);
var el = new ComponentFixture_(componentRef);
expect(rootEl.parentNode).toBe(doc.body);
el.detectChanges();

File diff suppressed because it is too large Load Diff

View File

@ -15,7 +15,7 @@ import {
containsRegexp,
stringifyElement,
TestComponentBuilder,
RootTestComponent,
ComponentFixture,
fakeAsync,
tick
} from 'angular2/testing_internal';
@ -293,7 +293,7 @@ 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: RootTestComponent) => {
.then((main: ComponentFixture) => {
main.detectChanges();
@ -314,7 +314,7 @@ export function main() {
{template: '<simple string-prop="text"></simple>', directives: [Simple]}))
.overrideTemplate(Simple, '<style></style><p>P,</p>{{stringProp}}')
.createAsync(MainComp)
.then((main: RootTestComponent) => {
.then((main: ComponentFixture) => {
main.detectChanges();
expect(main.debugElement.nativeElement).toHaveText('P,text');

View File

@ -211,10 +211,10 @@ export function main() {
tcb.overrideTemplate(MyComp, template)
.createAsync(MyComp)
.then((rtc) => {
rtc.debugElement.componentInstance.shouldShow = true;
rtc.detectChanges();
rtc.destroy();
.then((fixture) => {
fixture.debugElement.componentInstance.shouldShow = true;
fixture.detectChanges();
fixture.destroy();
async.done();
});

View File

@ -55,15 +55,15 @@ export function main() {
describe('integration', () => {
it('should work with mutable objects',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.createAsync(TestComp).then((rootTC) => {
tcb.createAsync(TestComp).then((fixture) => {
let mutable: number[] = [1];
rootTC.debugElement.componentInstance.data = mutable;
rootTC.detectChanges();
expect(rootTC.debugElement.nativeElement).toHaveText("[\n 1\n]");
fixture.debugElement.componentInstance.data = mutable;
fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText("[\n 1\n]");
mutable.push(2);
rootTC.detectChanges();
expect(rootTC.debugElement.nativeElement).toHaveText("[\n 1,\n 2\n]");
fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText("[\n 1,\n 2\n]");
async.done();
});

View File

@ -91,15 +91,15 @@ export function main() {
describe('integration', () => {
it('should work with mutable arrays',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.createAsync(TestComp).then((rootTC) => {
tcb.createAsync(TestComp).then((fixture) => {
let mutable: number[] = [1, 2];
rootTC.debugElement.componentInstance.data = mutable;
rootTC.detectChanges();
expect(rootTC.debugElement.nativeElement).toHaveText('2');
fixture.debugElement.componentInstance.data = mutable;
fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('2');
mutable.push(3);
rootTC.detectChanges();
expect(rootTC.debugElement.nativeElement).toHaveText('2,3');
fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('2,3');
async.done();
});