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:
@@ -22,14 +22,14 @@ import {DOM} from 'angular2/src/core/dom/dom_adapter';
|
||||
|
||||
import {DebugElement, DebugElement_} from 'angular2/src/core/debug/debug_element';
|
||||
|
||||
export abstract class RootTestComponent {
|
||||
export abstract class ComponentFixture {
|
||||
debugElement: DebugElement;
|
||||
|
||||
abstract detectChanges(): void;
|
||||
abstract destroy(): void;
|
||||
}
|
||||
|
||||
export class RootTestComponent_ extends RootTestComponent {
|
||||
export class ComponentFixture_ extends ComponentFixture {
|
||||
/** @internal */
|
||||
_componentRef: ComponentRef;
|
||||
/** @internal */
|
||||
@@ -53,7 +53,7 @@ export class RootTestComponent_ extends RootTestComponent {
|
||||
var _nextRootElementId = 0;
|
||||
|
||||
/**
|
||||
* Builds a RootTestComponent for use in component level tests.
|
||||
* Builds a ComponentFixture for use in component level tests.
|
||||
*/
|
||||
@Injectable()
|
||||
export class TestComponentBuilder {
|
||||
@@ -186,11 +186,11 @@ export class TestComponentBuilder {
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds and returns a RootTestComponent.
|
||||
* Builds and returns a ComponentFixture.
|
||||
*
|
||||
* @return {Promise<RootTestComponent>}
|
||||
* @return {Promise<ComponentFixture>}
|
||||
*/
|
||||
createAsync(rootComponentType: Type): Promise<RootTestComponent> {
|
||||
createAsync(rootComponentType: Type): Promise<ComponentFixture> {
|
||||
var mockDirectiveResolver = this._injector.get(DirectiveResolver);
|
||||
var mockViewResolver = this._injector.get(ViewResolver);
|
||||
this._viewOverrides.forEach((view, type) => mockViewResolver.setView(type, view));
|
||||
@@ -220,6 +220,6 @@ export class TestComponentBuilder {
|
||||
|
||||
return this._injector.get(DynamicComponentLoader)
|
||||
.loadAsRoot(rootComponentType, `#${rootElId}`, this._injector)
|
||||
.then((componentRef) => { return new RootTestComponent_(componentRef); });
|
||||
.then((componentRef) => { return new ComponentFixture_(componentRef); });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -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();
|
||||
});
|
||||
}));
|
||||
|
||||
@@ -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('');
|
||||
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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
@@ -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');
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
RootTestComponent,
|
||||
ComponentFixture,
|
||||
AsyncTestCompleter,
|
||||
TestComponentBuilder,
|
||||
beforeEach,
|
||||
@@ -58,7 +58,7 @@ export function main() {
|
||||
describe('Router lifecycle hooks', () => {
|
||||
|
||||
var tcb: TestComponentBuilder;
|
||||
var rootTC: RootTestComponent;
|
||||
var fixture: ComponentFixture;
|
||||
var rtr;
|
||||
|
||||
beforeEachBindings(() => [
|
||||
@@ -87,7 +87,7 @@ export function main() {
|
||||
directives: [RouterOutlet, RouterLink]
|
||||
}))
|
||||
.createAsync(MyComp)
|
||||
.then((tc) => { rootTC = tc; });
|
||||
.then((tc) => { fixture = tc; });
|
||||
}
|
||||
|
||||
it('should call the onActivate hook', inject([AsyncTestCompleter], (async) => {
|
||||
@@ -95,8 +95,8 @@ export function main() {
|
||||
.then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})]))
|
||||
.then((_) => rtr.navigateByUrl('/on-activate'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.debugElement.nativeElement).toHaveText('activate cmp');
|
||||
fixture.detectChanges();
|
||||
expect(fixture.debugElement.nativeElement).toHaveText('activate cmp');
|
||||
expect(log).toEqual(['activate: null -> /on-activate']);
|
||||
async.done();
|
||||
});
|
||||
@@ -114,8 +114,8 @@ export function main() {
|
||||
});
|
||||
rtr.navigateByUrl('/parent-activate/child-activate')
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.debugElement.nativeElement).toHaveText('parent {activate cmp}');
|
||||
fixture.detectChanges();
|
||||
expect(fixture.debugElement.nativeElement).toHaveText('parent {activate cmp}');
|
||||
expect(log).toEqual([
|
||||
'parent activate: null -> /parent-activate',
|
||||
'activate: null -> /child-activate'
|
||||
@@ -131,8 +131,8 @@ export function main() {
|
||||
.then((_) => rtr.navigateByUrl('/on-deactivate'))
|
||||
.then((_) => rtr.navigateByUrl('/a'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.debugElement.nativeElement).toHaveText('A');
|
||||
fixture.detectChanges();
|
||||
expect(fixture.debugElement.nativeElement).toHaveText('A');
|
||||
expect(log).toEqual(['deactivate: /on-deactivate -> /a']);
|
||||
async.done();
|
||||
});
|
||||
@@ -147,13 +147,13 @@ export function main() {
|
||||
ObservableWrapper.subscribe<string>(eventBus, (ev) => {
|
||||
if (ev.startsWith('deactivate')) {
|
||||
completer.resolve(true);
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.debugElement.nativeElement).toHaveText('parent {deactivate cmp}');
|
||||
fixture.detectChanges();
|
||||
expect(fixture.debugElement.nativeElement).toHaveText('parent {deactivate cmp}');
|
||||
}
|
||||
});
|
||||
rtr.navigateByUrl('/a').then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.debugElement.nativeElement).toHaveText('A');
|
||||
fixture.detectChanges();
|
||||
expect(fixture.debugElement.nativeElement).toHaveText('A');
|
||||
expect(log).toEqual([
|
||||
'deactivate: /child-deactivate -> null',
|
||||
'parent deactivate: /parent-deactivate -> /a'
|
||||
@@ -169,16 +169,16 @@ export function main() {
|
||||
.then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})]))
|
||||
.then((_) => rtr.navigateByUrl('/on-reuse/1/a'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
fixture.detectChanges();
|
||||
expect(log).toEqual([]);
|
||||
expect(rootTC.debugElement.nativeElement).toHaveText('reuse {A}');
|
||||
expect(fixture.debugElement.nativeElement).toHaveText('reuse {A}');
|
||||
expect(cmpInstanceCount).toBe(1);
|
||||
})
|
||||
.then((_) => rtr.navigateByUrl('/on-reuse/2/b'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
fixture.detectChanges();
|
||||
expect(log).toEqual(['reuse: /on-reuse/1 -> /on-reuse/2']);
|
||||
expect(rootTC.debugElement.nativeElement).toHaveText('reuse {B}');
|
||||
expect(fixture.debugElement.nativeElement).toHaveText('reuse {B}');
|
||||
expect(cmpInstanceCount).toBe(1);
|
||||
async.done();
|
||||
});
|
||||
@@ -191,16 +191,16 @@ export function main() {
|
||||
.then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})]))
|
||||
.then((_) => rtr.navigateByUrl('/never-reuse/1/a'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
fixture.detectChanges();
|
||||
expect(log).toEqual([]);
|
||||
expect(rootTC.debugElement.nativeElement).toHaveText('reuse {A}');
|
||||
expect(fixture.debugElement.nativeElement).toHaveText('reuse {A}');
|
||||
expect(cmpInstanceCount).toBe(1);
|
||||
})
|
||||
.then((_) => rtr.navigateByUrl('/never-reuse/2/b'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
fixture.detectChanges();
|
||||
expect(log).toEqual([]);
|
||||
expect(rootTC.debugElement.nativeElement).toHaveText('reuse {B}');
|
||||
expect(fixture.debugElement.nativeElement).toHaveText('reuse {B}');
|
||||
expect(cmpInstanceCount).toBe(2);
|
||||
async.done();
|
||||
});
|
||||
@@ -218,8 +218,8 @@ export function main() {
|
||||
});
|
||||
rtr.navigateByUrl('/can-activate/a')
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.debugElement.nativeElement).toHaveText('canActivate {A}');
|
||||
fixture.detectChanges();
|
||||
expect(fixture.debugElement.nativeElement).toHaveText('canActivate {A}');
|
||||
expect(log).toEqual(['canActivate: null -> /can-activate']);
|
||||
async.done();
|
||||
});
|
||||
@@ -238,8 +238,8 @@ export function main() {
|
||||
});
|
||||
rtr.navigateByUrl('/can-activate/a')
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.debugElement.nativeElement).toHaveText('');
|
||||
fixture.detectChanges();
|
||||
expect(fixture.debugElement.nativeElement).toHaveText('');
|
||||
expect(log).toEqual(['canActivate: null -> /can-activate']);
|
||||
async.done();
|
||||
});
|
||||
@@ -252,8 +252,8 @@ export function main() {
|
||||
.then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})]))
|
||||
.then((_) => rtr.navigateByUrl('/can-deactivate/a'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.debugElement.nativeElement).toHaveText('canDeactivate {A}');
|
||||
fixture.detectChanges();
|
||||
expect(fixture.debugElement.nativeElement).toHaveText('canDeactivate {A}');
|
||||
expect(log).toEqual([]);
|
||||
|
||||
ObservableWrapper.subscribe<string>(eventBus, (ev) => {
|
||||
@@ -263,8 +263,8 @@ export function main() {
|
||||
});
|
||||
|
||||
rtr.navigateByUrl('/a').then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.debugElement.nativeElement).toHaveText('A');
|
||||
fixture.detectChanges();
|
||||
expect(fixture.debugElement.nativeElement).toHaveText('A');
|
||||
expect(log).toEqual(['canDeactivate: /can-deactivate -> /a']);
|
||||
async.done();
|
||||
});
|
||||
@@ -277,8 +277,8 @@ export function main() {
|
||||
.then((_) => rtr.config([new Route({path: '/...', component: LifecycleCmp})]))
|
||||
.then((_) => rtr.navigateByUrl('/can-deactivate/a'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.debugElement.nativeElement).toHaveText('canDeactivate {A}');
|
||||
fixture.detectChanges();
|
||||
expect(fixture.debugElement.nativeElement).toHaveText('canDeactivate {A}');
|
||||
expect(log).toEqual([]);
|
||||
|
||||
ObservableWrapper.subscribe<string>(eventBus, (ev) => {
|
||||
@@ -288,8 +288,8 @@ export function main() {
|
||||
});
|
||||
|
||||
rtr.navigateByUrl('/a').then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.debugElement.nativeElement).toHaveText('canDeactivate {A}');
|
||||
fixture.detectChanges();
|
||||
expect(fixture.debugElement.nativeElement).toHaveText('canDeactivate {A}');
|
||||
expect(log).toEqual(['canDeactivate: /can-deactivate -> /a']);
|
||||
async.done();
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
RootTestComponent,
|
||||
ComponentFixture,
|
||||
AsyncTestCompleter,
|
||||
TestComponentBuilder,
|
||||
beforeEach,
|
||||
@@ -41,7 +41,7 @@ export function main() {
|
||||
describe('navigation', () => {
|
||||
|
||||
var tcb: TestComponentBuilder;
|
||||
var rootTC: RootTestComponent;
|
||||
var fixture: ComponentFixture;
|
||||
var rtr;
|
||||
|
||||
beforeEachBindings(() => [
|
||||
@@ -70,7 +70,7 @@ export function main() {
|
||||
directives: [RouterOutlet, RouterLink]
|
||||
}))
|
||||
.createAsync(MyComp)
|
||||
.then((tc) => { rootTC = tc; });
|
||||
.then((tc) => { fixture = tc; });
|
||||
}
|
||||
|
||||
it('should work in a simple case', inject([AsyncTestCompleter], (async) => {
|
||||
@@ -78,8 +78,8 @@ export function main() {
|
||||
.then((_) => rtr.config([new Route({path: '/test', component: HelloCmp})]))
|
||||
.then((_) => rtr.navigateByUrl('/test'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.debugElement.nativeElement).toHaveText('hello');
|
||||
fixture.detectChanges();
|
||||
expect(fixture.debugElement.nativeElement).toHaveText('hello');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@@ -91,13 +91,13 @@ export function main() {
|
||||
.then((_) => rtr.config([new Route({path: '/user/:name', component: UserCmp})]))
|
||||
.then((_) => rtr.navigateByUrl('/user/brian'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.debugElement.nativeElement).toHaveText('hello brian');
|
||||
fixture.detectChanges();
|
||||
expect(fixture.debugElement.nativeElement).toHaveText('hello brian');
|
||||
})
|
||||
.then((_) => rtr.navigateByUrl('/user/igor'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.debugElement.nativeElement).toHaveText('hello igor');
|
||||
fixture.detectChanges();
|
||||
expect(fixture.debugElement.nativeElement).toHaveText('hello igor');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@@ -108,8 +108,8 @@ export function main() {
|
||||
.then((_) => rtr.config([new Route({path: '/a/...', component: ParentCmp})]))
|
||||
.then((_) => rtr.navigateByUrl('/a/b'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.debugElement.nativeElement).toHaveText('outer { inner { hello } }');
|
||||
fixture.detectChanges();
|
||||
expect(fixture.debugElement.nativeElement).toHaveText('outer { inner { hello } }');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@@ -120,8 +120,8 @@ export function main() {
|
||||
.then((_) => rtr.config([new Route({path: '/a/...', component: ParentCmp})]))
|
||||
.then((_) => rtr.navigateByUrl('/a'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.debugElement.nativeElement).toHaveText('outer { inner { hello } }');
|
||||
fixture.detectChanges();
|
||||
expect(fixture.debugElement.nativeElement).toHaveText('outer { inner { hello } }');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@@ -132,8 +132,8 @@ export function main() {
|
||||
.then((_) => rtr.config([new AsyncRoute({path: '/a/...', loader: parentLoader})]))
|
||||
.then((_) => rtr.navigateByUrl('/a/b'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.debugElement.nativeElement).toHaveText('outer { inner { hello } }');
|
||||
fixture.detectChanges();
|
||||
expect(fixture.debugElement.nativeElement).toHaveText('outer { inner { hello } }');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@@ -148,8 +148,8 @@ export function main() {
|
||||
]))
|
||||
.then((_) => rtr.navigateByUrl('/original'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.debugElement.nativeElement).toHaveText('hello');
|
||||
fixture.detectChanges();
|
||||
expect(fixture.debugElement.nativeElement).toHaveText('hello');
|
||||
expect(location.urlChanges).toEqual(['/redirected']);
|
||||
async.done();
|
||||
});
|
||||
@@ -161,15 +161,15 @@ export function main() {
|
||||
.then((_) => rtr.config([new Route({path: '/team/:id/...', component: TeamCmp})]))
|
||||
.then((_) => rtr.navigateByUrl('/team/angular/user/rado'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
fixture.detectChanges();
|
||||
expect(cmpInstanceCount).toBe(1);
|
||||
expect(rootTC.debugElement.nativeElement).toHaveText('team angular { hello rado }');
|
||||
expect(fixture.debugElement.nativeElement).toHaveText('team angular { hello rado }');
|
||||
})
|
||||
.then((_) => rtr.navigateByUrl('/team/angular/user/victor'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
fixture.detectChanges();
|
||||
expect(cmpInstanceCount).toBe(1);
|
||||
expect(rootTC.debugElement.nativeElement)
|
||||
expect(fixture.debugElement.nativeElement)
|
||||
.toHaveText('team angular { hello victor }');
|
||||
async.done();
|
||||
});
|
||||
@@ -181,17 +181,17 @@ export function main() {
|
||||
.then((_) => rtr.config([new Route({path: '/team/:id/...', component: TeamCmp})]))
|
||||
.then((_) => rtr.navigateByUrl('/team/angular/user/rado'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
fixture.detectChanges();
|
||||
expect(cmpInstanceCount).toBe(1);
|
||||
expect(childCmpInstanceCount).toBe(1);
|
||||
expect(rootTC.debugElement.nativeElement).toHaveText('team angular { hello rado }');
|
||||
expect(fixture.debugElement.nativeElement).toHaveText('team angular { hello rado }');
|
||||
})
|
||||
.then((_) => rtr.navigateByUrl('/team/dart/user/rado'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
fixture.detectChanges();
|
||||
expect(cmpInstanceCount).toBe(2);
|
||||
expect(childCmpInstanceCount).toBe(2);
|
||||
expect(rootTC.debugElement.nativeElement).toHaveText('team dart { hello rado }');
|
||||
expect(fixture.debugElement.nativeElement).toHaveText('team dart { hello rado }');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@@ -203,8 +203,8 @@ export function main() {
|
||||
]))
|
||||
.then((_) => rtr.navigateByUrl('/route-data'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.debugElement.nativeElement).toHaveText('true');
|
||||
fixture.detectChanges();
|
||||
expect(fixture.debugElement.nativeElement).toHaveText('true');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@@ -218,8 +218,8 @@ export function main() {
|
||||
]))
|
||||
.then((_) => rtr.navigateByUrl('/route-data'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.debugElement.nativeElement).toHaveText('true');
|
||||
fixture.detectChanges();
|
||||
expect(fixture.debugElement.nativeElement).toHaveText('true');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@@ -231,8 +231,8 @@ export function main() {
|
||||
[new Route({path: '/route-data-default', component: RouteDataCmp})]))
|
||||
.then((_) => rtr.navigateByUrl('/route-data-default'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.debugElement.nativeElement).toHaveText('');
|
||||
fixture.detectChanges();
|
||||
expect(fixture.debugElement.nativeElement).toHaveText('');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@@ -243,8 +243,9 @@ export function main() {
|
||||
.then((_) => rtr.config([new Route({path: '/...', component: AuxCmp})]))
|
||||
.then((_) => rtr.navigateByUrl('/hello(modal)'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.debugElement.nativeElement).toHaveText('main {hello} | aux {modal}');
|
||||
fixture.detectChanges();
|
||||
expect(fixture.debugElement.nativeElement)
|
||||
.toHaveText('main {hello} | aux {modal}');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
@@ -79,10 +79,10 @@ export function main() {
|
||||
|
||||
it('should rethrow exceptions from component constructors',
|
||||
inject([AsyncTestCompleter, TestComponentBuilder], (async, tcb: TestComponentBuilder) => {
|
||||
tcb.createAsync(AppCmp).then((rootTC) => {
|
||||
var router = rootTC.debugElement.componentInstance.router;
|
||||
tcb.createAsync(AppCmp).then((fixture) => {
|
||||
var router = fixture.debugElement.componentInstance.router;
|
||||
PromiseWrapper.catchError(router.navigateByUrl('/cause-error'), (error) => {
|
||||
expect(rootTC.debugElement.nativeElement).toHaveText('outer { oh no }');
|
||||
expect(fixture.debugElement.nativeElement).toHaveText('outer { oh no }');
|
||||
expect(error).toContainError('oops!');
|
||||
async.done();
|
||||
});
|
||||
@@ -98,8 +98,8 @@ export function main() {
|
||||
inject([AsyncTestCompleter, TestComponentBuilder], (async, tcb: TestComponentBuilder) => {
|
||||
|
||||
tcb.createAsync(HierarchyAppCmp)
|
||||
.then((rootTC) => {
|
||||
var router = rootTC.debugElement.componentInstance.router;
|
||||
.then((fixture) => {
|
||||
var router = fixture.debugElement.componentInstance.router;
|
||||
var position = 0;
|
||||
var flipped = false;
|
||||
var history =
|
||||
@@ -110,8 +110,8 @@ export function main() {
|
||||
]
|
||||
|
||||
router.subscribe((_) => {
|
||||
var location = rootTC.debugElement.componentInstance.location;
|
||||
var element = rootTC.debugElement.nativeElement;
|
||||
var location = fixture.debugElement.componentInstance.location;
|
||||
var element = fixture.debugElement.nativeElement;
|
||||
var path = location.path();
|
||||
|
||||
var entry = history[position];
|
||||
@@ -150,12 +150,12 @@ export function main() {
|
||||
inject([AsyncTestCompleter, TestComponentBuilder], (async, tcb: TestComponentBuilder) => {
|
||||
|
||||
tcb.createAsync(HierarchyAppCmp)
|
||||
.then((rootTC) => {
|
||||
var router = rootTC.debugElement.componentInstance.router;
|
||||
.then((fixture) => {
|
||||
var router = fixture.debugElement.componentInstance.router;
|
||||
router.subscribe((_) => {
|
||||
expect(rootTC.debugElement.nativeElement)
|
||||
expect(fixture.debugElement.nativeElement)
|
||||
.toHaveText('root { parent { hello } }');
|
||||
expect(rootTC.debugElement.componentInstance.location.path())
|
||||
expect(fixture.debugElement.componentInstance.location.path())
|
||||
.toEqual('/parent/child');
|
||||
async.done();
|
||||
});
|
||||
@@ -171,12 +171,12 @@ export function main() {
|
||||
(async, tcb: TestComponentBuilder) => {
|
||||
|
||||
tcb.createAsync(HierarchyAppCmp)
|
||||
.then((rootTC) => {
|
||||
var router = rootTC.debugElement.componentInstance.router;
|
||||
.then((fixture) => {
|
||||
var router = fixture.debugElement.componentInstance.router;
|
||||
router.subscribe((_) => {
|
||||
expect(rootTC.debugElement.nativeElement)
|
||||
expect(fixture.debugElement.nativeElement)
|
||||
.toHaveText('root { parent { hello } }');
|
||||
expect(rootTC.debugElement.componentInstance.location.path())
|
||||
expect(fixture.debugElement.componentInstance.location.path())
|
||||
.toEqual('/my/app/parent/child');
|
||||
async.done();
|
||||
});
|
||||
@@ -194,12 +194,12 @@ export function main() {
|
||||
it('should recognize and return querystring params with the injected RouteParams',
|
||||
inject([AsyncTestCompleter, TestComponentBuilder], (async, tcb: TestComponentBuilder) => {
|
||||
tcb.createAsync(QueryStringAppCmp)
|
||||
.then((rootTC) => {
|
||||
var router = rootTC.debugElement.componentInstance.router;
|
||||
.then((fixture) => {
|
||||
var router = fixture.debugElement.componentInstance.router;
|
||||
router.subscribe((_) => {
|
||||
rootTC.detectChanges();
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(rootTC.debugElement.nativeElement)
|
||||
expect(fixture.debugElement.nativeElement)
|
||||
.toHaveText('qParam = search-for-something');
|
||||
/*
|
||||
expect(applicationRef.hostComponent.location.path())
|
||||
@@ -207,7 +207,7 @@ export function main() {
|
||||
async.done();
|
||||
});
|
||||
router.navigateByUrl('/qs?q=search-for-something');
|
||||
rootTC.detectChanges();
|
||||
fixture.detectChanges();
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
RootTestComponent,
|
||||
ComponentFixture,
|
||||
AsyncTestCompleter,
|
||||
beforeEach,
|
||||
ddescribe,
|
||||
@@ -43,7 +43,7 @@ import {DOM} from 'angular2/src/core/dom/dom_adapter';
|
||||
export function main() {
|
||||
describe('router-link directive', function() {
|
||||
var tcb: TestComponentBuilder;
|
||||
var rootTC: RootTestComponent;
|
||||
var fixture: ComponentFixture;
|
||||
var router, location;
|
||||
|
||||
beforeEachBindings(() => [
|
||||
@@ -70,7 +70,7 @@ export function main() {
|
||||
directives: [RouterOutlet, RouterLink]
|
||||
}))
|
||||
.createAsync(MyComp)
|
||||
.then((tc) => { rootTC = tc; });
|
||||
.then((tc) => { fixture = tc; });
|
||||
}
|
||||
|
||||
it('should generate absolute hrefs that include the base href',
|
||||
@@ -81,8 +81,8 @@ export function main() {
|
||||
[new Route({path: '/user', component: UserCmp, name: 'User'})]))
|
||||
.then((_) => router.navigateByUrl('/a/b'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(getHref(rootTC)).toEqual('/my/base/user');
|
||||
fixture.detectChanges();
|
||||
expect(getHref(fixture)).toEqual('/my/base/user');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@@ -94,8 +94,8 @@ export function main() {
|
||||
[new Route({path: '/user', component: UserCmp, name: 'User'})]))
|
||||
.then((_) => router.navigateByUrl('/a/b'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(getHref(rootTC)).toEqual('/user');
|
||||
fixture.detectChanges();
|
||||
expect(getHref(fixture)).toEqual('/user');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@@ -107,10 +107,10 @@ export function main() {
|
||||
[new Route({path: '/user/:name', component: UserCmp, name: 'User'})]))
|
||||
.then((_) => router.navigateByUrl('/a/b'))
|
||||
.then((_) => {
|
||||
rootTC.debugElement.componentInstance.name = 'brian';
|
||||
rootTC.detectChanges();
|
||||
expect(rootTC.debugElement.nativeElement).toHaveText('brian');
|
||||
expect(DOM.getAttribute(rootTC.debugElement.componentViewChildren[0].nativeElement,
|
||||
fixture.debugElement.componentInstance.name = 'brian';
|
||||
fixture.detectChanges();
|
||||
expect(fixture.debugElement.nativeElement).toHaveText('brian');
|
||||
expect(DOM.getAttribute(fixture.debugElement.componentViewChildren[0].nativeElement,
|
||||
'href'))
|
||||
.toEqual('/user/brian');
|
||||
async.done();
|
||||
@@ -125,8 +125,8 @@ export function main() {
|
||||
[new Route({path: '/page/:number', component: SiblingPageCmp, name: 'Page'})]))
|
||||
.then((_) => router.navigateByUrl('/page/1'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(DOM.getAttribute(rootTC.debugElement.componentViewChildren[1]
|
||||
fixture.detectChanges();
|
||||
expect(DOM.getAttribute(fixture.debugElement.componentViewChildren[1]
|
||||
.componentViewChildren[0]
|
||||
.nativeElement,
|
||||
'href'))
|
||||
@@ -144,8 +144,8 @@ export function main() {
|
||||
]))
|
||||
.then((_) => router.navigateByUrl('/page/1'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(DOM.getAttribute(rootTC.debugElement.componentViewChildren[1]
|
||||
fixture.detectChanges();
|
||||
expect(DOM.getAttribute(fixture.debugElement.componentViewChildren[1]
|
||||
.componentViewChildren[0]
|
||||
.nativeElement,
|
||||
'href'))
|
||||
@@ -162,8 +162,8 @@ export function main() {
|
||||
]))
|
||||
.then((_) => router.navigateByUrl('/book/1984/page/1'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(DOM.getAttribute(rootTC.debugElement.componentViewChildren[1]
|
||||
fixture.detectChanges();
|
||||
expect(DOM.getAttribute(fixture.debugElement.componentViewChildren[1]
|
||||
.componentViewChildren[0]
|
||||
.nativeElement,
|
||||
'href'))
|
||||
@@ -181,7 +181,7 @@ export function main() {
|
||||
.then((_) => router.navigateByUrl('/book/1984/page/1'))
|
||||
.then((_) => {
|
||||
var link = ListWrapper.toJSON(['Book', {number: 100}]);
|
||||
expect(() => rootTC.detectChanges())
|
||||
expect(() => fixture.detectChanges())
|
||||
.toThrowErrorWith(
|
||||
`Link "${link}" is ambiguous, use "./" or "../" to disambiguate.`);
|
||||
async.done();
|
||||
@@ -200,8 +200,8 @@ export function main() {
|
||||
]))
|
||||
.then((_) => router.navigate(['/ChildWithGrandchild']))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(DOM.getAttribute(rootTC.debugElement.componentViewChildren[1]
|
||||
fixture.detectChanges();
|
||||
expect(DOM.getAttribute(fixture.debugElement.componentViewChildren[1]
|
||||
.componentViewChildren[0]
|
||||
.nativeElement,
|
||||
'href'))
|
||||
@@ -217,14 +217,14 @@ export function main() {
|
||||
[new Route({path: '/book/:title/...', component: BookCmp, name: 'Book'})]))
|
||||
.then((_) => router.navigateByUrl('/book/1984/page/1'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
expect(DOM.getAttribute(rootTC.debugElement.componentViewChildren[1]
|
||||
fixture.detectChanges();
|
||||
expect(DOM.getAttribute(fixture.debugElement.componentViewChildren[1]
|
||||
.componentViewChildren[0]
|
||||
.nativeElement,
|
||||
'href'))
|
||||
.toEqual('/book/1984/page/100');
|
||||
|
||||
expect(DOM.getAttribute(rootTC.debugElement.componentViewChildren[1]
|
||||
expect(DOM.getAttribute(fixture.debugElement.componentViewChildren[1]
|
||||
.componentViewChildren[2]
|
||||
.componentViewChildren[0]
|
||||
.nativeElement,
|
||||
@@ -245,9 +245,9 @@ export function main() {
|
||||
<a [router-link]="['./BetterChild']" class="better-child-link">Better Child</a>
|
||||
<router-outlet></router-outlet>`))
|
||||
.then((_) => {
|
||||
var element = rootTC.debugElement.nativeElement;
|
||||
var element = fixture.debugElement.nativeElement;
|
||||
|
||||
rootTC.detectChanges();
|
||||
fixture.detectChanges();
|
||||
|
||||
var link1 = DOM.querySelector(element, '.child-link');
|
||||
var link2 = DOM.querySelector(element, '.better-child-link');
|
||||
@@ -256,7 +256,7 @@ export function main() {
|
||||
expect(link2).not.toHaveCssClass('router-link-active');
|
||||
|
||||
router.subscribe((_) => {
|
||||
rootTC.detectChanges();
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(link1).not.toHaveCssClass('router-link-active');
|
||||
expect(link2).toHaveCssClass('router-link-active');
|
||||
@@ -280,9 +280,9 @@ export function main() {
|
||||
<a [router-link]="['./ChildWithGrandchild/Grandchild']" class="child-with-grandchild-link">Better Child</a>
|
||||
<router-outlet></router-outlet>`))
|
||||
.then((_) => {
|
||||
var element = rootTC.debugElement.nativeElement;
|
||||
var element = fixture.debugElement.nativeElement;
|
||||
|
||||
rootTC.detectChanges();
|
||||
fixture.detectChanges();
|
||||
|
||||
var link1 = DOM.querySelector(element, '.child-link');
|
||||
var link2 = DOM.querySelector(element, '.child-with-grandchild-link');
|
||||
@@ -291,7 +291,7 @@ export function main() {
|
||||
expect(link2).not.toHaveCssClass('router-link-active');
|
||||
|
||||
router.subscribe((_) => {
|
||||
rootTC.detectChanges();
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(link1).not.toHaveCssClass('router-link-active');
|
||||
expect(link2).toHaveCssClass('router-link-active');
|
||||
@@ -312,7 +312,7 @@ export function main() {
|
||||
describe('when clicked', () => {
|
||||
|
||||
var clickOnElement = function(view) {
|
||||
var anchorEl = rootTC.debugElement.componentViewChildren[0].nativeElement;
|
||||
var anchorEl = fixture.debugElement.componentViewChildren[0].nativeElement;
|
||||
var dispatchedEvent = DOM.createMouseEvent('click');
|
||||
DOM.dispatchEvent(anchorEl, dispatchedEvent);
|
||||
return dispatchedEvent;
|
||||
@@ -324,9 +324,9 @@ export function main() {
|
||||
[new Route({path: '/user', component: UserCmp, name: 'User'})]))
|
||||
.then((_) => router.navigateByUrl('/a/b'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
fixture.detectChanges();
|
||||
|
||||
var dispatchedEvent = clickOnElement(rootTC);
|
||||
var dispatchedEvent = clickOnElement(fixture);
|
||||
expect(DOM.isPrevented(dispatchedEvent)).toBe(true);
|
||||
|
||||
// router navigation is async.
|
||||
@@ -345,9 +345,9 @@ export function main() {
|
||||
[new Route({path: '/user', component: UserCmp, name: 'User'})]))
|
||||
.then((_) => router.navigateByUrl('/a/b'))
|
||||
.then((_) => {
|
||||
rootTC.detectChanges();
|
||||
fixture.detectChanges();
|
||||
|
||||
var dispatchedEvent = clickOnElement(rootTC);
|
||||
var dispatchedEvent = clickOnElement(fixture);
|
||||
expect(DOM.isPrevented(dispatchedEvent)).toBe(true);
|
||||
|
||||
// router navigation is async.
|
||||
@@ -361,7 +361,7 @@ export function main() {
|
||||
});
|
||||
}
|
||||
|
||||
function getHref(tc: RootTestComponent) {
|
||||
function getHref(tc: ComponentFixture) {
|
||||
return DOM.getAttribute(tc.debugElement.componentViewChildren[0].nativeElement, 'href');
|
||||
}
|
||||
|
||||
|
||||
@@ -95,10 +95,10 @@ export function main() {
|
||||
it('should instantiate a component with valid DOM',
|
||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||
|
||||
tcb.createAsync(ChildComp).then((rootTestComponent) => {
|
||||
rootTestComponent.detectChanges();
|
||||
tcb.createAsync(ChildComp).then((componentFixture) => {
|
||||
componentFixture.detectChanges();
|
||||
|
||||
expect(rootTestComponent.debugElement.nativeElement).toHaveText('Original Child');
|
||||
expect(componentFixture.debugElement.nativeElement).toHaveText('Original Child');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@@ -106,13 +106,13 @@ export function main() {
|
||||
it('should allow changing members of the component',
|
||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||
|
||||
tcb.createAsync(MyIfComp).then((rootTestComponent) => {
|
||||
rootTestComponent.detectChanges();
|
||||
expect(rootTestComponent.debugElement.nativeElement).toHaveText('MyIf()');
|
||||
tcb.createAsync(MyIfComp).then((componentFixture) => {
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.debugElement.nativeElement).toHaveText('MyIf()');
|
||||
|
||||
rootTestComponent.debugElement.componentInstance.showMore = true;
|
||||
rootTestComponent.detectChanges();
|
||||
expect(rootTestComponent.debugElement.nativeElement).toHaveText('MyIf(More)');
|
||||
componentFixture.debugElement.componentInstance.showMore = true;
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.debugElement.nativeElement).toHaveText('MyIf(More)');
|
||||
|
||||
async.done();
|
||||
});
|
||||
@@ -123,9 +123,9 @@ export function main() {
|
||||
|
||||
tcb.overrideTemplate(MockChildComp, '<span>Mock</span>')
|
||||
.createAsync(MockChildComp)
|
||||
.then((rootTestComponent) => {
|
||||
rootTestComponent.detectChanges();
|
||||
expect(rootTestComponent.debugElement.nativeElement).toHaveText('Mock');
|
||||
.then((componentFixture) => {
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.debugElement.nativeElement).toHaveText('Mock');
|
||||
|
||||
async.done();
|
||||
});
|
||||
@@ -137,9 +137,9 @@ export function main() {
|
||||
tcb.overrideView(ChildComp,
|
||||
new ViewMetadata({template: '<span>Modified {{childBinding}}</span>'}))
|
||||
.createAsync(ChildComp)
|
||||
.then((rootTestComponent) => {
|
||||
rootTestComponent.detectChanges();
|
||||
expect(rootTestComponent.debugElement.nativeElement).toHaveText('Modified Child');
|
||||
.then((componentFixture) => {
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.debugElement.nativeElement).toHaveText('Modified Child');
|
||||
|
||||
async.done();
|
||||
});
|
||||
@@ -150,9 +150,9 @@ export function main() {
|
||||
|
||||
tcb.overrideDirective(ParentComp, ChildComp, MockChildComp)
|
||||
.createAsync(ParentComp)
|
||||
.then((rootTestComponent) => {
|
||||
rootTestComponent.detectChanges();
|
||||
expect(rootTestComponent.debugElement.nativeElement).toHaveText('Parent(Mock)');
|
||||
.then((componentFixture) => {
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.debugElement.nativeElement).toHaveText('Parent(Mock)');
|
||||
|
||||
async.done();
|
||||
});
|
||||
@@ -165,9 +165,9 @@ export function main() {
|
||||
tcb.overrideDirective(ParentComp, ChildComp, ChildWithChildComp)
|
||||
.overrideDirective(ChildWithChildComp, ChildChildComp, MockChildChildComp)
|
||||
.createAsync(ParentComp)
|
||||
.then((rootTestComponent) => {
|
||||
rootTestComponent.detectChanges();
|
||||
expect(rootTestComponent.debugElement.nativeElement)
|
||||
.then((componentFixture) => {
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.debugElement.nativeElement)
|
||||
.toHaveText('Parent(Original Child(ChildChild Mock))');
|
||||
|
||||
async.done();
|
||||
@@ -180,9 +180,9 @@ export function main() {
|
||||
tcb.overrideProviders(TestBindingsComp,
|
||||
[provide(FancyService, {useClass: MockFancyService})])
|
||||
.createAsync(TestBindingsComp)
|
||||
.then((rootTestComponent) => {
|
||||
rootTestComponent.detectChanges();
|
||||
expect(rootTestComponent.debugElement.nativeElement)
|
||||
.then((componentFixture) => {
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.debugElement.nativeElement)
|
||||
.toHaveText('injected value: mocked out value');
|
||||
async.done();
|
||||
});
|
||||
@@ -195,9 +195,9 @@ export function main() {
|
||||
tcb.overrideViewProviders(TestViewBindingsComp,
|
||||
[provide(FancyService, {useClass: MockFancyService})])
|
||||
.createAsync(TestViewBindingsComp)
|
||||
.then((rootTestComponent) => {
|
||||
rootTestComponent.detectChanges();
|
||||
expect(rootTestComponent.debugElement.nativeElement)
|
||||
.then((componentFixture) => {
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.debugElement.nativeElement)
|
||||
.toHaveText('injected value: mocked out value');
|
||||
async.done();
|
||||
});
|
||||
|
||||
@@ -243,23 +243,23 @@ export function main() {
|
||||
it('should instantiate a component with valid DOM',
|
||||
injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
|
||||
return tcb.createAsync(ChildComp).then((rootTestComponent) => {
|
||||
rootTestComponent.detectChanges();
|
||||
return tcb.createAsync(ChildComp).then((componentFixture) => {
|
||||
componentFixture.detectChanges();
|
||||
|
||||
expect(rootTestComponent.debugElement.nativeElement).toHaveText('Original Child');
|
||||
expect(componentFixture.debugElement.nativeElement).toHaveText('Original Child');
|
||||
});
|
||||
}));
|
||||
|
||||
it('should allow changing members of the component',
|
||||
injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
|
||||
return tcb.createAsync(MyIfComp).then((rootTestComponent) => {
|
||||
rootTestComponent.detectChanges();
|
||||
expect(rootTestComponent.debugElement.nativeElement).toHaveText('MyIf()');
|
||||
return tcb.createAsync(MyIfComp).then((componentFixture) => {
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.debugElement.nativeElement).toHaveText('MyIf()');
|
||||
|
||||
rootTestComponent.debugElement.componentInstance.showMore = true;
|
||||
rootTestComponent.detectChanges();
|
||||
expect(rootTestComponent.debugElement.nativeElement).toHaveText('MyIf(More)');
|
||||
componentFixture.debugElement.componentInstance.showMore = true;
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.debugElement.nativeElement).toHaveText('MyIf(More)');
|
||||
});
|
||||
}));
|
||||
|
||||
@@ -268,9 +268,9 @@ export function main() {
|
||||
|
||||
return tcb.overrideTemplate(MockChildComp, '<span>Mock</span>')
|
||||
.createAsync(MockChildComp)
|
||||
.then((rootTestComponent) => {
|
||||
rootTestComponent.detectChanges();
|
||||
expect(rootTestComponent.debugElement.nativeElement).toHaveText('Mock');
|
||||
.then((componentFixture) => {
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.debugElement.nativeElement).toHaveText('Mock');
|
||||
|
||||
});
|
||||
}));
|
||||
@@ -282,9 +282,9 @@ export function main() {
|
||||
ChildComp,
|
||||
new ViewMetadata({template: '<span>Modified {{childBinding}}</span>'}))
|
||||
.createAsync(ChildComp)
|
||||
.then((rootTestComponent) => {
|
||||
rootTestComponent.detectChanges();
|
||||
expect(rootTestComponent.debugElement.nativeElement).toHaveText('Modified Child');
|
||||
.then((componentFixture) => {
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.debugElement.nativeElement).toHaveText('Modified Child');
|
||||
|
||||
});
|
||||
}));
|
||||
@@ -294,9 +294,9 @@ export function main() {
|
||||
|
||||
return tcb.overrideDirective(ParentComp, ChildComp, MockChildComp)
|
||||
.createAsync(ParentComp)
|
||||
.then((rootTestComponent) => {
|
||||
rootTestComponent.detectChanges();
|
||||
expect(rootTestComponent.debugElement.nativeElement).toHaveText('Parent(Mock)');
|
||||
.then((componentFixture) => {
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.debugElement.nativeElement).toHaveText('Parent(Mock)');
|
||||
|
||||
});
|
||||
}));
|
||||
@@ -308,9 +308,9 @@ export function main() {
|
||||
return tcb.overrideDirective(ParentComp, ChildComp, ChildWithChildComp)
|
||||
.overrideDirective(ChildWithChildComp, ChildChildComp, MockChildChildComp)
|
||||
.createAsync(ParentComp)
|
||||
.then((rootTestComponent) => {
|
||||
rootTestComponent.detectChanges();
|
||||
expect(rootTestComponent.debugElement.nativeElement)
|
||||
.then((componentFixture) => {
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.debugElement.nativeElement)
|
||||
.toHaveText('Parent(Original Child(ChildChild Mock))');
|
||||
|
||||
});
|
||||
@@ -322,9 +322,9 @@ export function main() {
|
||||
return tcb.overrideProviders(TestProvidersComp,
|
||||
[bind(FancyService).toClass(MockFancyService)])
|
||||
.createAsync(TestProvidersComp)
|
||||
.then((rootTestComponent) => {
|
||||
rootTestComponent.detectChanges();
|
||||
expect(rootTestComponent.debugElement.nativeElement)
|
||||
.then((componentFixture) => {
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.debugElement.nativeElement)
|
||||
.toHaveText('injected value: mocked out value');
|
||||
});
|
||||
}));
|
||||
@@ -336,9 +336,9 @@ export function main() {
|
||||
return tcb.overrideViewProviders(TestViewProvidersComp,
|
||||
[bind(FancyService).toClass(MockFancyService)])
|
||||
.createAsync(TestViewProvidersComp)
|
||||
.then((rootTestComponent) => {
|
||||
rootTestComponent.detectChanges();
|
||||
expect(rootTestComponent.debugElement.nativeElement)
|
||||
.then((componentFixture) => {
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.debugElement.nativeElement)
|
||||
.toHaveText('injected value: mocked out value');
|
||||
});
|
||||
}));
|
||||
|
||||
@@ -138,12 +138,12 @@ export function main() {
|
||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||
tcb.overrideView(MyComp, new ViewMetadata({template: '<div>{{ctxProp}}</div>'}))
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
var renderEl = getRenderElement(rootTC.debugElement.elementRef);
|
||||
.then((fixture) => {
|
||||
var renderEl = getRenderElement(fixture.debugElement.elementRef);
|
||||
expect(renderEl).toHaveText('');
|
||||
|
||||
rootTC.debugElement.componentInstance.ctxProp = 'Hello World!';
|
||||
rootTC.detectChanges();
|
||||
fixture.debugElement.componentInstance.ctxProp = 'Hello World!';
|
||||
fixture.detectChanges();
|
||||
expect(renderEl).toHaveText('Hello World!');
|
||||
async.done();
|
||||
|
||||
@@ -156,7 +156,7 @@ export function main() {
|
||||
tcb.overrideView(MyComp, new ViewMetadata(
|
||||
{template: '<input [title]="y" style="position:absolute">'}))
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
.then((fixture) => {
|
||||
var checkSetters = (elr) => {
|
||||
var el = getRenderElement(elr);
|
||||
renderer.setElementProperty(elr, 'tabIndex', 1);
|
||||
@@ -177,9 +177,9 @@ export function main() {
|
||||
};
|
||||
|
||||
// root element
|
||||
checkSetters(rootTC.debugElement.elementRef);
|
||||
checkSetters(fixture.debugElement.elementRef);
|
||||
// nested elements
|
||||
checkSetters(rootTC.debugElement.componentViewChildren[0].elementRef);
|
||||
checkSetters(fixture.debugElement.componentViewChildren[0].elementRef);
|
||||
|
||||
async.done();
|
||||
});
|
||||
@@ -192,17 +192,17 @@ export function main() {
|
||||
directives: [NgIf]
|
||||
}))
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
.then((fixture) => {
|
||||
|
||||
var rootEl = getRenderElement(rootTC.debugElement.elementRef);
|
||||
var rootEl = getRenderElement(fixture.debugElement.elementRef);
|
||||
expect(rootEl).toHaveText('');
|
||||
|
||||
rootTC.debugElement.componentInstance.ctxBoolProp = true;
|
||||
rootTC.detectChanges();
|
||||
fixture.debugElement.componentInstance.ctxBoolProp = true;
|
||||
fixture.detectChanges();
|
||||
expect(rootEl).toHaveText('hello');
|
||||
|
||||
rootTC.debugElement.componentInstance.ctxBoolProp = false;
|
||||
rootTC.detectChanges();
|
||||
fixture.debugElement.componentInstance.ctxBoolProp = false;
|
||||
fixture.detectChanges();
|
||||
expect(rootEl).toHaveText('');
|
||||
|
||||
async.done();
|
||||
@@ -216,8 +216,8 @@ export function main() {
|
||||
tcb.overrideView(MyComp,
|
||||
new ViewMetadata({template: '<input [title]="y"></input>'}))
|
||||
.createAsync(MyComp)
|
||||
.then((rootTC) => {
|
||||
var elRef = rootTC.debugElement.componentViewChildren[0].elementRef;
|
||||
.then((fixture) => {
|
||||
var elRef = fixture.debugElement.componentViewChildren[0].elementRef;
|
||||
renderer.invokeElementMethod(elRef, 'setAttribute', ['a', 'b']);
|
||||
|
||||
expect(DOM.getAttribute(getRenderElement(elRef), 'a')).toEqual('b');
|
||||
|
||||
@@ -7,6 +7,6 @@
|
||||
*
|
||||
*/
|
||||
export * from './src/testing/testing';
|
||||
export {RootTestComponent, TestComponentBuilder} from './src/testing/test_component_builder';
|
||||
export {ComponentFixture, TestComponentBuilder} from './src/testing/test_component_builder';
|
||||
export * from './src/testing/test_injector';
|
||||
export * from './src/testing/fake_async';
|
||||
|
||||
@@ -36,10 +36,9 @@ export function main() {
|
||||
|
||||
describe('button[md-button]', () => {
|
||||
it('should handle a click on the button', inject([AsyncTestCompleter], (async) => {
|
||||
builder.createAsync(TestApp).then(rootTestComponent => {
|
||||
let testComponent = rootTestComponent.debugElement.componentInstance;
|
||||
let buttonDebugElement =
|
||||
getChildDebugElement(rootTestComponent.debugElement, 'button');
|
||||
builder.createAsync(TestApp).then(fixture => {
|
||||
let testComponent = fixture.debugElement.componentInstance;
|
||||
let buttonDebugElement = getChildDebugElement(fixture.debugElement, 'button');
|
||||
|
||||
buttonDebugElement.nativeElement.click();
|
||||
expect(testComponent.clickCount).toBe(1);
|
||||
@@ -49,10 +48,9 @@ export function main() {
|
||||
}), 1000);
|
||||
|
||||
it('should disable the button', inject([AsyncTestCompleter], (async) => {
|
||||
builder.createAsync(TestApp).then(rootTestComponent => {
|
||||
let testAppComponent = rootTestComponent.debugElement.componentInstance;
|
||||
let buttonDebugElement =
|
||||
getChildDebugElement(rootTestComponent.debugElement, 'button');
|
||||
builder.createAsync(TestApp).then(fixture => {
|
||||
let testAppComponent = fixture.debugElement.componentInstance;
|
||||
let buttonDebugElement = getChildDebugElement(fixture.debugElement, 'button');
|
||||
let buttonElement = buttonDebugElement.nativeElement;
|
||||
|
||||
// The button should initially be enabled.
|
||||
@@ -60,7 +58,7 @@ export function main() {
|
||||
|
||||
// After the disabled binding has been changed.
|
||||
testAppComponent.isDisabled = true;
|
||||
rootTestComponent.detectChanges();
|
||||
fixture.detectChanges();
|
||||
|
||||
// The button should should now be disabled.
|
||||
expect(buttonElement.disabled).toBe(true);
|
||||
@@ -82,9 +80,9 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should remove disabled anchors from tab order', inject([AsyncTestCompleter], (async) => {
|
||||
builder.createAsync(TestApp).then(rootTestComponent => {
|
||||
let testAppComponent = rootTestComponent.debugElement.componentInstance;
|
||||
let anchorDebugElement = getChildDebugElement(rootTestComponent.debugElement, 'a');
|
||||
builder.createAsync(TestApp).then(fixture => {
|
||||
let testAppComponent = fixture.debugElement.componentInstance;
|
||||
let anchorDebugElement = getChildDebugElement(fixture.debugElement, 'a');
|
||||
let anchorElement = anchorDebugElement.nativeElement;
|
||||
|
||||
// The anchor should initially be in the tab order.
|
||||
@@ -92,7 +90,7 @@ export function main() {
|
||||
|
||||
// After the disabled binding has been changed.
|
||||
testAppComponent.isDisabled = true;
|
||||
rootTestComponent.detectChanges();
|
||||
fixture.detectChanges();
|
||||
|
||||
// The anchor should now be out of the tab order.
|
||||
expect(anchorElement.tabIndex).toBe(-1);
|
||||
|
||||
Reference in New Issue
Block a user