fix(Typings): Remove public exports added in 1926335b85

Closes #4147
This commit is contained in:
Jason Teplitz 2015-09-11 13:45:31 -07:00 committed by Misko Hevery
parent 0246b2a2cb
commit 787d1f955f
51 changed files with 943 additions and 868 deletions

View File

@ -60,27 +60,21 @@ module.exports = new Package('angular-v2-docs', [jsdocPackage, nunjucksPackage,
{
id: 'angular2/router',
references: ['./angular2.d.ts'],
remapTypes: {Type: 'ng.Type'},
remapTypes: {Type: 'ng.Type', InjectableReference: 'ng.InjectableReference'},
modules: {'angular2/router': {namespace: 'ngRouter', id: 'angular2/router'}}
},
{
id: 'angular2/http',
references: ['./angular2.d.ts'],
remapTypes: {Type: 'ng.Type', Observable: 'ng.Observable', EventEmitter: 'ng.EventEmitter'},
remapTypes: {Type: 'ng.Type', Observable: 'ng.Observable', EventEmitter: 'ng.EventEmitter', InjectableReference: 'ng.InjectableReference' },
modules: {'angular2/http': {namespace: 'ngHttp', id: 'angular2/http'}}
},
{
id: 'angular2/test_lib',
references: ['./angular2.d.ts', '../jasmine/jasmine.d.ts'],
remapTypes: {
Type: 'ng.Type',
Binding: 'ng.Binding',
ViewMetadata: 'ng.ViewMetadata',
Injector: 'ng.Injector',
Predicate: 'ng.Predicate',
ElementRef: 'ng.ElementRef',
DebugElement: 'ng.DebugElement'
},
remapTypes: { Type: 'ng.Type', Binding: 'ng.Binding', ViewMetadata: 'ng.ViewMetadata', Injector: 'ng.Injector',
Predicate: 'ng.Predicate', ElementRef: 'ng.ElementRef', DebugElement: 'ng.DebugElement',
InjectableReference: 'ng.InjectableReference' },
modules: {'angular2/test_lib': {namespace: 'ngTestLib', id: 'angular2/test_lib'}}
}
];

View File

@ -19,8 +19,3 @@ export * from './src/core/directives';
export * from './src/core/forms';
export * from './src/core/debug';
export * from './src/core/change_detection';
export {Reflector, ReflectionInfo} from './src/core/reflection/reflection';
export {
PlatformReflectionCapabilities
} from './src/core/reflection/platform_reflection_capabilities';
export {SetterFn, GetterFn, MethodFn} from './src/core/reflection/types';

View File

@ -30,7 +30,6 @@ export {BaseRequestOptions, RequestOptions} from './src/http/base_request_option
export {BaseResponseOptions, ResponseOptions} from './src/http/base_response_options';
export {XHRBackend, XHRConnection} from './src/http/backends/xhr_backend';
export {JSONPBackend, JSONPConnection} from './src/http/backends/jsonp_backend';
export {BrowserJsonp} from './src/http/backends/browser_jsonp';
export {Http, Jsonp} from './src/http/http';
export {Headers} from './src/http/headers';

View File

@ -7,47 +7,12 @@
export {Router, RootRouter} from './src/router/router';
export {RouterOutlet} from './src/router/router_outlet';
export {
DynamicComponentLoader,
ComponentRef,
ElementRef,
Compiler,
AppViewManager,
ViewRef,
HostViewRef,
ProtoViewRef,
ViewContainerRef,
TemplateRef
} from './core';
export {
Renderer,
RenderElementRef,
RenderViewRef,
RenderProtoViewRef,
RenderEventDispatcher,
RenderFragmentRef,
RenderViewWithFragments
} from './render';
export {
Binding,
Injector,
ResolvedBinding,
Key,
Dependency,
ProtoInjector,
DependencyProvider,
BindingWithVisibility,
Visibility,
ResolvedFactory
} from './src/core/di';
export {RouterLink} from './src/router/router_link';
export {RouteParams} from './src/router/instruction';
export {RouteRegistry} from './src/router/route_registry';
export {LocationStrategy} from './src/router/location_strategy';
export {HashLocationStrategy} from './src/router/hash_location_strategy';
export {PathLocationStrategy} from './src/router/path_location_strategy';
export {PathRecognizer, PathMatch} from './src/router/path_recognizer';
export {RouteHandler} from './src/router/route_handler';
export {Location, APP_BASE_HREF} from './src/router/location';
export {Pipeline} from './src/router/pipeline';
export * from './src/router/route_config_decorator';
@ -108,8 +73,6 @@ export const ROUTER_BINDINGS: any[] = CONST_EXPR([
}))
]);
export interface InjectableReference {}
function routerFactory(registry, pipeline, location, appRoot) {
return new RootRouter(registry, pipeline, location, appRoot);
}

View File

@ -22,13 +22,6 @@ export {
IterableDifferFactory,
KeyValueDiffers,
KeyValueDiffer,
KeyValueDifferFactory,
Lexer,
Parser,
ChangeDispatcher,
BindingTarget,
DirectiveIndex,
DebugContext,
ProtoChangeDetector
} from 'angular2/src/core/change_detection/change_detection';
export * from 'angular2/src/core/change_detection/parser/ast';
KeyValueDifferFactory
} from './change_detection/change_detection';

View File

@ -14,7 +14,15 @@ import {
import {Injector, Inject, Injectable, OpaqueToken, Optional, Binding} from 'angular2/src/core/di';
import {StringMap, StringMapWrapper} from 'angular2/src/core/facade/collection';
import {CONST, CONST_EXPR, isPresent, assertionsEnabled} from 'angular2/src/core/facade/lang';
export * from './parser/ast';
export {
ASTWithSource,
AST,
AstTransformer,
PropertyRead,
LiteralArray,
ImplicitReceiver
} from './parser/ast';
export {Lexer} from './parser/lexer';
export {Parser} from './parser/parser';

View File

@ -19,14 +19,4 @@ export {ElementRef} from './compiler/element_ref';
export {TemplateRef} from './compiler/template_ref';
export {ViewRef, HostViewRef, ProtoViewRef} from './compiler/view_ref';
export {ViewContainerRef} from './compiler/view_container_ref';
export {AppView, AppProtoView, AppProtoViewMergeMapping, AppViewContainer} from './compiler/view';
export {ComponentRef} from './compiler/dynamic_component_loader';
export {
ElementInjector,
PreBuiltObjects,
TreeNode,
ProtoElementInjector,
DirectiveBinding,
EventEmitterAccessor
} from './compiler/element_injector';
export {ElementBinder} from './compiler/element_binder';

View File

@ -16,14 +16,13 @@ import {ElementRef} from 'angular2/src/core/compiler/element_ref';
export class DebugElement {
_elementInjector: ElementInjector;
/**
* @private
*/
constructor(private _parentView: AppView, private _boundElementIndex: number) {
this._elementInjector = this._parentView.elementInjectors[this._boundElementIndex];
}
static create(elementRef: ElementRef): DebugElement {
return new DebugElement(internalView(elementRef.parentView), elementRef.boundElementIndex);
}
get componentInstance(): any {
if (!isPresent(this._elementInjector)) {
return null;
@ -144,7 +143,7 @@ export class DebugElement {
* @return {DebugElement}
*/
export function inspectElement(elementRef: ElementRef): DebugElement {
return DebugElement.create(elementRef);
return new DebugElement(internalView(elementRef.parentView), elementRef.boundElementIndex);
}
export function asNativeElements(arr: DebugElement[]): any[] {

View File

@ -12,5 +12,3 @@ export {LimitToPipe} from './pipes/limit_to_pipe';
export {LowerCasePipe} from './pipes/lowercase_pipe';
export {NumberPipe, DecimalPipe, PercentPipe, CurrencyPipe} from './pipes/number_pipe';
export {UpperCasePipe} from './pipes/uppercase_pipe';
export {ProtoPipes} from './pipes/pipes';
export {PipeBinding} from './pipes/pipe_binding';

View File

@ -12,12 +12,5 @@ export {
ViewDefinition,
DOCUMENT,
APP_ID,
MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE,
EventManager,
SharedStylesHost,
DomSharedStylesHost,
TemplateCloner,
ViewType,
RenderProtoViewMergeMapping,
EventManagerPlugin
MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE
} from './render/render';

View File

@ -38,6 +38,9 @@ const REFLECT_PREFIX: string = 'ng-reflect-';
export class DomRenderer extends Renderer {
_document;
/**
* @private
*/
constructor(private _eventManager: EventManager,
private _domSharedStylesHost: DomSharedStylesHost,
private _templateCloner: TemplateCloner, @Inject(DOCUMENT) document) {

View File

@ -10,7 +10,4 @@ export * from './dom/compiler/compiler';
export * from './dom/dom_renderer';
export * from './dom/dom_tokens';
export * from './dom/template_cloner';
export * from './dom/events/event_manager';
export * from './dom/view/shared_styles_host';
export * from './dom/template_cloner';
export * from './api';

View File

@ -18,6 +18,9 @@ export class JSONPConnection implements Connection {
private _responseData: any;
private _finished: boolean = false;
/**
* @private
*/
constructor(req: Request, private _dom: BrowserJsonp,
private baseResponseOptions?: ResponseOptions) {
if (req.method !== RequestMethods.Get) {
@ -91,6 +94,9 @@ export class JSONPConnection implements Connection {
@Injectable()
export class JSONPBackend implements ConnectionBackend {
/**
* @private
*/
constructor(private _browserJSONP: BrowserJsonp, private _baseResponseOptions: ResponseOptions) {}
createConnection(request: Request): JSONPConnection {
return new JSONPConnection(request, this._browserJSONP, this._baseResponseOptions);

View File

@ -92,6 +92,9 @@ function stringifyAux(instruction: Instruction): string {
export class ComponentInstruction {
reuse: boolean = false;
/**
* @private
*/
constructor(public urlPath: string, public urlParams: string[],
private _recognizer: PathRecognizer, public params: StringMap<string, any> = null) {}

View File

@ -31,6 +31,9 @@ export class RouterOutlet {
private _componentRef: ComponentRef = null;
private _currentInstruction: ComponentInstruction = null;
/**
* @private
*/
constructor(private _elementRef: ElementRef, private _loader: DynamicComponentLoader,
private _parentRouter: routerMod.Router, @Attribute('name') nameAttr: string) {
if (isPresent(nameAttr)) {

View File

@ -22,12 +22,16 @@ import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {DebugElement} from 'angular2/src/core/debug/debug_element';
export class RootTestComponent extends DebugElement {
export class RootTestComponent {
_componentRef: ComponentRef;
_componentParentView: AppView;
debugElement: DebugElement;
/**
* @private
*/
constructor(componentRef: ComponentRef) {
super(internalView(<ViewRef>componentRef.hostView), 0);
this.debugElement = new DebugElement(internalView(<ViewRef>componentRef.hostView), 0);
this._componentParentView = internalView(<ViewRef>componentRef.hostView);
this._componentRef = componentRef;

View File

@ -16,6 +16,9 @@ export {Type} from "angular2/src/core/facade/lang";
@Injectable()
export class ClientMessageBrokerFactory {
/**
* @private
*/
constructor(private _messageBus: MessageBus, protected _serializer: Serializer) {}
/**
@ -31,6 +34,9 @@ export class ClientMessageBroker {
private _pending: Map<string, PromiseCompleter<any>> = new Map<string, PromiseCompleter<any>>();
private _sink: EventEmitter;
/**
* @private
*/
constructor(messageBus: MessageBus, protected _serializer: Serializer, public channel) {
this._sink = messageBus.to(channel);
var source = messageBus.from(channel);

View File

@ -12,6 +12,9 @@ import {
@Injectable()
export class ServiceMessageBrokerFactory {
/**
* @private
*/
constructor(private _messageBus: MessageBus, protected _serializer: Serializer) {}
/**
@ -33,6 +36,9 @@ export class ServiceMessageBroker {
private _sink: EventEmitter;
private _methods: Map<string, Function> = new Map<string, Function>();
/**
* @private
*/
constructor(messageBus: MessageBus, private _serializer: Serializer, public channel) {
this._sink = messageBus.to(channel);
var source = messageBus.from(channel);

View File

@ -29,41 +29,42 @@ export function main() {
describe('DynamicComponentLoader', function() {
describe("loading into a location", () => {
it('should work',
inject([DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter],
(loader, tcb: TestComponentBuilder, async) => {
tcb.overrideView(
MyComp,
new ViewMetadata(
{template: '<location #loc></location>', directives: [Location]}))
.createAsync(MyComp)
.then((tc) => {
inject(
[DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter],
(loader, tcb: TestComponentBuilder, async) => {
tcb.overrideView(
MyComp, new ViewMetadata(
{template: '<location #loc></location>', directives: [Location]}))
.createAsync(MyComp)
.then((tc) => {
loader.loadIntoLocation(DynamicallyLoaded, tc.elementRef, 'loc')
.then(ref => {
expect(tc.nativeElement).toHaveText("Location;DynamicallyLoaded;");
async.done();
});
});
}));
loader.loadIntoLocation(DynamicallyLoaded, tc.debugElement.elementRef, 'loc')
.then(ref => {
expect(tc.debugElement.nativeElement)
.toHaveText("Location;DynamicallyLoaded;");
async.done();
});
});
}));
it('should return a disposable component ref',
inject([DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter],
(loader, tcb: TestComponentBuilder, async) => {
tcb.overrideView(
MyComp,
new ViewMetadata(
{template: '<location #loc></location>', directives: [Location]}))
.createAsync(MyComp)
.then((tc) => {
inject(
[DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter],
(loader, tcb: TestComponentBuilder, async) => {
tcb.overrideView(
MyComp, new ViewMetadata(
{template: '<location #loc></location>', directives: [Location]}))
.createAsync(MyComp)
.then((tc) => {
loader.loadIntoLocation(DynamicallyLoaded, tc.elementRef, 'loc')
.then(ref => {
ref.dispose();
expect(tc.nativeElement).toHaveText("Location;");
async.done();
});
});
}));
loader.loadIntoLocation(DynamicallyLoaded, tc.debugElement.elementRef, 'loc')
.then(ref => {
ref.dispose();
expect(tc.debugElement.nativeElement).toHaveText("Location;");
async.done();
});
});
}));
it('should allow to dispose even if the location has been removed',
inject([DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter],
@ -78,45 +79,48 @@ export function main() {
{template: '<location #loc></location>', directives: [Location]}))
.createAsync(MyComp)
.then((tc) => {
tc.componentInstance.ctxBoolProp = true;
tc.debugElement.componentInstance.ctxBoolProp = true;
tc.detectChanges();
var childCompEl = tc.query(By.css('child-cmp'));
var childCompEl = tc.debugElement.query(By.css('child-cmp'));
loader.loadIntoLocation(DynamicallyLoaded, childCompEl.elementRef, 'loc')
.then(ref => {
expect(tc.nativeElement).toHaveText("Location;DynamicallyLoaded;");
expect(tc.debugElement.nativeElement)
.toHaveText("Location;DynamicallyLoaded;");
tc.componentInstance.ctxBoolProp = false;
tc.debugElement.componentInstance.ctxBoolProp = false;
tc.detectChanges();
expect(tc.nativeElement).toHaveText("");
expect(tc.debugElement.nativeElement).toHaveText("");
ref.dispose();
expect(tc.nativeElement).toHaveText("");
expect(tc.debugElement.nativeElement).toHaveText("");
async.done();
});
});
}));
it('should update host properties',
inject(
[DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter],
(loader, tcb: TestComponentBuilder, async) => {
tcb.overrideView(
MyComp, new ViewMetadata(
{template: '<location #loc></location>', directives: [Location]}))
.createAsync(MyComp)
.then((tc) => {
loader.loadIntoLocation(DynamicallyLoadedWithHostProps, tc.elementRef, 'loc')
.then(ref => {
ref.instance.id = "new value";
inject([DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter],
(loader, tcb: TestComponentBuilder, async) => {
tcb.overrideView(
MyComp,
new ViewMetadata(
{template: '<location #loc></location>', directives: [Location]}))
.createAsync(MyComp)
.then((tc) => {
loader.loadIntoLocation(DynamicallyLoadedWithHostProps,
tc.debugElement.elementRef, 'loc')
.then(ref => {
ref.instance.id = "new value";
tc.detectChanges();
tc.detectChanges();
var newlyInsertedElement = DOM.childNodes(tc.nativeElement)[1];
expect((<HTMLElement>newlyInsertedElement).id).toEqual("new value");
async.done();
});
});
}));
var newlyInsertedElement =
DOM.childNodes(tc.debugElement.nativeElement)[1];
expect((<HTMLElement>newlyInsertedElement).id).toEqual("new value");
async.done();
});
});
}));
it('should throw if the variable does not exist',
inject([DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter],
@ -128,7 +132,8 @@ export function main() {
.createAsync(MyComp)
.then((tc) => {
expect(() => loader.loadIntoLocation(DynamicallyLoadedWithHostProps,
tc.elementRef, 'someUnknownVariable'))
tc.debugElement.elementRef,
'someUnknownVariable'))
.toThrowError('Could not find variable someUnknownVariable');
async.done();
});
@ -136,59 +141,60 @@ export function main() {
});
describe("loading next to a location", () => {
it('should work', inject([DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter],
(loader, tcb: TestComponentBuilder, async) => {
tcb.overrideView(
MyComp, new ViewMetadata({
template: '<div><location #loc></location></div>',
directives: [Location]
}))
.createAsync(MyComp)
.then((tc) => {
loader.loadNextToLocation(DynamicallyLoaded, tc.elementRef)
.then(ref => {
expect(tc.nativeElement).toHaveText("Location;");
expect(DOM.nextSibling(tc.nativeElement))
.toHaveText('DynamicallyLoaded;');
async.done();
});
});
}));
it('should return a disposable component ref',
it('should work',
inject([DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter],
(loader, tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new ViewMetadata({
template: '<div><location #loc></location></div>',
directives: [Location]
}))
.
createAsync(MyComp)
.createAsync(MyComp)
.then((tc) => {
loader.loadNextToLocation(DynamicallyLoaded, tc.elementRef)
loader.loadNextToLocation(DynamicallyLoaded, tc.debugElement.elementRef)
.then(ref => {
loader.loadNextToLocation(DynamicallyLoaded2, tc.elementRef)
.then(ref2 => {
var firstSibling = DOM.nextSibling(tc.nativeElement);
var secondSibling = DOM.nextSibling(firstSibling);
expect(tc.nativeElement).toHaveText("Location;");
expect(firstSibling).toHaveText("DynamicallyLoaded;");
expect(secondSibling).toHaveText("DynamicallyLoaded2;");
expect(tc.debugElement.nativeElement).toHaveText("Location;");
expect(DOM.nextSibling(tc.debugElement.nativeElement))
.toHaveText('DynamicallyLoaded;');
ref2.dispose();
firstSibling = DOM.nextSibling(tc.nativeElement);
secondSibling = DOM.nextSibling(firstSibling);
expect(secondSibling).toBeNull();
async.done();
});
async.done();
});
});
}));
it('should return a disposable component ref',
inject(
[DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter],
(loader, tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new ViewMetadata({
template: '<div><location #loc></location></div>',
directives: [Location]
}))
.
createAsync(MyComp)
.then((tc) => {
loader.loadNextToLocation(DynamicallyLoaded, tc.debugElement.elementRef)
.then(ref => {
loader.loadNextToLocation(DynamicallyLoaded2, tc.debugElement.elementRef)
.then(ref2 => {
var firstSibling = DOM.nextSibling(tc.debugElement.nativeElement);
var secondSibling = DOM.nextSibling(firstSibling);
expect(tc.debugElement.nativeElement).toHaveText("Location;");
expect(firstSibling).toHaveText("DynamicallyLoaded;");
expect(secondSibling).toHaveText("DynamicallyLoaded2;");
ref2.dispose();
firstSibling = DOM.nextSibling(tc.debugElement.nativeElement);
secondSibling = DOM.nextSibling(firstSibling);
expect(secondSibling).toBeNull();
async.done();
});
});
});
}));
it('should update host properties',
inject([DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter],
(loader, tcb: TestComponentBuilder, async) => {
@ -200,13 +206,15 @@ export function main() {
.createAsync(MyComp)
.then((tc) => {
loader.loadNextToLocation(DynamicallyLoadedWithHostProps, tc.elementRef)
loader.loadNextToLocation(DynamicallyLoadedWithHostProps,
tc.debugElement.elementRef)
.then(ref => {
ref.instance.id = "new value";
tc.detectChanges();
var newlyInsertedElement = DOM.nextSibling(tc.nativeElement);
var newlyInsertedElement =
DOM.nextSibling(tc.debugElement.nativeElement);
expect((<HTMLElement>newlyInsertedElement).id).toEqual("new value");
async.done();

View File

@ -56,7 +56,7 @@ main() {
.createAsync(Dummy)
.then((tc) {
tc.detectChanges();
expect(asNativeElements(tc.componentViewChildren))
expect(asNativeElements(tc.debugElement.componentViewChildren))
.toHaveText('[Hello, World]');
async.done();
});
@ -112,7 +112,7 @@ main() {
.createAsync(Dummy)
.then((tc) {
tc.detectChanges();
expect(asNativeElements(tc.componentViewChildren))
expect(asNativeElements(tc.debugElement.componentViewChildren))
.toHaveText('prop:foo-prop;map:foo-map');
async.done();
});
@ -149,7 +149,7 @@ main() {
.createAsync(Dummy)
.then((tc) {
tc.detectChanges();
var cmp = tc.componentViewChildren[0].inject(OnChangeComponent);
var cmp = tc.debugElement.componentViewChildren[0].inject(OnChangeComponent);
expect(cmp.prop).toEqual('hello');
expect(cmp.changes.containsKey('prop')).toEqual(true);
async.done();
@ -171,19 +171,19 @@ main() {
directives: [ComponentWithObservableList]))
.createAsync(Dummy)
.then((tc) {
tc.componentInstance.value = new ObservableList.from([1, 2]);
tc.debugElement.componentInstance.value = new ObservableList.from([1, 2]);
tc.detectChanges();
expect(log.result()).toEqual("check");
expect(asNativeElements(tc.componentViewChildren)).toHaveText('12');
expect(asNativeElements(tc.debugElement.componentViewChildren)).toHaveText('12');
tc.detectChanges();
// we did not change the list => no checks
expect(log.result()).toEqual("check");
tc.componentInstance.value.add(3);
tc.debugElement.componentInstance.value.add(3);
flushMicrotasks();
@ -191,16 +191,16 @@ main() {
// we changed the list => a check
expect(log.result()).toEqual("check; check");
expect(asNativeElements(tc.componentViewChildren))
expect(asNativeElements(tc.debugElement.componentViewChildren))
.toHaveText('123');
// we replaced the list => a check
tc.componentInstance.value = new ObservableList.from([5, 6, 7]);
tc.debugElement.componentInstance.value = new ObservableList.from([5, 6, 7]);
tc.detectChanges();
expect(log.result()).toEqual("check; check; check");
expect(asNativeElements(tc.componentViewChildren))
expect(asNativeElements(tc.debugElement.componentViewChildren))
.toHaveText('567');
});
})));

View File

@ -17,7 +17,8 @@ import {
TestComponentBuilder,
fakeAsync,
tick,
clearPendingTimers
clearPendingTimers,
RootTestComponent
} from 'angular2/test_lib';
@ -105,10 +106,10 @@ export function main() {
tcb.overrideView(MyComp, new ViewMetadata({template: '<div>{{ctxProp}}</div>'}))
.createAsync(MyComp)
.then((rootTC) => {
rootTC.componentInstance.ctxProp = 'Hello World!';
rootTC.debugElement.componentInstance.ctxProp = 'Hello World!';
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('Hello World!');
expect(rootTC.debugElement.nativeElement).toHaveText('Hello World!');
async.done();
});
@ -119,10 +120,10 @@ export function main() {
tcb.overrideView(MyComp, new ViewMetadata({template: '<div>{{null}}{{ctxProp}}</div>'}))
.createAsync(MyComp)
.then((rootTC) => {
rootTC.componentInstance.ctxProp = null;
rootTC.debugElement.componentInstance.ctxProp = null;
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('');
expect(rootTC.debugElement.nativeElement).toHaveText('');
async.done();
});
}));
@ -133,10 +134,11 @@ export function main() {
.createAsync(MyComp)
.then((rootTC) => {
rootTC.componentInstance.ctxProp = 'Hello World!';
rootTC.debugElement.componentInstance.ctxProp = 'Hello World!';
rootTC.detectChanges();
expect(rootTC.componentViewChildren[0].nativeElement.id).toEqual('Hello World!');
expect(rootTC.debugElement.componentViewChildren[0].nativeElement.id)
.toEqual('Hello World!');
async.done();
});
}));
@ -149,16 +151,16 @@ export function main() {
.createAsync(MyComp)
.then((rootTC) => {
rootTC.componentInstance.ctxProp = 'Initial aria label';
rootTC.debugElement.componentInstance.ctxProp = 'Initial aria label';
rootTC.detectChanges();
expect(
DOM.getAttribute(rootTC.componentViewChildren[0].nativeElement, 'aria-label'))
expect(DOM.getAttribute(rootTC.debugElement.componentViewChildren[0].nativeElement,
'aria-label'))
.toEqual('Initial aria label');
rootTC.componentInstance.ctxProp = 'Changed aria label';
rootTC.debugElement.componentInstance.ctxProp = 'Changed aria label';
rootTC.detectChanges();
expect(
DOM.getAttribute(rootTC.componentViewChildren[0].nativeElement, 'aria-label'))
expect(DOM.getAttribute(rootTC.debugElement.componentViewChildren[0].nativeElement,
'aria-label'))
.toEqual('Changed aria label');
async.done();
@ -174,11 +176,13 @@ export function main() {
.then((rootTC) => {
rootTC.detectChanges();
expect(rootTC.componentViewChildren[0].nativeElement.tabIndex).toEqual(0);
expect(rootTC.debugElement.componentViewChildren[0].nativeElement.tabIndex)
.toEqual(0);
rootTC.componentInstance.ctxNumProp = 5;
rootTC.debugElement.componentInstance.ctxNumProp = 5;
rootTC.detectChanges();
expect(rootTC.componentViewChildren[0].nativeElement.tabIndex).toEqual(5);
expect(rootTC.debugElement.componentViewChildren[0].nativeElement.tabIndex)
.toEqual(5);
async.done();
});
@ -193,11 +197,13 @@ export function main() {
.then((rootTC) => {
rootTC.detectChanges();
expect(rootTC.componentViewChildren[0].nativeElement.readOnly).toBeFalsy();
expect(rootTC.debugElement.componentViewChildren[0].nativeElement.readOnly)
.toBeFalsy();
rootTC.componentInstance.ctxBoolProp = true;
rootTC.debugElement.componentInstance.ctxBoolProp = true;
rootTC.detectChanges();
expect(rootTC.componentViewChildren[0].nativeElement.readOnly).toBeTruthy();
expect(rootTC.debugElement.componentViewChildren[0].nativeElement.readOnly)
.toBeTruthy();
async.done();
});
@ -211,14 +217,16 @@ export function main() {
.createAsync(MyComp)
.then((rootTC) => {
rootTC.componentInstance.ctxProp = 'Some <span>HTML</span>';
rootTC.debugElement.componentInstance.ctxProp = 'Some <span>HTML</span>';
rootTC.detectChanges();
expect(DOM.getInnerHTML(rootTC.componentViewChildren[0].nativeElement))
expect(
DOM.getInnerHTML(rootTC.debugElement.componentViewChildren[0].nativeElement))
.toEqual('Some <span>HTML</span>');
rootTC.componentInstance.ctxProp = 'Some other <div>HTML</div>';
rootTC.debugElement.componentInstance.ctxProp = 'Some other <div>HTML</div>';
rootTC.detectChanges();
expect(DOM.getInnerHTML(rootTC.componentViewChildren[0].nativeElement))
expect(
DOM.getInnerHTML(rootTC.debugElement.componentViewChildren[0].nativeElement))
.toEqual('Some other <div>HTML</div>');
async.done();
@ -233,8 +241,8 @@ export function main() {
.createAsync(MyComp)
.then((rootTC) => {
var nativeEl = rootTC.componentViewChildren[0].nativeElement;
rootTC.componentInstance.ctxProp = 'foo bar';
var nativeEl = rootTC.debugElement.componentViewChildren[0].nativeElement;
rootTC.debugElement.componentInstance.ctxProp = 'foo bar';
rootTC.detectChanges();
expect(nativeEl).toHaveCssClass('foo');
@ -258,14 +266,16 @@ export function main() {
.createAsync(MyComp)
.then((rootTC) => {
rootTC.componentInstance.ctxProp = 'Hello World!';
rootTC.debugElement.componentInstance.ctxProp = 'Hello World!';
rootTC.detectChanges();
expect(rootTC.componentViewChildren[0].inject(MyDir).dirProp)
expect(rootTC.debugElement.componentViewChildren[0].inject(MyDir).dirProp)
.toEqual('Hello World!');
expect(rootTC.componentViewChildren[1].inject(MyDir).dirProp).toEqual('Hi there!');
expect(rootTC.componentViewChildren[2].inject(MyDir).dirProp).toEqual('Hi there!');
expect(rootTC.componentViewChildren[3].inject(MyDir).dirProp)
expect(rootTC.debugElement.componentViewChildren[1].inject(MyDir).dirProp)
.toEqual('Hi there!');
expect(rootTC.debugElement.componentViewChildren[2].inject(MyDir).dirProp)
.toEqual('Hi there!');
expect(rootTC.debugElement.componentViewChildren[3].inject(MyDir).dirProp)
.toEqual('One more Hello World!');
async.done();
});
@ -284,10 +294,10 @@ export function main() {
.createAsync(MyComp)
.then((rootTC) => {
rootTC.componentInstance.ctxProp = 'a';
rootTC.debugElement.componentInstance.ctxProp = 'a';
rootTC.detectChanges();
var dir = rootTC.componentViewChildren[0].getLocal('dir');
var dir = rootTC.debugElement.componentViewChildren[0].getLocal('dir');
expect(dir.dirProp).toEqual('aa');
async.done();
});
@ -305,7 +315,7 @@ export function main() {
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('hello');
expect(rootTC.debugElement.nativeElement).toHaveText('hello');
async.done();
});
}));
@ -321,10 +331,10 @@ export function main() {
.createAsync(MyComp)
.then((rootTC) => {
rootTC.componentInstance.ctxProp = 'Hello World!';
rootTC.debugElement.componentInstance.ctxProp = 'Hello World!';
rootTC.detectChanges();
var tc = rootTC.componentViewChildren[0];
var tc = rootTC.debugElement.componentViewChildren[0];
expect(tc.inject(MyDir).dirProp).toEqual('Hello World!');
expect(tc.inject(ChildComp).dirProp).toEqual(null);
@ -358,7 +368,7 @@ export function main() {
}))
.createAsync(MyComp)
.then((rootTC) => {
expect(rootTC.nativeElement).toHaveText('noduplicate');
expect(rootTC.debugElement.nativeElement).toHaveText('noduplicate');
async.done();
});
}));
@ -375,7 +385,7 @@ export function main() {
}))
.createAsync(MyComp)
.then((rootTC) => {
expect(rootTC.nativeElement).toHaveText('othernoduplicate');
expect(rootTC.debugElement.nativeElement).toHaveText('othernoduplicate');
async.done();
});
}));
@ -387,14 +397,14 @@ export function main() {
.createAsync(MyComp)
.then((rootTC) => {
var tc = rootTC.componentViewChildren[0];
var tc = rootTC.debugElement.componentViewChildren[0];
var idDir = tc.inject(IdDir);
rootTC.componentInstance.ctxProp = 'some_id';
rootTC.debugElement.componentInstance.ctxProp = 'some_id';
rootTC.detectChanges();
expect(idDir.id).toEqual('some_id');
rootTC.componentInstance.ctxProp = 'other_id';
rootTC.debugElement.componentInstance.ctxProp = 'other_id';
rootTC.detectChanges();
expect(idDir.id).toEqual('other_id');
@ -413,7 +423,7 @@ export function main() {
.then((rootTC) => {
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('hello');
expect(rootTC.debugElement.nativeElement).toHaveText('hello');
async.done();
});
}));
@ -443,7 +453,7 @@ export function main() {
rootTC.detectChanges();
var childNodesOfWrapper = rootTC.componentViewChildren;
var childNodesOfWrapper = rootTC.debugElement.componentViewChildren;
// 1 template + 2 copies.
expect(childNodesOfWrapper.length).toBe(3);
expect(childNodesOfWrapper[1].nativeElement).toHaveText('hello');
@ -465,7 +475,7 @@ export function main() {
.then((rootTC) => {
rootTC.detectChanges();
var childNodesOfWrapper = rootTC.componentViewChildren;
var childNodesOfWrapper = rootTC.debugElement.componentViewChildren;
// 1 template + 2 copies.
expect(childNodesOfWrapper.length).toBe(3);
expect(childNodesOfWrapper[1].nativeElement).toHaveText('hello');
@ -484,10 +494,10 @@ export function main() {
}))
.createAsync(MyComp)
.then((rootTC) => {
rootTC.componentInstance.ctxProp = 'From myComp';
rootTC.debugElement.componentInstance.ctxProp = 'From myComp';
rootTC.detectChanges();
expect(rootTC.nativeElement)
expect(rootTC.debugElement.nativeElement)
.toHaveText(
'TOOLBAR(From myComp,From toolbar,Component with an injected host)');
@ -506,7 +516,7 @@ export function main() {
.createAsync(MyComp)
.then((rootTC) => {
expect(rootTC.componentViewChildren[0].getLocal('alice'))
expect(rootTC.debugElement.componentViewChildren[0].getLocal('alice'))
.toBeAnInstanceOf(ChildComp);
async.done();
@ -522,7 +532,7 @@ export function main() {
.createAsync(MyComp)
.then((rootTC) => {
expect(rootTC.componentViewChildren[0].getLocal('localdir'))
expect(rootTC.debugElement.componentViewChildren[0].getLocal('localdir'))
.toBeAnInstanceOf(ExportDir);
async.done();
@ -543,7 +553,7 @@ export function main() {
.then((rootTC) => {
rootTC.detectChanges();
expect(rootTC.nativeElement)
expect(rootTC.debugElement.nativeElement)
.toHaveText('hellohello'); // this first one is the
// component, the second one is
// the text binding
@ -563,32 +573,33 @@ export function main() {
.createAsync(MyComp)
.then((rootTC) => {
expect(rootTC.componentViewChildren[0].getLocal('alice'))
expect(rootTC.debugElement.componentViewChildren[0].getLocal('alice'))
.toBeAnInstanceOf(ChildComp);
expect(rootTC.componentViewChildren[0].getLocal('bob'))
expect(rootTC.debugElement.componentViewChildren[0].getLocal('bob'))
.toBeAnInstanceOf(ChildComp);
expect(rootTC.componentViewChildren[0].getLocal('alice'))
.not.toBe(rootTC.componentViewChildren[0].getLocal('bob'));
expect(rootTC.debugElement.componentViewChildren[0].getLocal('alice'))
.not.toBe(
rootTC.debugElement.componentViewChildren[0].getLocal('bob'));
async.done();
})}));
it('should assign the component instance to a var- with shorthand syntax',
inject([TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder,
async) => {tcb.overrideView(MyComp, new ViewMetadata({
template: '<child-cmp #alice></child-cmp>',
directives: [ChildComp]
}))
(tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new ViewMetadata({
template: '<child-cmp #alice></child-cmp>',
directives: [ChildComp]
}))
.createAsync(MyComp)
.then((rootTC) => {
.createAsync(MyComp)
.then((rootTC) => {
expect(rootTC.componentViewChildren[0].getLocal('alice'))
.toBeAnInstanceOf(ChildComp);
expect(rootTC.debugElement.componentViewChildren[0].getLocal('alice'))
.toBeAnInstanceOf(ChildComp);
async.done();
})}));
async.done();
})}));
it('should assign the element instance to a user-defined variable',
inject([TestComponentBuilder, AsyncTestCompleter],
@ -600,7 +611,8 @@ export function main() {
.createAsync(MyComp)
.then((rootTC) => {
var value = rootTC.componentViewChildren[0].getLocal('alice');
var value =
rootTC.debugElement.componentViewChildren[0].getLocal('alice');
expect(value).not.toBe(null);
expect(value.tagName.toLowerCase()).toEqual('div');
@ -608,21 +620,21 @@ export function main() {
})}));
it('should change dash-case to camel-case',
inject([TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new ViewMetadata({
template: '<p><child-cmp var-super-alice></child-cmp></p>',
directives: [ChildComp]
}))
inject(
[TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new ViewMetadata({
template: '<p><child-cmp var-super-alice></child-cmp></p>',
directives: [ChildComp]
}))
.createAsync(MyComp)
.then((rootTC) => {
expect(rootTC.componentViewChildren[0].getLocal('superAlice'))
.toBeAnInstanceOf(ChildComp);
.createAsync(MyComp)
.then((rootTC) => {
expect(rootTC.debugElement.componentViewChildren[0].getLocal('superAlice'))
.toBeAnInstanceOf(ChildComp);
async.done();
});
}));
async.done();
});
}));
it('should allow to use variables in a for loop',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder,
@ -639,7 +651,8 @@ export function main() {
rootTC.detectChanges();
// Get the element at index 1, since index 0 is the <template>.
expect(rootTC.componentViewChildren[1].nativeElement).toHaveText("1-hello");
expect(rootTC.debugElement.componentViewChildren[1].nativeElement)
.toHaveText("1-hello");
async.done();
});
@ -659,7 +672,7 @@ export function main() {
.createAsync(MyComp)
.then((rootTC) => {
var cmp = rootTC.componentViewChildren[0].getLocal('cmp');
var cmp = rootTC.debugElement.componentViewChildren[0].getLocal('cmp');
rootTC.detectChanges();
expect(cmp.numberOfChecks).toEqual(1);
@ -685,13 +698,13 @@ export function main() {
.createAsync(MyComp)
.then((rootTC) => {
var cmp = rootTC.componentViewChildren[0].getLocal('cmp');
var cmp = rootTC.debugElement.componentViewChildren[0].getLocal('cmp');
rootTC.componentInstance.ctxProp = "one";
rootTC.debugElement.componentInstance.ctxProp = "one";
rootTC.detectChanges();
expect(cmp.numberOfChecks).toEqual(1);
rootTC.componentInstance.ctxProp = "two";
rootTC.debugElement.componentInstance.ctxProp = "two";
rootTC.detectChanges();
expect(cmp.numberOfChecks).toEqual(2);
@ -711,13 +724,13 @@ export function main() {
.createAsync(MyComp)
.then((rootTC) => {
var cmp = rootTC.componentViewChildren[0].getLocal('cmp');
var cmp = rootTC.debugElement.componentViewChildren[0].getLocal('cmp');
rootTC.componentInstance.ctxProp = "one";
rootTC.debugElement.componentInstance.ctxProp = "one";
rootTC.detectChanges();
expect(cmp.prop).toEqual("one");
rootTC.componentInstance.ctxProp = "two";
rootTC.debugElement.componentInstance.ctxProp = "two";
rootTC.detectChanges();
expect(cmp.prop).toEqual("two");
@ -733,11 +746,11 @@ export function main() {
directives: [[[PushCmpWithAsyncPipe]]]
}));
var rootTC;
var rootTC: RootTestComponent;
tcb.createAsync(MyComp).then(root => { rootTC = root; });
tick();
var cmp = rootTC.componentViewChildren[0].getLocal('cmp');
var cmp = rootTC.debugElement.componentViewChildren[0].getLocal('cmp');
rootTC.detectChanges();
expect(cmp.numberOfChecks).toEqual(1);
@ -770,7 +783,8 @@ export function main() {
.createAsync(MyComp)
.then((rootTC) => {
var childComponent = rootTC.componentViewChildren[0].getLocal('child');
var childComponent =
rootTC.debugElement.componentViewChildren[0].getLocal('child');
expect(childComponent.myHost).toBeAnInstanceOf(SomeDirective);
async.done();
@ -792,7 +806,7 @@ export function main() {
.then((rootTC) => {
rootTC.detectChanges();
var tc = rootTC.componentViewChildren[0].children[1];
var tc = rootTC.debugElement.componentViewChildren[0].children[1];
var childComponent = tc.getLocal('child');
expect(childComponent.myHost).toBeAnInstanceOf(SomeDirective);
@ -811,7 +825,7 @@ export function main() {
.createAsync(MyComp)
.then((rootTC) => {
var tc = rootTC.componentViewChildren[0];
var tc = rootTC.debugElement.componentViewChildren[0];
var emitter = tc.inject(DirectiveEmitingEvent);
var listener = tc.inject(DirectiveListeningEvent);
@ -835,16 +849,16 @@ export function main() {
.createAsync(MyComp)
.then((rootTC) => {
var tc = rootTC.componentViewChildren[0];
var tc = rootTC.debugElement.componentViewChildren[0];
var dir = tc.inject(DirectiveWithTwoWayBinding);
rootTC.componentInstance.ctxProp = 'one';
rootTC.debugElement.componentInstance.ctxProp = 'one';
rootTC.detectChanges();
expect(dir.value).toEqual('one');
ObservableWrapper.subscribe(dir.control, (_) => {
expect(rootTC.componentInstance.ctxProp).toEqual('two');
expect(rootTC.debugElement.componentInstance.ctxProp).toEqual('two');
async.done();
});
@ -862,7 +876,7 @@ export function main() {
.createAsync(MyComp)
.then((rootTC) => {
var tc = rootTC.componentViewChildren[0];
var tc = rootTC.debugElement.componentViewChildren[0];
var listener = tc.inject(DirectiveListeningDomEvent);
dispatchEvent(tc.nativeElement, 'domEvent');
@ -884,7 +898,7 @@ export function main() {
.createAsync(MyComp)
.then((rootTC) => {
var tc = rootTC.componentViewChildren[0];
var tc = rootTC.debugElement.componentViewChildren[0];
var listener = tc.inject(DirectiveListeningDomEvent);
dispatchEvent(DOM.getGlobalEventTarget("window"), 'domEvent');
expect(listener.eventTypes).toEqual(['window_domEvent']);
@ -913,7 +927,8 @@ export function main() {
.then((rootTC) => {
rootTC.detectChanges();
expect(DOM.getAttribute(rootTC.componentViewChildren[0].nativeElement, "role"))
expect(DOM.getAttribute(rootTC.debugElement.componentViewChildren[0].nativeElement,
"role"))
.toEqual("button");
async.done();
@ -929,7 +944,7 @@ export function main() {
.createAsync(MyComp)
.then((rootTC) => {
var tc = rootTC.componentViewChildren[0];
var tc = rootTC.debugElement.componentViewChildren[0];
var updateHost = tc.inject(DirectiveUpdatingHostProperties);
updateHost.id = "newId";
@ -961,15 +976,17 @@ export function main() {
.then((rootTC) => {
var dispatchedEvent = DOM.createMouseEvent('click');
var dispatchedEvent2 = DOM.createMouseEvent('click');
DOM.dispatchEvent(rootTC.componentViewChildren[0].nativeElement,
DOM.dispatchEvent(rootTC.debugElement.componentViewChildren[0].nativeElement,
dispatchedEvent);
DOM.dispatchEvent(rootTC.componentViewChildren[1].nativeElement,
DOM.dispatchEvent(rootTC.debugElement.componentViewChildren[1].nativeElement,
dispatchedEvent2);
expect(DOM.isPrevented(dispatchedEvent)).toBe(true);
expect(DOM.isPrevented(dispatchedEvent2)).toBe(false);
expect(DOM.getChecked(rootTC.componentViewChildren[0].nativeElement))
expect(
DOM.getChecked(rootTC.debugElement.componentViewChildren[0].nativeElement))
.toBeFalsy();
expect(DOM.getChecked(rootTC.componentViewChildren[1].nativeElement))
expect(
DOM.getChecked(rootTC.debugElement.componentViewChildren[1].nativeElement))
.toBeTruthy();
async.done();
});
@ -988,10 +1005,10 @@ export function main() {
.createAsync(MyComp)
.then((rootTC) => {
globalCounter = 0;
rootTC.componentInstance.ctxBoolProp = true;
rootTC.debugElement.componentInstance.ctxBoolProp = true;
rootTC.detectChanges();
var tc = rootTC.componentViewChildren[1];
var tc = rootTC.debugElement.componentViewChildren[1];
var listener = tc.inject(DirectiveListeningDomEvent);
var listenerother = tc.inject(DirectiveListeningDomEventOther);
@ -1001,12 +1018,12 @@ export function main() {
expect(globalCounter).toEqual(1);
rootTC.componentInstance.ctxBoolProp = false;
rootTC.debugElement.componentInstance.ctxBoolProp = false;
rootTC.detectChanges();
dispatchEvent(DOM.getGlobalEventTarget("window"), 'domEvent');
expect(globalCounter).toEqual(1);
rootTC.componentInstance.ctxBoolProp = true;
rootTC.debugElement.componentInstance.ctxBoolProp = true;
rootTC.detectChanges();
dispatchEvent(DOM.getGlobalEventTarget("window"), 'domEvent');
expect(globalCounter).toEqual(2);
@ -1027,11 +1044,11 @@ export function main() {
.createAsync(MyComp)
.then((rootTC) => {
var tc = rootTC.componentViewChildren[0];
var tc = rootTC.debugElement.componentViewChildren[0];
var dynamicVp = tc.inject(DynamicViewport);
dynamicVp.done.then((_) => {
rootTC.detectChanges();
expect(rootTC.componentViewChildren[1].nativeElement)
expect(rootTC.debugElement.componentViewChildren[1].nativeElement)
.toHaveText('dynamic greet');
async.done();
});
@ -1048,7 +1065,7 @@ export function main() {
{template: '<input static type="text" title>', directives: [NeedsAttribute]}))
.createAsync(MyComp)
.then((rootTC) => {
var tc = rootTC.componentViewChildren[0];
var tc = rootTC.debugElement.componentViewChildren[0];
var needsAttribute = tc.inject(NeedsAttribute);
expect(needsAttribute.typeAttribute).toEqual('text');
expect(needsAttribute.staticAttribute).toEqual('');
@ -1074,7 +1091,7 @@ export function main() {
}))
.createAsync(MyComp)
.then((rootTC) => {
var comp = rootTC.componentViewChildren[0].getLocal("consuming");
var comp = rootTC.debugElement.componentViewChildren[0].getLocal("consuming");
expect(comp.injectable).toBeAnInstanceOf(InjectableService);
async.done();
@ -1092,7 +1109,7 @@ export function main() {
}))
.createAsync(DirectiveProvidingInjectableInView)
.then((rootTC) => {
var comp = rootTC.componentViewChildren[0].getLocal("consuming");
var comp = rootTC.debugElement.componentViewChildren[0].getLocal("consuming");
expect(comp.injectable).toBeAnInstanceOf(InjectableService);
async.done();
@ -1122,7 +1139,7 @@ export function main() {
.createAsync(MyComp)
.then((rootTC) => {
var comp = rootTC.componentViewChildren[0].getLocal("dir");
var comp = rootTC.debugElement.componentViewChildren[0].getLocal("dir");
expect(comp.directive.injectable).toBeAnInstanceOf(InjectableService);
async.done();
@ -1148,7 +1165,7 @@ export function main() {
}))
.createAsync(MyComp)
.then((rootTC) => {
var gpComp = rootTC.componentViewChildren[0];
var gpComp = rootTC.debugElement.componentViewChildren[0];
var parentComp = gpComp.children[0];
var childComp = parentComp.children[0];
@ -1180,10 +1197,10 @@ export function main() {
}))
.createAsync(MyComp)
.then((rootTC) => {
var providing = rootTC.componentViewChildren[0].getLocal("providing");
var providing = rootTC.debugElement.componentViewChildren[0].getLocal("providing");
expect(providing.created).toBe(false);
rootTC.componentInstance.ctxBoolProp = true;
rootTC.debugElement.componentInstance.ctxBoolProp = true;
rootTC.detectChanges();
expect(providing.created).toBe(true);
@ -1203,7 +1220,8 @@ export function main() {
}))
.createAsync(MyComp)
.then((rootTC) => {
expect(DOM.querySelectorAll(rootTC.nativeElement, 'script').length).toEqual(0);
expect(DOM.querySelectorAll(rootTC.debugElement.nativeElement, 'script').length)
.toEqual(0);
async.done();
});
}));
@ -1281,7 +1299,7 @@ export function main() {
expect(DOM.nodeName(c.componentElement).toUpperCase()).toEqual("DIV");
expect(c.injector).toBeAnInstanceOf(Injector);
expect(c.expression).toContain("one.two.three");
expect(c.context).toBe(rootTC.componentInstance);
expect(c.context).toBe(rootTC.debugElement.componentInstance);
expect(c.locals["local"]).toBeDefined();
}
@ -1318,11 +1336,11 @@ export function main() {
directives: [DirectiveEmitingEvent, DirectiveListeningEvent]
}));
var rootTC;
var rootTC: RootTestComponent;
tcb.createAsync(MyComp).then(root => { rootTC = root; });
tick();
var tc = rootTC.componentViewChildren[0];
var tc = rootTC.debugElement.componentViewChildren[0];
tc.inject(DirectiveEmitingEvent).fireEvent("boom");
try {
@ -1335,7 +1353,7 @@ export function main() {
expect(DOM.nodeName(c.element).toUpperCase()).toEqual("SPAN");
expect(DOM.nodeName(c.componentElement).toUpperCase()).toEqual("DIV");
expect(c.injector).toBeAnInstanceOf(Injector);
expect(c.context).toBe(rootTC.componentInstance);
expect(c.context).toBe(rootTC.debugElement.componentInstance);
expect(c.locals["local"]).toBeDefined();
}
})));
@ -1411,7 +1429,7 @@ export function main() {
}))
.createAsync(MyComp)
.then((rootTC) => {
expect(rootTC.nativeElement).toHaveText('hello imp view');
expect(rootTC.debugElement.nativeElement).toHaveText('hello imp view');
async.done();
});
}));
@ -1424,18 +1442,18 @@ export function main() {
directives: [SomeImperativeViewport]
}))
.createAsync(MyComp)
.then((rootTC) => {
.then((rootTC: RootTestComponent) => {
rootTC.detectChanges();
expect(anchorElement).toHaveText('');
rootTC.componentInstance.ctxBoolProp = true;
rootTC.debugElement.componentInstance.ctxBoolProp = true;
rootTC.detectChanges();
expect(anchorElement).toHaveText('hello');
rootTC.componentInstance.ctxBoolProp = false;
rootTC.debugElement.componentInstance.ctxBoolProp = false;
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('');
expect(rootTC.debugElement.nativeElement).toHaveText('');
async.done();
});
@ -1478,10 +1496,10 @@ export function main() {
}))
.createAsync(MyComp)
.then((rootTC) => {
rootTC.componentInstance.ctxProp = "TITLE";
rootTC.debugElement.componentInstance.ctxProp = "TITLE";
rootTC.detectChanges();
var el = DOM.querySelector(rootTC.nativeElement, "span");
var el = DOM.querySelector(rootTC.debugElement.nativeElement, "span");
expect(isBlank(el.title) || el.title == '').toBeTruthy();
async.done();
@ -1497,10 +1515,10 @@ export function main() {
}))
.createAsync(MyComp)
.then((rootTC) => {
rootTC.componentInstance.ctxProp = "TITLE";
rootTC.debugElement.componentInstance.ctxProp = "TITLE";
rootTC.detectChanges();
var el = DOM.querySelector(rootTC.nativeElement, "span");
var el = DOM.querySelector(rootTC.debugElement.nativeElement, "span");
expect(el.title).toEqual("TITLE");
async.done();
@ -1525,10 +1543,10 @@ export function main() {
.createAsync(MyComp)
.then((rootTC) => {
rootTC.componentInstance.ctxProp = 'hello';
rootTC.debugElement.componentInstance.ctxProp = 'hello';
rootTC.detectChanges();
expect(DOM.getInnerHTML(rootTC.nativeElement))
expect(DOM.getInnerHTML(rootTC.debugElement.nativeElement))
.toContain('ng-reflect-dir-prop="hello"');
async.done();
});
@ -1543,10 +1561,10 @@ export function main() {
new ViewMetadata({template: `<!--${mode}--><div>{{ctxProp}}</div>`}))
.createAsync(MyComp)
.then((rootTC) => {
rootTC.componentInstance.ctxProp = 'Hello World!';
rootTC.debugElement.componentInstance.ctxProp = 'Hello World!';
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('Hello World!');
expect(rootTC.debugElement.nativeElement).toHaveText('Hello World!');
async.done();
});
});
@ -1621,7 +1639,8 @@ export function main() {
.createAsync(MyComp)
.then((rootTC) => {
rootTC.detectChanges();
var dir = rootTC.componentViewChildren[0].inject(DirectiveWithPropDecorators);
var dir = rootTC.debugElement.componentViewChildren[0].inject(
DirectiveWithPropDecorators);
expect(dir.dirProp).toEqual("aaa");
async.done();
});
@ -1636,11 +1655,13 @@ export function main() {
.createAsync(MyComp)
.then((rootTC) => {
rootTC.detectChanges();
var dir = rootTC.componentViewChildren[0].inject(DirectiveWithPropDecorators);
var dir = rootTC.debugElement.componentViewChildren[0].inject(
DirectiveWithPropDecorators);
dir.myAttr = "aaa";
rootTC.detectChanges();
expect(DOM.getOuterHTML(rootTC.componentViewChildren[0].nativeElement))
expect(
DOM.getOuterHTML(rootTC.debugElement.componentViewChildren[0].nativeElement))
.toContain('my-attr="aaa"');
async.done();
});
@ -1655,38 +1676,39 @@ export function main() {
directives: [DirectiveWithPropDecorators]
}));
var rootTC;
var rootTC: RootTestComponent;
tcb.createAsync(MyComp).then(root => { rootTC = root; });
tick();
var emitter =
rootTC.componentViewChildren[0].inject(DirectiveWithPropDecorators);
var emitter = rootTC.debugElement.componentViewChildren[0].inject(
DirectiveWithPropDecorators);
emitter.fireEvent('fired !');
tick();
expect(rootTC.componentInstance.ctxProp).toEqual("called");
expect(rootTC.debugElement.componentInstance.ctxProp).toEqual("called");
})));
it('should support host listener decorators',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder,
async) => {
tcb.overrideView(MyComp, new ViewMetadata({
template: '<with-prop-decorators></with-prop-decorators>',
directives: [DirectiveWithPropDecorators]
}))
.createAsync(MyComp)
.then((rootTC) => {
rootTC.detectChanges();
var dir = rootTC.componentViewChildren[0].inject(DirectiveWithPropDecorators);
var native = rootTC.componentViewChildren[0].nativeElement;
native.click();
inject([TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new ViewMetadata({
template: '<with-prop-decorators></with-prop-decorators>',
directives: [DirectiveWithPropDecorators]
}))
.createAsync(MyComp)
.then((rootTC) => {
rootTC.detectChanges();
var dir = rootTC.debugElement.componentViewChildren[0].inject(
DirectiveWithPropDecorators);
var native = rootTC.debugElement.componentViewChildren[0].nativeElement;
native.click();
expect(dir.target).toBe(native);
async.done();
});
}));
expect(dir.target).toBe(native);
async.done();
});
}));
}
});
});

View File

@ -49,7 +49,7 @@ export function main() {
}))
.createAsync(MainComp)
.then((main) => {
expect(main.nativeElement).toHaveText('SIMPLE(A)');
expect(main.debugElement.nativeElement).toHaveText('SIMPLE(A)');
async.done();
});
}));
@ -65,9 +65,9 @@ export function main() {
.createAsync(MainComp)
.then((main) => {
main.componentInstance.text = 'A';
main.debugElement.componentInstance.text = 'A';
main.detectChanges();
expect(main.nativeElement).toHaveText('START(SIMPLE(A))END');
expect(main.debugElement.nativeElement).toHaveText('START(SIMPLE(A))END');
async.done();
});
}));
@ -84,9 +84,9 @@ export function main() {
.createAsync(MainComp)
.then((main) => {
main.componentInstance.text = 'A';
main.debugElement.componentInstance.text = 'A';
main.detectChanges();
expect(main.nativeElement).toHaveText('SIMPLE(A)');
expect(main.debugElement.nativeElement).toHaveText('SIMPLE(A)');
async.done();
});
}));
@ -106,9 +106,9 @@ export function main() {
.createAsync(MainComp)
.then((main) => {
main.componentInstance.text = 'A';
main.debugElement.componentInstance.text = 'A';
main.detectChanges();
expect(main.nativeElement).toHaveText('SIMPLE(AEL)');
expect(main.debugElement.nativeElement).toHaveText('SIMPLE(AEL)');
async.done();
});
}));
@ -120,7 +120,7 @@ export function main() {
.createAsync(MainComp)
.then((main) => {
expect(main.nativeElement).toHaveText('');
expect(main.debugElement.nativeElement).toHaveText('');
async.done();
});
}));
@ -138,7 +138,7 @@ export function main() {
.createAsync(MainComp)
.then((main) => {
expect(main.nativeElement).toHaveText('(A, BC)');
expect(main.debugElement.nativeElement).toHaveText('(A, BC)');
async.done();
});
}));
@ -155,7 +155,7 @@ export function main() {
.createAsync(MainComp)
.then((main) => {
expect(main.nativeElement).toHaveText('(, BAC)');
expect(main.debugElement.nativeElement).toHaveText('(, BAC)');
async.done();
});
}));
@ -172,16 +172,17 @@ export function main() {
.createAsync(MainComp)
.then((main) => {
var viewportDirectives = main.queryAll(By.directive(ManualViewportDirective))
.map(de => de.inject(ManualViewportDirective));
var viewportDirectives =
main.debugElement.queryAll(By.directive(ManualViewportDirective))
.map(de => de.inject(ManualViewportDirective));
expect(main.nativeElement).toHaveText('(, B)');
expect(main.debugElement.nativeElement).toHaveText('(, B)');
viewportDirectives.forEach(d => d.show());
expect(main.nativeElement).toHaveText('(A1, B)');
expect(main.debugElement.nativeElement).toHaveText('(A1, B)');
viewportDirectives.forEach(d => d.hide());
expect(main.nativeElement).toHaveText('(, B)');
expect(main.debugElement.nativeElement).toHaveText('(, B)');
async.done();
});
}));
@ -198,7 +199,7 @@ export function main() {
.createAsync(MainComp)
.then((main) => {
expect(main.nativeElement).toHaveText('OUTER(SIMPLE(AB))');
expect(main.debugElement.nativeElement).toHaveText('OUTER(SIMPLE(AB))');
async.done();
});
}));
@ -216,13 +217,14 @@ export function main() {
.createAsync(MainComp)
.then((main) => {
var viewportDirective = main.query(By.directive(ManualViewportDirective))
.inject(ManualViewportDirective);
var viewportDirective =
main.debugElement.query(By.directive(ManualViewportDirective))
.inject(ManualViewportDirective);
expect(main.nativeElement).toHaveText('OUTER(INNER(INNERINNER(,BC)))');
expect(main.debugElement.nativeElement).toHaveText('OUTER(INNER(INNERINNER(,BC)))');
viewportDirective.show();
expect(main.nativeElement).toHaveText('OUTER(INNER(INNERINNER(A,BC)))');
expect(main.debugElement.nativeElement).toHaveText('OUTER(INNER(INNERINNER(A,BC)))');
async.done();
});
}));
@ -240,17 +242,18 @@ export function main() {
.createAsync(MainComp)
.then((main) => {
var viewportDirective = main.query(By.directive(ManualViewportDirective))
.inject(ManualViewportDirective);
var viewportDirective =
main.debugElement.query(By.directive(ManualViewportDirective))
.inject(ManualViewportDirective);
expect(main.nativeElement).toHaveText('(, BC)');
expect(main.debugElement.nativeElement).toHaveText('(, BC)');
viewportDirective.show();
expect(main.nativeElement).toHaveText('(A, BC)');
expect(main.debugElement.nativeElement).toHaveText('(A, BC)');
viewportDirective.hide();
expect(main.nativeElement).toHaveText('(, BC)');
expect(main.debugElement.nativeElement).toHaveText('(, BC)');
async.done();
});
}));
@ -267,11 +270,11 @@ export function main() {
{template: '<simple string-prop="text"></simple>', directives: [Simple]}))
.overrideTemplate(Simple, '<ng-content></ng-content><p>P,</p>{{stringProp}}')
.createAsync(MainComp)
.then((main) => {
.then((main: RootTestComponent) => {
main.detectChanges();
expect(main.nativeElement).toHaveText('P,text');
expect(main.debugElement.nativeElement).toHaveText('P,text');
async.done();
});
@ -288,10 +291,10 @@ export function main() {
{template: '<simple string-prop="text"></simple>', directives: [Simple]}))
.overrideTemplate(Simple, '<style></style><p>P,</p>{{stringProp}}')
.createAsync(MainComp)
.then((main) => {
.then((main: RootTestComponent) => {
main.detectChanges();
expect(main.nativeElement).toHaveText('P,text');
expect(main.debugElement.nativeElement).toHaveText('P,text');
async.done();
});
}));
@ -309,14 +312,14 @@ export function main() {
.then((main) => {
var sourceDirective: ManualViewportDirective =
main.query(By.directive(ManualViewportDirective))
main.debugElement.query(By.directive(ManualViewportDirective))
.inject(ManualViewportDirective);
var projectDirective: ProjectDirective =
main.query(By.directive(ProjectDirective)).inject(ProjectDirective);
expect(main.nativeElement).toHaveText('START()END');
main.debugElement.query(By.directive(ProjectDirective)).inject(ProjectDirective);
expect(main.debugElement.nativeElement).toHaveText('START()END');
projectDirective.show(sourceDirective.templateRef);
expect(main.nativeElement).toHaveText('START(A)END');
expect(main.debugElement.nativeElement).toHaveText('START(A)END');
async.done();
});
}));
@ -332,14 +335,14 @@ export function main() {
.then((main) => {
var sourceDirective: ManualViewportDirective =
main.query(By.directive(ManualViewportDirective))
main.debugElement.query(By.directive(ManualViewportDirective))
.inject(ManualViewportDirective);
var projectDirective: ProjectDirective =
main.query(By.directive(ProjectDirective)).inject(ProjectDirective);
expect(main.nativeElement).toHaveText('SIMPLE()START()END');
main.debugElement.query(By.directive(ProjectDirective)).inject(ProjectDirective);
expect(main.debugElement.nativeElement).toHaveText('SIMPLE()START()END');
projectDirective.show(sourceDirective.templateRef);
expect(main.nativeElement).toHaveText('SIMPLE()START(A)END');
expect(main.debugElement.nativeElement).toHaveText('SIMPLE()START(A)END');
async.done();
});
}));
@ -360,19 +363,19 @@ export function main() {
.then((main) => {
var sourceDirective: ManualViewportDirective =
main.query(By.directive(ManualViewportDirective))
main.debugElement.query(By.directive(ManualViewportDirective))
.inject(ManualViewportDirective);
var projectDirective: ProjectDirective =
main.query(By.directive(ProjectDirective)).inject(ProjectDirective);
expect(main.nativeElement).toHaveText('(, B)START()END');
main.debugElement.query(By.directive(ProjectDirective)).inject(ProjectDirective);
expect(main.debugElement.nativeElement).toHaveText('(, B)START()END');
projectDirective.show(sourceDirective.templateRef);
expect(main.nativeElement).toHaveText('(, B)START(A)END');
expect(main.debugElement.nativeElement).toHaveText('(, B)START(A)END');
// Stamping ng-content multiple times should not produce the content multiple
// times...
projectDirective.show(sourceDirective.templateRef);
expect(main.nativeElement).toHaveText('(, B)START(A)END');
expect(main.debugElement.nativeElement).toHaveText('(, B)START(A)END');
async.done();
});
}));
@ -390,12 +393,12 @@ export function main() {
main.detectChanges();
var manualDirective: ManualViewportDirective =
main.query(By.directive(ManualViewportDirective))
main.debugElement.query(By.directive(ManualViewportDirective))
.inject(ManualViewportDirective);
expect(main.nativeElement).toHaveText('TREE(0:)');
expect(main.debugElement.nativeElement).toHaveText('TREE(0:)');
manualDirective.show();
main.detectChanges();
expect(main.nativeElement).toHaveText('TREE(0:TREE(1:))');
expect(main.debugElement.nativeElement).toHaveText('TREE(0:TREE(1:))');
async.done();
});
}));
@ -412,7 +415,7 @@ export function main() {
.createAsync(MainComp)
.then((main) => {
expect(main.nativeElement).toHaveText('SIMPLE(A)');
expect(main.debugElement.nativeElement).toHaveText('SIMPLE(A)');
async.done();
});
}));
@ -429,15 +432,17 @@ export function main() {
}))
.createAsync(MainComp)
.then((main) => {
expect(main.nativeElement).toHaveText('MAIN()');
expect(main.debugElement.nativeElement).toHaveText('MAIN()');
var viewportElement = main.componentViewChildren[0].componentViewChildren[0];
var viewportElement =
main.debugElement.componentViewChildren[0].componentViewChildren[0];
viewportElement.inject(ManualViewportDirective).show();
expect(main.nativeElement).toHaveText('MAIN(FIRST())');
expect(main.debugElement.nativeElement).toHaveText('MAIN(FIRST())');
viewportElement = main.componentViewChildren[0].componentViewChildren[1];
viewportElement =
main.debugElement.componentViewChildren[0].componentViewChildren[1];
viewportElement.inject(ManualViewportDirective).show();
expect(main.nativeElement).toHaveText('MAIN(FIRST(SECOND(a)))');
expect(main.debugElement.nativeElement).toHaveText('MAIN(FIRST(SECOND(a)))');
async.done();
});

View File

@ -49,7 +49,8 @@ export function main() {
.then((view) => {
view.detectChanges();
expect(asNativeElements(view.componentViewChildren)).toHaveText('2|3|');
expect(asNativeElements(view.debugElement.componentViewChildren))
.toHaveText('2|3|');
async.done();
});
@ -67,7 +68,8 @@ export function main() {
.createAsync(MyComp)
.then((view) => {
view.detectChanges();
expect(asNativeElements(view.componentViewChildren)).toHaveText('2|3|4|');
expect(asNativeElements(view.debugElement.componentViewChildren))
.toHaveText('2|3|4|');
async.done();
});
@ -83,7 +85,8 @@ export function main() {
.createAsync(MyComp)
.then((view) => {
view.detectChanges();
expect(asNativeElements(view.componentViewChildren)).toHaveText('2|3|');
expect(asNativeElements(view.debugElement.componentViewChildren))
.toHaveText('2|3|');
async.done();
});
@ -101,11 +104,12 @@ export function main() {
.then((view) => {
view.detectChanges();
expect(asNativeElements(view.componentViewChildren)).toHaveText('2|');
expect(asNativeElements(view.debugElement.componentViewChildren)).toHaveText('2|');
view.componentInstance.shouldShow = true;
view.debugElement.componentInstance.shouldShow = true;
view.detectChanges();
expect(asNativeElements(view.componentViewChildren)).toHaveText('2|3|');
expect(asNativeElements(view.debugElement.componentViewChildren))
.toHaveText('2|3|');
async.done();
});
@ -121,7 +125,7 @@ export function main() {
tcb.overrideTemplate(MyComp, template)
.createAsync(MyComp)
.then((rtc) => {
rtc.componentInstance.shouldShow = true;
rtc.debugElement.componentInstance.shouldShow = true;
rtc.detectChanges();
rtc.destroy();
@ -141,11 +145,13 @@ export function main() {
.then((view) => {
view.detectChanges();
expect(asNativeElements(view.componentViewChildren)).toHaveText('2|1d|2d|3d|');
expect(asNativeElements(view.debugElement.componentViewChildren))
.toHaveText('2|1d|2d|3d|');
view.componentInstance.list = ['3d', '2d'];
view.debugElement.componentInstance.list = ['3d', '2d'];
view.detectChanges();
expect(asNativeElements(view.componentViewChildren)).toHaveText('2|3d|2d|');
expect(asNativeElements(view.debugElement.componentViewChildren))
.toHaveText('2|3d|2d|');
async.done();
});
@ -160,7 +166,8 @@ export function main() {
.createAsync(MyComp)
.then((view) => {
view.detectChanges();
var needsTpl: NeedsTpl = view.componentViewChildren[0].inject(NeedsTpl);
var needsTpl: NeedsTpl =
view.debugElement.componentViewChildren[0].inject(NeedsTpl);
expect(needsTpl.query.first.hasLocal('light')).toBe(true);
expect(needsTpl.viewQuery.first.hasLocal('shadow')).toBe(true);
@ -181,7 +188,7 @@ export function main() {
tcb.overrideTemplate(MyComp, template)
.createAsync(MyComp)
.then((view) => {
var q = view.componentViewChildren[0].getLocal("q");
var q = view.debugElement.componentViewChildren[0].getLocal("q");
view.detectChanges();
q.query.onChange(() => {
@ -190,7 +197,7 @@ export function main() {
async.done();
});
view.componentInstance.shouldShow = true;
view.debugElement.componentInstance.shouldShow = true;
view.detectChanges();
});
}));
@ -206,8 +213,8 @@ export function main() {
tcb.overrideTemplate(MyComp, template)
.createAsync(MyComp)
.then((view) => {
var q1 = view.componentViewChildren[0].getLocal("q1");
var q2 = view.componentViewChildren[0].getLocal("q2");
var q1 = view.debugElement.componentViewChildren[0].getLocal("q1");
var q2 = view.debugElement.componentViewChildren[0].getLocal("q2");
var firedQ2 = false;
@ -229,19 +236,19 @@ export function main() {
tcb.overrideTemplate(MyComp, template)
.createAsync(MyComp)
.then((view) => {
view.componentInstance.shouldShow = true;
view.debugElement.componentInstance.shouldShow = true;
view.detectChanges();
var q: NeedsQuery = view.componentViewChildren[1].getLocal('q');
var q: NeedsQuery = view.debugElement.componentViewChildren[1].getLocal('q');
expect(q.query.length).toEqual(1);
view.componentInstance.shouldShow = false;
view.debugElement.componentInstance.shouldShow = false;
view.detectChanges();
view.componentInstance.shouldShow = true;
view.debugElement.componentInstance.shouldShow = true;
view.detectChanges();
var q2: NeedsQuery = view.componentViewChildren[1].getLocal('q');
var q2: NeedsQuery = view.debugElement.componentViewChildren[1].getLocal('q');
expect(q2.query.length).toEqual(1);
@ -261,9 +268,9 @@ export function main() {
tcb.overrideTemplate(MyComp, template)
.createAsync(MyComp)
.then((view) => {
var q = view.componentViewChildren[0].getLocal("q");
var q = view.debugElement.componentViewChildren[0].getLocal("q");
view.componentInstance.list = ['1d', '2d'];
view.debugElement.componentInstance.list = ['1d', '2d'];
view.detectChanges();
@ -284,7 +291,7 @@ export function main() {
tcb.overrideTemplate(MyComp, template)
.createAsync(MyComp)
.then((view) => {
var q = view.componentViewChildren[0].getLocal("q");
var q = view.debugElement.componentViewChildren[0].getLocal("q");
view.detectChanges();
expect(q.query.first.text).toEqual("one");
@ -304,13 +311,13 @@ export function main() {
tcb.overrideTemplate(MyComp, template)
.createAsync(MyComp)
.then((view) => {
var q = view.componentViewChildren[0].getLocal("q");
var q = view.debugElement.componentViewChildren[0].getLocal("q");
view.componentInstance.list = ['1d', '2d'];
view.debugElement.componentInstance.list = ['1d', '2d'];
view.detectChanges();
view.componentInstance.list = ['2d', '1d'];
view.debugElement.componentInstance.list = ['2d', '1d'];
view.detectChanges();
@ -331,9 +338,9 @@ export function main() {
tcb.overrideTemplate(MyComp, template)
.createAsync(MyComp)
.then((view) => {
var q = view.componentViewChildren[0].getLocal("q");
var q = view.debugElement.componentViewChildren[0].getLocal("q");
view.componentInstance.list = ['1d', '2d'];
view.debugElement.componentInstance.list = ['1d', '2d'];
view.detectChanges();
@ -355,7 +362,8 @@ export function main() {
.then((view) => {
view.detectChanges();
expect(asNativeElements(view.componentViewChildren)).toHaveText('hello|world|');
expect(asNativeElements(view.debugElement.componentViewChildren))
.toHaveText('hello|world|');
async.done();
});
@ -368,7 +376,8 @@ export function main() {
tcb.overrideTemplate(MyComp, template)
.createAsync(MyComp)
.then((view) => {
var q: NeedsViewQueryByLabel = view.componentViewChildren[0].getLocal("q");
var q: NeedsViewQueryByLabel =
view.debugElement.componentViewChildren[0].getLocal("q");
view.detectChanges();
expect(q.query.first.nativeElement).toHaveText("text");
@ -386,7 +395,7 @@ export function main() {
tcb.overrideTemplate(MyComp, template)
.createAsync(MyComp)
.then((view) => {
var q: NeedsViewQuery = view.componentViewChildren[0].getLocal("q");
var q: NeedsViewQuery = view.debugElement.componentViewChildren[0].getLocal("q");
view.detectChanges();
@ -403,7 +412,7 @@ export function main() {
tcb.overrideTemplate(MyComp, template)
.createAsync(MyComp)
.then((view) => {
var q: NeedsViewQuery = view.componentViewChildren[0].getLocal("q");
var q: NeedsViewQuery = view.debugElement.componentViewChildren[0].getLocal("q");
view.detectChanges();
@ -420,7 +429,7 @@ export function main() {
tcb.overrideTemplate(MyComp, template)
.createAsync(MyComp)
.then((view) => {
var q: NeedsViewQueryIf = view.componentViewChildren[0].getLocal("q");
var q: NeedsViewQueryIf = view.debugElement.componentViewChildren[0].getLocal("q");
view.detectChanges();
@ -443,7 +452,8 @@ export function main() {
tcb.overrideTemplate(MyComp, template)
.createAsync(MyComp)
.then((view) => {
var q: NeedsViewQueryNestedIf = view.componentViewChildren[0].getLocal("q");
var q: NeedsViewQueryNestedIf =
view.debugElement.componentViewChildren[0].getLocal("q");
view.detectChanges();
@ -468,7 +478,8 @@ export function main() {
tcb.overrideTemplate(MyComp, template)
.createAsync(MyComp)
.then((view) => {
var q: NeedsViewQueryOrder = view.componentViewChildren[0].getLocal("q");
var q: NeedsViewQueryOrder =
view.debugElement.componentViewChildren[0].getLocal("q");
view.detectChanges();
@ -491,7 +502,8 @@ export function main() {
tcb.overrideTemplate(MyComp, template)
.createAsync(MyComp)
.then((view) => {
var q: NeedsViewQueryOrderWithParent = view.componentViewChildren[0].getLocal("q");
var q: NeedsViewQueryOrderWithParent =
view.debugElement.componentViewChildren[0].getLocal("q");
view.detectChanges();
@ -514,7 +526,8 @@ export function main() {
tcb.overrideTemplate(MyComp, template)
.createAsync(MyComp)
.then((view) => {
var q: NeedsViewQueryOrder = view.componentViewChildren[0].getLocal('q');
var q: NeedsViewQueryOrder =
view.debugElement.componentViewChildren[0].getLocal('q');
// no significance to 50, just a reasonably large cycle.
for (var i = 0; i < 50; i++) {

View File

@ -124,17 +124,17 @@ export function main() {
describe('debug element', function() {
it('should list component child elements',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb, async) => {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.createAsync(ParentComp)
.then((rootTestComponent) => {
rootTestComponent.detectChanges();
var childEls = rootTestComponent.children;
var childEls = rootTestComponent.debugElement.children;
// The root is a lone component, and has no children in the light dom.
expect(childEls.length).toEqual(0);
var rootCompChildren = rootTestComponent.componentViewChildren;
var rootCompChildren = rootTestComponent.debugElement.componentViewChildren;
// The root component has 3 elements in its shadow view.
expect(rootCompChildren.length).toEqual(3);
expect(DOM.hasClass(rootCompChildren[0].nativeElement, 'parent')).toBe(true);
@ -163,12 +163,12 @@ export function main() {
}));
it('should list child elements within viewports',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb, async) => {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.createAsync(UsingFor).then((rootTestComponent) => {
rootTestComponent.detectChanges();
var childEls = rootTestComponent.componentViewChildren;
var childEls = rootTestComponent.debugElement.componentViewChildren;
// TODO should this count include the <template> element?
expect(childEls.length).toEqual(5);
@ -180,13 +180,13 @@ export function main() {
}));
it('should query child elements',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb, async) => {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.createAsync(ParentComp)
.then((rootTestComponent) => {
rootTestComponent.detectChanges();
var childTestEls = rootTestComponent.queryAll(By.directive(MessageDir));
var childTestEls = rootTestComponent.debugElement.queryAll(By.directive(MessageDir));
expect(childTestEls.length).toBe(4);
expect(DOM.hasClass(childTestEls[0].nativeElement, 'parent')).toBe(true);
@ -198,13 +198,13 @@ export function main() {
}));
it('should query child elements in the light DOM',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb, async) => {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.createAsync(ParentComp)
.then((rootTestComponent) => {
rootTestComponent.detectChanges();
var parentEl = rootTestComponent.componentViewChildren[0];
var parentEl = rootTestComponent.debugElement.componentViewChildren[0];
var childTestEls = parentEl.queryAll(By.directive(MessageDir), Scope.light);
@ -216,13 +216,14 @@ export function main() {
}));
it('should query child elements in the current component view DOM',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb, async) => {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.createAsync(ParentComp)
.then((rootTestComponent) => {
rootTestComponent.detectChanges();
var childTestEls = rootTestComponent.queryAll(By.directive(MessageDir), Scope.view);
var childTestEls =
rootTestComponent.debugElement.queryAll(By.directive(MessageDir), Scope.view);
expect(childTestEls.length).toBe(2);
expect(DOM.hasClass(childTestEls[0].nativeElement, 'parent')).toBe(true);
@ -233,13 +234,13 @@ export function main() {
}));
it('should allow injecting from the element injector',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb, async) => {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.createAsync(ParentComp)
.then((rootTestComponent) => {
rootTestComponent.detectChanges();
expect(rootTestComponent.componentViewChildren[0].inject(Logger).log)
expect(rootTestComponent.debugElement.componentViewChildren[0].inject(Logger).log)
.toEqual(['parent', 'nestedparent', 'child', 'nestedchild']);
async.done();
@ -247,20 +248,22 @@ export function main() {
}));
it('should trigger event handlers',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb, async) => {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.createAsync(EventsComp)
.then((rootTestComponent) => {
rootTestComponent.detectChanges();
expect(rootTestComponent.componentInstance.clicked).toBe(false);
expect(rootTestComponent.componentInstance.customed).toBe(false);
expect(rootTestComponent.debugElement.componentInstance.clicked).toBe(false);
expect(rootTestComponent.debugElement.componentInstance.customed).toBe(false);
rootTestComponent.componentViewChildren[0].triggerEventHandler('click', {});
expect(rootTestComponent.componentInstance.clicked).toBe(true);
rootTestComponent.debugElement.componentViewChildren[0].triggerEventHandler(
'click', <Event>{});
expect(rootTestComponent.debugElement.componentInstance.clicked).toBe(true);
rootTestComponent.componentViewChildren[1].triggerEventHandler('myevent', {});
expect(rootTestComponent.componentInstance.customed).toBe(true);
rootTestComponent.debugElement.componentViewChildren[1].triggerEventHandler(
'myevent', <Event>{});
expect(rootTestComponent.debugElement.componentInstance.customed).toBe(true);
async.done();
});

View File

@ -31,11 +31,12 @@ export function main() {
beforeEachBindings(() => [bind(APP_VIEW_POOL_CAPACITY).toValue(0)]);
it('should return a TestElement from a dom element',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb, async) => {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideTemplate(MyComp, '<div some-dir></div>')
.createAsync(MyComp)
.then((rootTestComponent) => {
expect(inspectNativeElement(rootTestComponent.nativeElement).componentInstance)
expect(inspectNativeElement(rootTestComponent.debugElement.nativeElement)
.componentInstance)
.toBeAnInstanceOf(MyComp);
async.done();
@ -43,12 +44,13 @@ export function main() {
}));
it('should clean up whent the view is destroyed',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb, async) => {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideTemplate(MyComp, '')
.createAsync(MyComp)
.then((rootTestComponent) => {
rootTestComponent.destroy();
expect(inspectNativeElement(rootTestComponent.nativeElement)).toBe(null);
expect(inspectNativeElement(rootTestComponent.debugElement.nativeElement))
.toBe(null);
async.done();
});
@ -57,11 +59,12 @@ export function main() {
if (!IS_DART) {
it('should provide a global function to inspect elements',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb, async) => {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideTemplate(MyComp, '')
.createAsync(MyComp)
.then((rootTestComponent) => {
expect(global['ng']['probe'](rootTestComponent.nativeElement).componentInstance)
expect(global['ng']['probe'](rootTestComponent.debugElement.nativeElement)
.componentInstance)
.toBeAnInstanceOf(MyComp);
async.done();

View File

@ -1,4 +1,5 @@
import {
RootTestComponent,
AsyncTestCompleter,
TestComponentBuilder,
beforeEach,
@ -18,9 +19,10 @@ import {Component, View, NgFor, bind} from 'angular2/angular2';
import {NgClass} from 'angular2/src/core/directives/ng_class';
import {APP_VIEW_POOL_CAPACITY} from 'angular2/src/core/compiler/view_pool';
function detectChangesAndCheck(rootTC, classes: string, elIndex: number = 0) {
function detectChangesAndCheck(rootTC: RootTestComponent, classes: string, elIndex: number = 0) {
rootTC.detectChanges();
expect(rootTC.componentViewChildren[elIndex].nativeElement.className).toEqual(classes);
expect(rootTC.debugElement.componentViewChildren[elIndex].nativeElement.className)
.toEqual(classes);
}
export function main() {
@ -35,9 +37,9 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.componentInstance.items = [['0']];
rootTC.debugElement.componentInstance.items = [['0']];
rootTC.detectChanges();
rootTC.componentInstance.items = [['1']];
rootTC.debugElement.componentInstance.items = [['1']];
detectChangesAndCheck(rootTC, 'ng-binding 1', 1);
@ -83,7 +85,7 @@ export function main() {
.then((rootTC) => {
detectChangesAndCheck(rootTC, 'ng-binding foo');
rootTC.componentInstance.condition = false;
rootTC.debugElement.componentInstance.condition = false;
detectChangesAndCheck(rootTC, 'ng-binding bar');
async.done();
@ -99,13 +101,13 @@ export function main() {
.then((rootTC) => {
detectChangesAndCheck(rootTC, 'ng-binding foo');
StringMapWrapper.set(rootTC.componentInstance.objExpr, 'bar', true);
StringMapWrapper.set(rootTC.debugElement.componentInstance.objExpr, 'bar', true);
detectChangesAndCheck(rootTC, 'ng-binding foo bar');
StringMapWrapper.set(rootTC.componentInstance.objExpr, 'baz', true);
StringMapWrapper.set(rootTC.debugElement.componentInstance.objExpr, 'baz', true);
detectChangesAndCheck(rootTC, 'ng-binding foo bar baz');
StringMapWrapper.delete(rootTC.componentInstance.objExpr, 'bar');
StringMapWrapper.delete(rootTC.debugElement.componentInstance.objExpr, 'bar');
detectChangesAndCheck(rootTC, 'ng-binding foo baz');
async.done();
@ -121,10 +123,10 @@ export function main() {
.then((rootTC) => {
detectChangesAndCheck(rootTC, 'ng-binding foo');
rootTC.componentInstance.objExpr = {foo: true, bar: true};
rootTC.debugElement.componentInstance.objExpr = {foo: true, bar: true};
detectChangesAndCheck(rootTC, 'ng-binding foo bar');
rootTC.componentInstance.objExpr = {baz: true};
rootTC.debugElement.componentInstance.objExpr = {baz: true};
detectChangesAndCheck(rootTC, 'ng-binding baz');
async.done();
@ -140,10 +142,10 @@ export function main() {
.then((rootTC) => {
detectChangesAndCheck(rootTC, 'ng-binding foo');
rootTC.componentInstance.objExpr = null;
rootTC.debugElement.componentInstance.objExpr = null;
detectChangesAndCheck(rootTC, 'ng-binding');
rootTC.componentInstance.objExpr = {'foo': false, 'bar': true};
rootTC.debugElement.componentInstance.objExpr = {'foo': false, 'bar': true};
detectChangesAndCheck(rootTC, 'ng-binding bar');
async.done();
@ -172,7 +174,7 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
var arrExpr: string[] = rootTC.componentInstance.arrExpr;
var arrExpr: string[] = rootTC.debugElement.componentInstance.arrExpr;
detectChangesAndCheck(rootTC, 'ng-binding foo');
arrExpr.push('bar');
@ -181,7 +183,7 @@ export function main() {
arrExpr[1] = 'baz';
detectChangesAndCheck(rootTC, 'ng-binding foo baz');
ListWrapper.remove(rootTC.componentInstance.arrExpr, 'baz');
ListWrapper.remove(rootTC.debugElement.componentInstance.arrExpr, 'baz');
detectChangesAndCheck(rootTC, 'ng-binding foo');
async.done();
@ -197,7 +199,7 @@ export function main() {
.then((rootTC) => {
detectChangesAndCheck(rootTC, 'ng-binding foo');
rootTC.componentInstance.arrExpr = ['bar'];
rootTC.debugElement.componentInstance.arrExpr = ['bar'];
detectChangesAndCheck(rootTC, 'ng-binding bar');
async.done();
@ -213,7 +215,7 @@ export function main() {
.then((rootTC) => {
detectChangesAndCheck(rootTC, 'foo ng-binding');
rootTC.componentInstance.arrExpr = ['bar'];
rootTC.debugElement.componentInstance.arrExpr = ['bar'];
detectChangesAndCheck(rootTC, 'ng-binding foo bar');
async.done();
@ -244,11 +246,11 @@ export function main() {
.then((rootTC) => {
detectChangesAndCheck(rootTC, 'ng-binding foo');
rootTC.componentInstance.strExpr = 'foo bar';
rootTC.debugElement.componentInstance.strExpr = 'foo bar';
detectChangesAndCheck(rootTC, 'ng-binding foo bar');
rootTC.componentInstance.strExpr = 'baz';
rootTC.debugElement.componentInstance.strExpr = 'baz';
detectChangesAndCheck(rootTC, 'ng-binding baz');
async.done();
@ -264,7 +266,7 @@ export function main() {
.then((rootTC) => {
detectChangesAndCheck(rootTC, 'ng-binding foo');
rootTC.componentInstance.strExpr = null;
rootTC.debugElement.componentInstance.strExpr = null;
detectChangesAndCheck(rootTC, 'ng-binding');
async.done();
@ -280,7 +282,7 @@ export function main() {
.then((rootTC) => {
detectChangesAndCheck(rootTC, 'foo ng-binding');
rootTC.componentInstance.strExpr = null;
rootTC.debugElement.componentInstance.strExpr = null;
detectChangesAndCheck(rootTC, 'ng-binding foo');
async.done();
@ -298,13 +300,13 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
StringMapWrapper.set(rootTC.componentInstance.objExpr, 'bar', true);
StringMapWrapper.set(rootTC.debugElement.componentInstance.objExpr, 'bar', true);
detectChangesAndCheck(rootTC, 'init foo ng-binding bar');
StringMapWrapper.set(rootTC.componentInstance.objExpr, 'foo', false);
StringMapWrapper.set(rootTC.debugElement.componentInstance.objExpr, 'foo', false);
detectChangesAndCheck(rootTC, 'init ng-binding bar');
rootTC.componentInstance.objExpr = null;
rootTC.debugElement.componentInstance.objExpr = null;
detectChangesAndCheck(rootTC, 'init ng-binding foo');
async.done();
@ -318,13 +320,13 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
StringMapWrapper.set(rootTC.componentInstance.objExpr, 'bar', true);
StringMapWrapper.set(rootTC.debugElement.componentInstance.objExpr, 'bar', true);
detectChangesAndCheck(rootTC, `{{'init foo'}} ng-binding init foo bar`);
StringMapWrapper.set(rootTC.componentInstance.objExpr, 'foo', false);
StringMapWrapper.set(rootTC.debugElement.componentInstance.objExpr, 'foo', false);
detectChangesAndCheck(rootTC, `{{'init foo'}} ng-binding init bar`);
rootTC.componentInstance.objExpr = null;
rootTC.debugElement.componentInstance.objExpr = null;
detectChangesAndCheck(rootTC, `{{'init foo'}} ng-binding init foo`);
async.done();
@ -338,13 +340,13 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
StringMapWrapper.set(rootTC.componentInstance.objExpr, 'bar', true);
StringMapWrapper.set(rootTC.debugElement.componentInstance.objExpr, 'bar', true);
detectChangesAndCheck(rootTC, `init ng-binding foo bar`);
StringMapWrapper.set(rootTC.componentInstance.objExpr, 'foo', false);
StringMapWrapper.set(rootTC.debugElement.componentInstance.objExpr, 'foo', false);
detectChangesAndCheck(rootTC, `init ng-binding bar`);
rootTC.componentInstance.objExpr = null;
rootTC.debugElement.componentInstance.objExpr = null;
detectChangesAndCheck(rootTC, `init ng-binding foo`);
async.done();
@ -361,13 +363,13 @@ export function main() {
.then((rootTC) => {
detectChangesAndCheck(rootTC, 'init foo ng-binding baz');
StringMapWrapper.set(rootTC.componentInstance.objExpr, 'bar', true);
StringMapWrapper.set(rootTC.debugElement.componentInstance.objExpr, 'bar', true);
detectChangesAndCheck(rootTC, 'init foo ng-binding baz bar');
StringMapWrapper.set(rootTC.componentInstance.objExpr, 'foo', false);
StringMapWrapper.set(rootTC.debugElement.componentInstance.objExpr, 'foo', false);
detectChangesAndCheck(rootTC, 'init ng-binding baz bar');
rootTC.componentInstance.condition = false;
rootTC.debugElement.componentInstance.condition = false;
detectChangesAndCheck(rootTC, 'init ng-binding bar');
async.done();
@ -383,13 +385,13 @@ export function main() {
.then((rootTC) => {
detectChangesAndCheck(rootTC, 'init ng-binding foo');
StringMapWrapper.set(rootTC.componentInstance.objExpr, 'bar', true);
StringMapWrapper.set(rootTC.debugElement.componentInstance.objExpr, 'bar', true);
detectChangesAndCheck(rootTC, 'init ng-binding foo bar');
rootTC.componentInstance.strExpr = 'baz';
rootTC.debugElement.componentInstance.strExpr = 'baz';
detectChangesAndCheck(rootTC, 'init ng-binding bar baz foo');
rootTC.componentInstance.objExpr = null;
rootTC.debugElement.componentInstance.objExpr = null;
detectChangesAndCheck(rootTC, 'init ng-binding baz');
async.done();

View File

@ -31,7 +31,7 @@ export function main() {
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('1;2;');
expect(rootTC.debugElement.nativeElement).toHaveText('1;2;');
async.done();
});
}));
@ -43,10 +43,10 @@ export function main() {
.then((rootTC) => {
rootTC.detectChanges();
(<number[]>rootTC.componentInstance.items).push(3);
(<number[]>rootTC.debugElement.componentInstance.items).push(3);
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('1;2;3;');
expect(rootTC.debugElement.nativeElement).toHaveText('1;2;3;');
async.done();
});
}));
@ -58,10 +58,10 @@ export function main() {
.then((rootTC) => {
rootTC.detectChanges();
ListWrapper.removeAt(rootTC.componentInstance.items, 1);
ListWrapper.removeAt(rootTC.debugElement.componentInstance.items, 1);
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('1;');
expect(rootTC.debugElement.nativeElement).toHaveText('1;');
async.done();
});
}));
@ -73,11 +73,11 @@ export function main() {
.then((rootTC) => {
rootTC.detectChanges();
ListWrapper.removeAt(rootTC.componentInstance.items, 0);
(<number[]>rootTC.componentInstance.items).push(1);
ListWrapper.removeAt(rootTC.debugElement.componentInstance.items, 0);
(<number[]>rootTC.debugElement.componentInstance.items).push(1);
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('2;1;');
expect(rootTC.debugElement.nativeElement).toHaveText('2;1;');
async.done();
});
}));
@ -87,13 +87,13 @@ export function main() {
tcb.overrideTemplate(TestComponent, TEMPLATE)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.componentInstance.items = [0, 1, 2, 3, 4, 5];
rootTC.debugElement.componentInstance.items = [0, 1, 2, 3, 4, 5];
rootTC.detectChanges();
rootTC.componentInstance.items = [6, 2, 7, 0, 4, 8];
rootTC.debugElement.componentInstance.items = [6, 2, 7, 0, 4, 8];
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('6;2;7;0;4;8;');
expect(rootTC.debugElement.nativeElement).toHaveText('6;2;7;0;4;8;');
async.done();
});
}));
@ -107,22 +107,22 @@ export function main() {
.then((rootTC) => {
// INIT
rootTC.componentInstance.items = [{'name': 'misko'}, {'name': 'shyam'}];
rootTC.debugElement.componentInstance.items = [{'name': 'misko'}, {'name': 'shyam'}];
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('misko;shyam;');
expect(rootTC.debugElement.nativeElement).toHaveText('misko;shyam;');
// GROW
(<any[]>rootTC.componentInstance.items).push({'name': 'adam'});
(<any[]>rootTC.debugElement.componentInstance.items).push({'name': 'adam'});
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('misko;shyam;adam;');
expect(rootTC.debugElement.nativeElement).toHaveText('misko;shyam;adam;');
// SHRINK
ListWrapper.removeAt(rootTC.componentInstance.items, 2);
ListWrapper.removeAt(rootTC.componentInstance.items, 0);
ListWrapper.removeAt(rootTC.debugElement.componentInstance.items, 2);
ListWrapper.removeAt(rootTC.debugElement.componentInstance.items, 0);
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('shyam;');
expect(rootTC.debugElement.nativeElement).toHaveText('shyam;');
async.done();
});
}));
@ -134,7 +134,7 @@ export function main() {
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('');
expect(rootTC.debugElement.nativeElement).toHaveText('');
async.done();
});
}));
@ -145,15 +145,15 @@ export function main() {
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('1;2;');
expect(rootTC.debugElement.nativeElement).toHaveText('1;2;');
rootTC.componentInstance.items = null;
rootTC.debugElement.componentInstance.items = null;
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('');
expect(rootTC.debugElement.nativeElement).toHaveText('');
rootTC.componentInstance.items = [1, 2, 3];
rootTC.debugElement.componentInstance.items = [1, 2, 3];
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('1;2;3;');
expect(rootTC.debugElement.nativeElement).toHaveText('1;2;3;');
async.done();
});
}));
@ -164,9 +164,9 @@ export function main() {
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('1;2;');
expect(rootTC.debugElement.nativeElement).toHaveText('1;2;');
rootTC.componentInstance.items = 'whaaa';
rootTC.debugElement.componentInstance.items = 'whaaa';
expect(() => rootTC.detectChanges()).toThrowError();
async.done();
});
@ -178,9 +178,9 @@ export function main() {
.createAsync(TestComponent)
.then((rootTC) => {
var a = new Foo();
rootTC.componentInstance.items = [a, a];
rootTC.debugElement.componentInstance.items = [a, a];
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('foo;foo;');
expect(rootTC.debugElement.nativeElement).toHaveText('foo;foo;');
async.done();
});
}));
@ -198,15 +198,15 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.componentInstance.items = [['a', 'b'], ['c']];
rootTC.debugElement.componentInstance.items = [['a', 'b'], ['c']];
rootTC.detectChanges();
rootTC.detectChanges();
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('a-2;b-2;|c-1;|');
expect(rootTC.debugElement.nativeElement).toHaveText('a-2;b-2;|c-1;|');
rootTC.componentInstance.items = [['e'], ['f', 'g']];
rootTC.debugElement.componentInstance.items = [['e'], ['f', 'g']];
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('e-1;|f-2;g-2;|');
expect(rootTC.debugElement.nativeElement).toHaveText('e-1;|f-2;g-2;|');
async.done();
});
@ -222,13 +222,13 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.componentInstance.items = [['a', 'b'], ['c']];
rootTC.debugElement.componentInstance.items = [['a', 'b'], ['c']];
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('a-2;b-2;c-1;');
expect(rootTC.debugElement.nativeElement).toHaveText('a-2;b-2;c-1;');
rootTC.componentInstance.items = [['e'], ['f', 'g']];
rootTC.debugElement.componentInstance.items = [['e'], ['f', 'g']];
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('e-1;f-2;g-2;');
expect(rootTC.debugElement.nativeElement).toHaveText('e-1;f-2;g-2;');
async.done();
});
}));
@ -241,13 +241,13 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.componentInstance.items = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
rootTC.debugElement.componentInstance.items = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('0123456789');
expect(rootTC.debugElement.nativeElement).toHaveText('0123456789');
rootTC.componentInstance.items = [1, 2, 6, 7, 4, 3, 5, 8, 9, 0];
rootTC.debugElement.componentInstance.items = [1, 2, 6, 7, 4, 3, 5, 8, 9, 0];
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('0123456789');
expect(rootTC.debugElement.nativeElement).toHaveText('0123456789');
async.done();
});
}));
@ -260,13 +260,13 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.componentInstance.items = [0, 1, 2];
rootTC.debugElement.componentInstance.items = [0, 1, 2];
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('falsefalsetrue');
expect(rootTC.debugElement.nativeElement).toHaveText('falsefalsetrue');
rootTC.componentInstance.items = [2, 1];
rootTC.debugElement.componentInstance.items = [2, 1];
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('falsetrue');
expect(rootTC.debugElement.nativeElement).toHaveText('falsetrue');
async.done();
});
}));

View File

@ -28,8 +28,9 @@ export function main() {
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.detectChanges();
expect(DOM.querySelectorAll(rootTC.nativeElement, 'copy-me').length).toEqual(1);
expect(rootTC.nativeElement).toHaveText('hello');
expect(DOM.querySelectorAll(rootTC.debugElement.nativeElement, 'copy-me').length)
.toEqual(1);
expect(rootTC.debugElement.nativeElement).toHaveText('hello');
async.done();
});
}));
@ -43,8 +44,9 @@ export function main() {
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.detectChanges();
expect(DOM.querySelectorAll(rootTC.nativeElement, 'copy-me').length).toEqual(1);
expect(rootTC.nativeElement).toHaveText('hello2');
expect(DOM.querySelectorAll(rootTC.debugElement.nativeElement, 'copy-me').length)
.toEqual(1);
expect(rootTC.debugElement.nativeElement).toHaveText('hello2');
async.done();
});
}));
@ -56,20 +58,23 @@ export function main() {
tcb.overrideTemplate(TestComponent, html)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.componentInstance.booleanCondition = false;
rootTC.debugElement.componentInstance.booleanCondition = false;
rootTC.detectChanges();
expect(DOM.querySelectorAll(rootTC.nativeElement, 'copy-me').length).toEqual(0);
expect(rootTC.nativeElement).toHaveText('');
expect(DOM.querySelectorAll(rootTC.debugElement.nativeElement, 'copy-me').length)
.toEqual(0);
expect(rootTC.debugElement.nativeElement).toHaveText('');
rootTC.componentInstance.booleanCondition = true;
rootTC.debugElement.componentInstance.booleanCondition = true;
rootTC.detectChanges();
expect(DOM.querySelectorAll(rootTC.nativeElement, 'copy-me').length).toEqual(1);
expect(rootTC.nativeElement).toHaveText('hello');
expect(DOM.querySelectorAll(rootTC.debugElement.nativeElement, 'copy-me').length)
.toEqual(1);
expect(rootTC.debugElement.nativeElement).toHaveText('hello');
rootTC.componentInstance.booleanCondition = false;
rootTC.debugElement.componentInstance.booleanCondition = false;
rootTC.detectChanges();
expect(DOM.querySelectorAll(rootTC.nativeElement, 'copy-me').length).toEqual(0);
expect(rootTC.nativeElement).toHaveText('');
expect(DOM.querySelectorAll(rootTC.debugElement.nativeElement, 'copy-me').length)
.toEqual(0);
expect(rootTC.debugElement.nativeElement).toHaveText('');
async.done();
});
@ -83,30 +88,35 @@ export function main() {
tcb.overrideTemplate(TestComponent, html)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.componentInstance.booleanCondition = false;
rootTC.debugElement.componentInstance.booleanCondition = false;
rootTC.detectChanges();
expect(DOM.querySelectorAll(rootTC.nativeElement, 'copy-me').length).toEqual(0);
expect(rootTC.nativeElement).toHaveText('');
expect(DOM.querySelectorAll(rootTC.debugElement.nativeElement, 'copy-me').length)
.toEqual(0);
expect(rootTC.debugElement.nativeElement).toHaveText('');
rootTC.componentInstance.booleanCondition = true;
rootTC.debugElement.componentInstance.booleanCondition = true;
rootTC.detectChanges();
expect(DOM.querySelectorAll(rootTC.nativeElement, 'copy-me').length).toEqual(1);
expect(rootTC.nativeElement).toHaveText('hello');
expect(DOM.querySelectorAll(rootTC.debugElement.nativeElement, 'copy-me').length)
.toEqual(1);
expect(rootTC.debugElement.nativeElement).toHaveText('hello');
rootTC.componentInstance.nestedBooleanCondition = false;
rootTC.debugElement.componentInstance.nestedBooleanCondition = false;
rootTC.detectChanges();
expect(DOM.querySelectorAll(rootTC.nativeElement, 'copy-me').length).toEqual(0);
expect(rootTC.nativeElement).toHaveText('');
expect(DOM.querySelectorAll(rootTC.debugElement.nativeElement, 'copy-me').length)
.toEqual(0);
expect(rootTC.debugElement.nativeElement).toHaveText('');
rootTC.componentInstance.nestedBooleanCondition = true;
rootTC.debugElement.componentInstance.nestedBooleanCondition = true;
rootTC.detectChanges();
expect(DOM.querySelectorAll(rootTC.nativeElement, 'copy-me').length).toEqual(1);
expect(rootTC.nativeElement).toHaveText('hello');
expect(DOM.querySelectorAll(rootTC.debugElement.nativeElement, 'copy-me').length)
.toEqual(1);
expect(rootTC.debugElement.nativeElement).toHaveText('hello');
rootTC.componentInstance.booleanCondition = false;
rootTC.debugElement.componentInstance.booleanCondition = false;
rootTC.detectChanges();
expect(DOM.querySelectorAll(rootTC.nativeElement, 'copy-me').length).toEqual(0);
expect(rootTC.nativeElement).toHaveText('');
expect(DOM.querySelectorAll(rootTC.debugElement.nativeElement, 'copy-me').length)
.toEqual(0);
expect(rootTC.debugElement.nativeElement).toHaveText('');
async.done();
});
@ -125,20 +135,23 @@ export function main() {
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.detectChanges();
expect(DOM.querySelectorAll(rootTC.nativeElement, 'copy-me').length).toEqual(3);
expect(DOM.getText(rootTC.nativeElement))
expect(DOM.querySelectorAll(rootTC.debugElement.nativeElement, 'copy-me').length)
.toEqual(3);
expect(DOM.getText(rootTC.debugElement.nativeElement))
.toEqual('helloNumberhelloStringhelloFunction');
rootTC.componentInstance.numberCondition = 0;
rootTC.debugElement.componentInstance.numberCondition = 0;
rootTC.detectChanges();
expect(DOM.querySelectorAll(rootTC.nativeElement, 'copy-me').length).toEqual(1);
expect(rootTC.nativeElement).toHaveText('helloString');
expect(DOM.querySelectorAll(rootTC.debugElement.nativeElement, 'copy-me').length)
.toEqual(1);
expect(rootTC.debugElement.nativeElement).toHaveText('helloString');
rootTC.componentInstance.numberCondition = 1;
rootTC.componentInstance.stringCondition = "bar";
rootTC.debugElement.componentInstance.numberCondition = 1;
rootTC.debugElement.componentInstance.stringCondition = "bar";
rootTC.detectChanges();
expect(DOM.querySelectorAll(rootTC.nativeElement, 'copy-me').length).toEqual(1);
expect(rootTC.nativeElement).toHaveText('helloNumber');
expect(DOM.querySelectorAll(rootTC.debugElement.nativeElement, 'copy-me').length)
.toEqual(1);
expect(rootTC.debugElement.nativeElement).toHaveText('helloNumber');
async.done();
});
}));
@ -153,13 +166,15 @@ export function main() {
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.detectChanges();
expect(DOM.querySelectorAll(rootTC.nativeElement, 'copy-me').length).toEqual(1);
expect(rootTC.nativeElement).toHaveText('hello');
expect(DOM.querySelectorAll(rootTC.debugElement.nativeElement, 'copy-me').length)
.toEqual(1);
expect(rootTC.debugElement.nativeElement).toHaveText('hello');
rootTC.componentInstance.numberCondition = 2;
rootTC.debugElement.componentInstance.numberCondition = 2;
rootTC.detectChanges();
expect(DOM.querySelectorAll(rootTC.nativeElement, 'copy-me').length).toEqual(1);
expect(rootTC.nativeElement).toHaveText('hello');
expect(DOM.querySelectorAll(rootTC.debugElement.nativeElement, 'copy-me').length)
.toEqual(1);
expect(rootTC.debugElement.nativeElement).toHaveText('hello');
async.done();
});
@ -173,11 +188,13 @@ export function main() {
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.detectChanges();
DOM.addClass(DOM.querySelector(rootTC.nativeElement, 'copy-me'), "foo");
DOM.addClass(DOM.querySelector(rootTC.debugElement.nativeElement, 'copy-me'),
"foo");
rootTC.componentInstance.numberCondition = 2;
rootTC.debugElement.componentInstance.numberCondition = 2;
rootTC.detectChanges();
expect(DOM.hasClass(DOM.querySelector(rootTC.nativeElement, 'copy-me'), "foo"))
expect(DOM.hasClass(
DOM.querySelector(rootTC.debugElement.nativeElement, 'copy-me'), "foo"))
.toBe(true);
async.done();
@ -194,8 +211,9 @@ export function main() {
.createAsync(TestComponent)
.then((rootTC) => {
expect(() => rootTC.detectChanges()).toThrowError();
expect(DOM.querySelectorAll(rootTC.nativeElement, 'copy-me').length).toEqual(0);
expect(rootTC.nativeElement).toHaveText('');
expect(DOM.querySelectorAll(rootTC.debugElement.nativeElement, 'copy-me').length)
.toEqual(0);
expect(rootTC.debugElement.nativeElement).toHaveText('');
async.done();
});
}));

View File

@ -32,7 +32,8 @@ export function main() {
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.detectChanges();
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'max-width'))
expect(DOM.getStyle(rootTC.debugElement.componentViewChildren[0].nativeElement,
'max-width'))
.toEqual('40px');
async.done();
@ -48,15 +49,17 @@ export function main() {
.then((rootTC) => {
var expr: Map<string, any>;
rootTC.componentInstance.expr = {'max-width': '40px'};
rootTC.debugElement.componentInstance.expr = {'max-width': '40px'};
rootTC.detectChanges();
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'max-width'))
expect(DOM.getStyle(rootTC.debugElement.componentViewChildren[0].nativeElement,
'max-width'))
.toEqual('40px');
expr = rootTC.componentInstance.expr;
expr = rootTC.debugElement.componentInstance.expr;
expr['max-width'] = '30%';
rootTC.detectChanges();
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'max-width'))
expect(DOM.getStyle(rootTC.debugElement.componentViewChildren[0].nativeElement,
'max-width'))
.toEqual('30%');
async.done();
@ -70,14 +73,16 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.componentInstance.expr = {'max-width': '40px'};
rootTC.debugElement.componentInstance.expr = {'max-width': '40px'};
rootTC.detectChanges();
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'max-width'))
expect(DOM.getStyle(rootTC.debugElement.componentViewChildren[0].nativeElement,
'max-width'))
.toEqual('40px');
StringMapWrapper.delete(rootTC.componentInstance.expr, 'max-width');
StringMapWrapper.delete(rootTC.debugElement.componentInstance.expr, 'max-width');
rootTC.detectChanges();
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'max-width'))
expect(DOM.getStyle(rootTC.debugElement.componentViewChildren[0].nativeElement,
'max-width'))
.toEqual('');
async.done();
@ -91,18 +96,22 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.componentInstance.expr = {'max-width': '40px'};
rootTC.debugElement.componentInstance.expr = {'max-width': '40px'};
rootTC.detectChanges();
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'max-width'))
expect(DOM.getStyle(rootTC.debugElement.componentViewChildren[0].nativeElement,
'max-width'))
.toEqual('40px');
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'font-size'))
expect(DOM.getStyle(rootTC.debugElement.componentViewChildren[0].nativeElement,
'font-size'))
.toEqual('12px');
StringMapWrapper.delete(rootTC.componentInstance.expr, 'max-width');
StringMapWrapper.delete(rootTC.debugElement.componentInstance.expr, 'max-width');
rootTC.detectChanges();
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'max-width'))
expect(DOM.getStyle(rootTC.debugElement.componentViewChildren[0].nativeElement,
'max-width'))
.toEqual('');
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'font-size'))
expect(DOM.getStyle(rootTC.debugElement.componentViewChildren[0].nativeElement,
'font-size'))
.toEqual('12px');
async.done();
@ -116,19 +125,23 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.componentInstance.expr = {'max-width': '40px'};
rootTC.debugElement.componentInstance.expr = {'max-width': '40px'};
rootTC.detectChanges();
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'max-width'))
expect(DOM.getStyle(rootTC.debugElement.componentViewChildren[0].nativeElement,
'max-width'))
.toEqual('40px');
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'font-size'))
expect(DOM.getStyle(rootTC.debugElement.componentViewChildren[0].nativeElement,
'font-size'))
.toEqual('12px');
StringMapWrapper.delete(rootTC.componentInstance.expr, 'max-width');
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'font-size'))
StringMapWrapper.delete(rootTC.debugElement.componentInstance.expr, 'max-width');
expect(DOM.getStyle(rootTC.debugElement.componentViewChildren[0].nativeElement,
'font-size'))
.toEqual('12px');
rootTC.detectChanges();
expect(DOM.getStyle(rootTC.componentViewChildren[0].nativeElement, 'max-width'))
expect(DOM.getStyle(rootTC.debugElement.componentViewChildren[0].nativeElement,
'max-width'))
.toEqual('');
async.done();

View File

@ -31,15 +31,15 @@ export function main() {
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('');
expect(rootTC.debugElement.nativeElement).toHaveText('');
rootTC.componentInstance.switchValue = 'a';
rootTC.debugElement.componentInstance.switchValue = 'a';
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('when a');
expect(rootTC.debugElement.nativeElement).toHaveText('when a');
rootTC.componentInstance.switchValue = 'b';
rootTC.debugElement.componentInstance.switchValue = 'b';
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('when b');
expect(rootTC.debugElement.nativeElement).toHaveText('when b');
async.done();
});
@ -57,15 +57,15 @@ export function main() {
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('when default');
expect(rootTC.debugElement.nativeElement).toHaveText('when default');
rootTC.componentInstance.switchValue = 'a';
rootTC.debugElement.componentInstance.switchValue = 'a';
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('when a');
expect(rootTC.debugElement.nativeElement).toHaveText('when a');
rootTC.componentInstance.switchValue = 'b';
rootTC.debugElement.componentInstance.switchValue = 'b';
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('when default');
expect(rootTC.debugElement.nativeElement).toHaveText('when default');
async.done();
});
@ -87,15 +87,16 @@ export function main() {
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('when default1;when default2;');
expect(rootTC.debugElement.nativeElement)
.toHaveText('when default1;when default2;');
rootTC.componentInstance.switchValue = 'a';
rootTC.debugElement.componentInstance.switchValue = 'a';
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('when a1;when a2;');
expect(rootTC.debugElement.nativeElement).toHaveText('when a1;when a2;');
rootTC.componentInstance.switchValue = 'b';
rootTC.debugElement.componentInstance.switchValue = 'b';
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('when b1;when b2;');
expect(rootTC.debugElement.nativeElement).toHaveText('when b1;when b2;');
async.done();
});
@ -115,27 +116,27 @@ export function main() {
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.componentInstance.when1 = 'a';
rootTC.componentInstance.when2 = 'b';
rootTC.componentInstance.switchValue = 'a';
rootTC.debugElement.componentInstance.when1 = 'a';
rootTC.debugElement.componentInstance.when2 = 'b';
rootTC.debugElement.componentInstance.switchValue = 'a';
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('when 1;');
expect(rootTC.debugElement.nativeElement).toHaveText('when 1;');
rootTC.componentInstance.switchValue = 'b';
rootTC.debugElement.componentInstance.switchValue = 'b';
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('when 2;');
expect(rootTC.debugElement.nativeElement).toHaveText('when 2;');
rootTC.componentInstance.switchValue = 'c';
rootTC.debugElement.componentInstance.switchValue = 'c';
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('when default;');
expect(rootTC.debugElement.nativeElement).toHaveText('when default;');
rootTC.componentInstance.when1 = 'c';
rootTC.debugElement.componentInstance.when1 = 'c';
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('when 1;');
expect(rootTC.debugElement.nativeElement).toHaveText('when 1;');
rootTC.componentInstance.when1 = 'd';
rootTC.debugElement.componentInstance.when1 = 'd';
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('when default;');
expect(rootTC.debugElement.nativeElement).toHaveText('when default;');
async.done();
});

View File

@ -24,7 +24,7 @@ export function main() {
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('foo{{text}}');
expect(rootTC.debugElement.nativeElement).toHaveText('foo{{text}}');
async.done();
});
}));
@ -39,7 +39,7 @@ export function main() {
// We must use DOM.querySelector instead of rootTC.query here
// since the elements inside are not compiled.
var span = DOM.querySelector(rootTC.nativeElement, '#child');
var span = DOM.querySelector(rootTC.debugElement.nativeElement, '#child');
expect(DOM.hasClass(span, 'compiled')).toBeFalsy();
async.done();
});
@ -52,7 +52,7 @@ export function main() {
.createAsync(TestComponent)
.then((rootTC) => {
rootTC.detectChanges();
var span = DOM.querySelector(rootTC.nativeElement, '#child');
var span = DOM.querySelector(rootTC.debugElement.nativeElement, '#child');
expect(DOM.hasClass(span, 'compiled')).toBeTruthy();
async.done();
});

View File

@ -1,5 +1,6 @@
import {Component, Directive, View} from 'angular2/angular2';
import {
RootTestComponent,
afterEach,
AsyncTestCompleter,
TestComponentBuilder,
@ -40,10 +41,11 @@ export function main() {
</div>`;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((rootTC) => {
rootTC.componentInstance.form = new ControlGroup({"login": new Control("loginValue")});
rootTC.debugElement.componentInstance.form =
new ControlGroup({"login": new Control("loginValue")});
rootTC.detectChanges();
var input = rootTC.query(By.css("input"));
var input = rootTC.debugElement.query(By.css("input"));
expect(input.nativeElement.value).toEqual("loginValue");
async.done();
});
@ -58,9 +60,9 @@ export function main() {
</div>`;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((rootTC) => {
rootTC.componentInstance.form = form;
rootTC.debugElement.componentInstance.form = form;
rootTC.detectChanges();
var input = rootTC.query(By.css("input"));
var input = rootTC.debugElement.query(By.css("input"));
input.nativeElement.value = "updatedValue";
dispatchEvent(input.nativeElement, "change");
@ -76,21 +78,21 @@ export function main() {
var t =
`<div><form [ng-form-model]="form" (ng-submit)="name='updated'"></form><span>{{name}}</span></div>`;
var rootTC;
var rootTC: RootTestComponent;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((root) => { rootTC = root; });
tick();
rootTC.componentInstance.form = new ControlGroup({});
rootTC.componentInstance.name = 'old';
rootTC.debugElement.componentInstance.form = new ControlGroup({});
rootTC.debugElement.componentInstance.name = 'old';
tick();
var form = rootTC.query(By.css("form"));
var form = rootTC.debugElement.query(By.css("form"));
dispatchEvent(form.nativeElement, "submit");
tick();
expect(rootTC.componentInstance.name).toEqual('updated');
expect(rootTC.debugElement.componentInstance.name).toEqual('updated');
})));
it("should work with single controls",
@ -100,10 +102,10 @@ export function main() {
var t = `<div><input type="text" [ng-form-control]="form"></div>`;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((rootTC) => {
rootTC.componentInstance.form = control;
rootTC.debugElement.componentInstance.form = control;
rootTC.detectChanges();
var input = rootTC.query(By.css("input"));
var input = rootTC.debugElement.query(By.css("input"));
expect(input.nativeElement.value).toEqual("loginValue");
input.nativeElement.value = "updatedValue";
@ -121,13 +123,15 @@ export function main() {
</div>`;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((rootTC) => {
rootTC.componentInstance.form = new ControlGroup({"login": new Control("oldValue")});
rootTC.debugElement.componentInstance.form =
new ControlGroup({"login": new Control("oldValue")});
rootTC.detectChanges();
rootTC.componentInstance.form = new ControlGroup({"login": new Control("newValue")});
rootTC.debugElement.componentInstance.form =
new ControlGroup({"login": new Control("newValue")});
rootTC.detectChanges();
var input = rootTC.query(By.css("input"));
var input = rootTC.debugElement.query(By.css("input"));
expect(input.nativeElement.value).toEqual("newValue");
async.done();
});
@ -143,14 +147,14 @@ export function main() {
</div>`;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((rootTC) => {
rootTC.componentInstance.form = form;
rootTC.debugElement.componentInstance.form = form;
rootTC.detectChanges();
login.updateValue("newValue");
rootTC.detectChanges();
var input = rootTC.query(By.css("input"));
var input = rootTC.debugElement.query(By.css("input"));
expect(input.nativeElement.value).toEqual("newValue");
async.done();
});
@ -166,10 +170,10 @@ export function main() {
</div>`;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((rootTC) => {
rootTC.componentInstance.form = form;
rootTC.debugElement.componentInstance.form = form;
rootTC.detectChanges();
var loginEl = rootTC.query(By.css("input"));
var loginEl = rootTC.debugElement.query(By.css("input"));
expect(login.touched).toBe(false);
dispatchEvent(loginEl.nativeElement, "blur");
@ -188,16 +192,17 @@ export function main() {
</div>`;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((rootTC) => {
rootTC.componentInstance.form = new ControlGroup({"text": new Control("old")});
rootTC.debugElement.componentInstance.form =
new ControlGroup({"text": new Control("old")});
rootTC.detectChanges();
var input = rootTC.query(By.css("input"));
var input = rootTC.debugElement.query(By.css("input"));
expect(input.nativeElement.value).toEqual("old");
input.nativeElement.value = "new";
dispatchEvent(input.nativeElement, "input");
expect(rootTC.componentInstance.form.value).toEqual({"text": "new"});
expect(rootTC.debugElement.componentInstance.form.value).toEqual({"text": "new"});
async.done();
});
}));
@ -209,15 +214,16 @@ export function main() {
</div>`;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((rootTC) => {
rootTC.componentInstance.form = new ControlGroup({"text": new Control("old")});
rootTC.debugElement.componentInstance.form =
new ControlGroup({"text": new Control("old")});
rootTC.detectChanges();
var input = rootTC.query(By.css("input"));
var input = rootTC.debugElement.query(By.css("input"));
expect(input.nativeElement.value).toEqual("old");
input.nativeElement.value = "new";
dispatchEvent(input.nativeElement, "input");
expect(rootTC.componentInstance.form.value).toEqual({"text": "new"});
expect(rootTC.debugElement.componentInstance.form.value).toEqual({"text": "new"});
async.done();
});
}));
@ -229,16 +235,17 @@ export function main() {
</div>`;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((rootTC) => {
rootTC.componentInstance.form = new ControlGroup({"text": new Control('old')});
rootTC.debugElement.componentInstance.form =
new ControlGroup({"text": new Control('old')});
rootTC.detectChanges();
var textarea = rootTC.query(By.css("textarea"));
var textarea = rootTC.debugElement.query(By.css("textarea"));
expect(textarea.nativeElement.value).toEqual("old");
textarea.nativeElement.value = "new";
dispatchEvent(textarea.nativeElement, "input");
expect(rootTC.componentInstance.form.value).toEqual({"text": 'new'});
expect(rootTC.debugElement.componentInstance.form.value).toEqual({"text": 'new'});
async.done();
});
}));
@ -250,16 +257,17 @@ export function main() {
</div>`;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((rootTC) => {
rootTC.componentInstance.form = new ControlGroup({"checkbox": new Control(true)});
rootTC.debugElement.componentInstance.form =
new ControlGroup({"checkbox": new Control(true)});
rootTC.detectChanges();
var input = rootTC.query(By.css("input"));
var input = rootTC.debugElement.query(By.css("input"));
expect(input.nativeElement.checked).toBe(true);
input.nativeElement.checked = false;
dispatchEvent(input.nativeElement, "change");
expect(rootTC.componentInstance.form.value).toEqual({"checkbox": false});
expect(rootTC.debugElement.componentInstance.form.value).toEqual({"checkbox": false});
async.done();
});
}));
@ -274,18 +282,19 @@ export function main() {
</div>`;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((rootTC) => {
rootTC.componentInstance.form = new ControlGroup({"city": new Control("SF")});
rootTC.debugElement.componentInstance.form =
new ControlGroup({"city": new Control("SF")});
rootTC.detectChanges();
var select = rootTC.query(By.css("select"));
var sfOption = rootTC.query(By.css("option"));
var select = rootTC.debugElement.query(By.css("select"));
var sfOption = rootTC.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.componentInstance.form.value).toEqual({"city": 'NYC'});
expect(rootTC.debugElement.componentInstance.form.value).toEqual({"city": 'NYC'});
expect(sfOption.nativeElement.selected).toBe(false);
async.done();
});
@ -300,11 +309,12 @@ export function main() {
</div>`;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((rootTC) => {
rootTC.componentInstance.form = new ControlGroup({"city": new Control("NYC")});
rootTC.componentInstance.data = ['SF', 'NYC'];
rootTC.debugElement.componentInstance.form =
new ControlGroup({"city": new Control("NYC")});
rootTC.debugElement.componentInstance.data = ['SF', 'NYC'];
rootTC.detectChanges();
var select = rootTC.query(By.css('select'));
var select = rootTC.debugElement.query(By.css('select'));
expect(select.nativeElement.value).toEqual('NYC');
async.done();
});
@ -317,15 +327,16 @@ export function main() {
</div>`;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((rootTC) => {
rootTC.componentInstance.form = new ControlGroup({"name": new Control("aa")});
rootTC.debugElement.componentInstance.form =
new ControlGroup({"name": new Control("aa")});
rootTC.detectChanges();
var input = rootTC.query(By.css("input"));
var input = rootTC.debugElement.query(By.css("input"));
expect(input.nativeElement.value).toEqual("!aa!");
input.nativeElement.value = "!bb!";
dispatchEvent(input.nativeElement, "change");
expect(rootTC.componentInstance.form.value).toEqual({"name": "bb"});
expect(rootTC.debugElement.componentInstance.form.value).toEqual({"name": "bb"});
async.done();
});
}));
@ -341,11 +352,11 @@ export function main() {
</div>`;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((rootTC) => {
rootTC.componentInstance.form = form;
rootTC.debugElement.componentInstance.form = form;
rootTC.detectChanges();
expect(form.valid).toEqual(true);
var input = rootTC.query(By.css("input"));
var input = rootTC.debugElement.query(By.css("input"));
input.nativeElement.value = "";
dispatchEvent(input.nativeElement, "change");
@ -364,11 +375,11 @@ export function main() {
</div>`;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((rootTC) => {
rootTC.componentInstance.form = form;
rootTC.debugElement.componentInstance.form = form;
rootTC.detectChanges();
expect(form.valid).toEqual(true);
var input = rootTC.query(By.css("input"));
var input = rootTC.debugElement.query(By.css("input"));
input.nativeElement.value = "";
dispatchEvent(input.nativeElement, "change");
@ -392,10 +403,10 @@ export function main() {
</div>`;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((rootTC) => {
rootTC.componentInstance.form = form;
rootTC.debugElement.componentInstance.form = form;
rootTC.detectChanges();
var input = rootTC.query(By.css("input"));
var input = rootTC.debugElement.query(By.css("input"));
expect(input.nativeElement.value).toEqual("value");
async.done();
});
@ -413,9 +424,9 @@ export function main() {
</div>`;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((rootTC) => {
rootTC.componentInstance.form = form;
rootTC.debugElement.componentInstance.form = form;
rootTC.detectChanges();
var input = rootTC.query(By.css("input"));
var input = rootTC.debugElement.query(By.css("input"));
input.nativeElement.value = "updatedValue";
dispatchEvent(input.nativeElement, "change");
@ -434,22 +445,22 @@ export function main() {
var t =
`<div [ng-form-model]="form"><input type="text" ng-control="name" [(ng-model)]="name"></div>`;
var rootTC;
var rootTC: RootTestComponent;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((root) => { rootTC = root; });
tick();
rootTC.componentInstance.name = 'oldValue';
rootTC.componentInstance.form = form;
rootTC.debugElement.componentInstance.name = 'oldValue';
rootTC.debugElement.componentInstance.form = form;
rootTC.detectChanges();
var input = rootTC.query(By.css("input")).nativeElement;
var input = rootTC.debugElement.query(By.css("input")).nativeElement;
expect(input.value).toEqual("oldValue");
input.value = "updatedValue";
dispatchEvent(input, "change");
tick();
expect(rootTC.componentInstance.name).toEqual("updatedValue");
expect(rootTC.debugElement.componentInstance.name).toEqual("updatedValue");
})));
it("should support ng-model for single fields",
@ -459,21 +470,21 @@ export function main() {
var t = `<div><input type="text" [ng-form-control]="form" [(ng-model)]="name"></div>`;
var rootTC;
var rootTC: RootTestComponent;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((root) => { rootTC = root; });
tick();
rootTC.componentInstance.form = form;
rootTC.componentInstance.name = "oldValue";
rootTC.debugElement.componentInstance.form = form;
rootTC.debugElement.componentInstance.name = "oldValue";
rootTC.detectChanges();
var input = rootTC.query(By.css("input")).nativeElement;
var input = rootTC.debugElement.query(By.css("input")).nativeElement;
expect(input.value).toEqual("oldValue");
input.value = "updatedValue";
dispatchEvent(input, "change");
tick();
expect(rootTC.componentInstance.name).toEqual("updatedValue");
expect(rootTC.debugElement.componentInstance.name).toEqual("updatedValue");
})));
describe("template-driven forms", () => {
@ -485,14 +496,14 @@ export function main() {
</div>
</form>`;
var rootTC;
var rootTC: RootTestComponent;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then(
(root) => { rootTC = root; });
tick();
rootTC.componentInstance.name = null;
rootTC.debugElement.componentInstance.name = null;
rootTC.detectChanges();
var form = rootTC.componentViewChildren[0].inject(NgForm);
var form = rootTC.debugElement.componentViewChildren[0].inject(NgForm);
expect(form.controls['user']).not.toBeDefined();
tick();
@ -505,17 +516,17 @@ export function main() {
inject([TestComponentBuilder], fakeAsync((tcb: TestComponentBuilder) => {
var t = `<div><form (ng-submit)="name='updated'"></form></div>`;
var rootTC;
var rootTC: RootTestComponent;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then(
(root) => { rootTC = root; });
tick();
rootTC.componentInstance.name = 'old';
var form = rootTC.query(By.css("form"));
rootTC.debugElement.componentInstance.name = 'old';
var form = rootTC.debugElement.query(By.css("form"));
dispatchEvent(form.nativeElement, "submit");
tick();
expect(rootTC.componentInstance.name).toEqual("updated");
expect(rootTC.debugElement.componentInstance.name).toEqual("updated");
})));
it("should not create a template-driven form when ng-no-form is used",
@ -524,10 +535,10 @@ export function main() {
</form>`;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((rootTC) => {
rootTC.componentInstance.name = null;
rootTC.debugElement.componentInstance.name = null;
rootTC.detectChanges();
expect(rootTC.componentViewChildren.length).toEqual(0);
expect(rootTC.debugElement.componentViewChildren.length).toEqual(0);
async.done();
});
}));
@ -540,19 +551,19 @@ export function main() {
</div>
</form>`;
var rootTC;
var rootTC: RootTestComponent;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then(
(root) => { rootTC = root; });
tick();
rootTC.componentInstance.name = 'show';
rootTC.debugElement.componentInstance.name = 'show';
rootTC.detectChanges();
tick();
var form = rootTC.componentViewChildren[0].inject(NgForm);
var form = rootTC.debugElement.componentViewChildren[0].inject(NgForm);
expect(form.controls['login']).toBeDefined();
rootTC.componentInstance.name = 'hide';
rootTC.debugElement.componentInstance.name = 'hide';
rootTC.detectChanges();
tick();
@ -568,18 +579,18 @@ export function main() {
</form>`;
var rootTC;
var rootTC: RootTestComponent;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then(
(root) => { rootTC = root; });
tick();
rootTC.componentInstance.name = 'show';
rootTC.debugElement.componentInstance.name = 'show';
rootTC.detectChanges();
tick();
var form = rootTC.componentViewChildren[0].inject(NgForm);
var form = rootTC.debugElement.componentViewChildren[0].inject(NgForm);
expect(form.controls['user']).toBeDefined();
rootTC.componentInstance.name = 'hide';
rootTC.debugElement.componentInstance.name = 'hide';
rootTC.detectChanges();
tick();
@ -592,22 +603,22 @@ export function main() {
<input type="text" ng-control="name" [(ng-model)]="name">
</form>`;
var rootTC;
var rootTC: RootTestComponent;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then(
(root) => { rootTC = root; });
tick();
rootTC.componentInstance.name = "oldValue";
rootTC.debugElement.componentInstance.name = "oldValue";
rootTC.detectChanges();
tick();
var input = rootTC.query(By.css("input")).nativeElement;
var input = rootTC.debugElement.query(By.css("input")).nativeElement;
expect(input.value).toEqual("oldValue");
input.value = "updatedValue";
dispatchEvent(input, "change");
tick();
expect(rootTC.componentInstance.name).toEqual("updatedValue");
expect(rootTC.debugElement.componentInstance.name).toEqual("updatedValue");
})));
@ -615,21 +626,21 @@ export function main() {
inject([TestComponentBuilder], fakeAsync((tcb: TestComponentBuilder) => {
var t = `<div><input type="text" [(ng-model)]="name"></div>`;
var rootTC;
var rootTC: RootTestComponent;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then(
(root) => { rootTC = root; });
tick();
rootTC.componentInstance.name = "oldValue";
rootTC.debugElement.componentInstance.name = "oldValue";
rootTC.detectChanges();
var input = rootTC.query(By.css("input")).nativeElement;
var input = rootTC.debugElement.query(By.css("input")).nativeElement;
expect(input.value).toEqual("oldValue");
input.value = "updatedValue";
dispatchEvent(input, "change");
tick();
expect(rootTC.componentInstance.name).toEqual("updatedValue");
expect(rootTC.debugElement.componentInstance.name).toEqual("updatedValue");
})));
});
@ -642,10 +653,10 @@ export function main() {
var t = `<div><input type="text" [ng-form-control]="form"></div>`;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((rootTC) => {
rootTC.componentInstance.form = form;
rootTC.debugElement.componentInstance.form = form;
rootTC.detectChanges();
var input = rootTC.query(By.css("input")).nativeElement;
var input = rootTC.debugElement.query(By.css("input")).nativeElement;
expect(DOM.classList(input))
.toEqual(['ng-binding', 'ng-invalid', 'ng-pristine', 'ng-untouched']);
@ -672,10 +683,10 @@ 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.componentInstance.form = form;
rootTC.debugElement.componentInstance.form = form;
rootTC.detectChanges();
var input = rootTC.query(By.css("input")).nativeElement;
var input = rootTC.debugElement.query(By.css("input")).nativeElement;
expect(DOM.classList(input))
.toEqual(["ng-binding", "ng-invalid", "ng-pristine", "ng-untouched"]);
@ -700,10 +711,10 @@ export function main() {
var t = `<div><input [(ng-model)]="name" required></div>`;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((rootTC) => {
rootTC.componentInstance.name = "";
rootTC.debugElement.componentInstance.name = "";
rootTC.detectChanges();
var input = rootTC.query(By.css("input")).nativeElement;
var input = rootTC.debugElement.query(By.css("input")).nativeElement;
expect(DOM.classList(input))
.toEqual(["ng-binding", "ng-invalid", "ng-pristine", "ng-untouched"]);
@ -731,21 +742,21 @@ export function main() {
var t =
`<div><input type="text" [ng-form-control]="form" [(ng-model)]="name"></div>`;
var rootTC;
var rootTC: RootTestComponent;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then(
(root) => { rootTC = root; });
tick();
rootTC.componentInstance.form = form;
rootTC.debugElement.componentInstance.form = form;
rootTC.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.nativeElement);
DOM.appendChild(fakeDoc.body, rootTC.debugElement.nativeElement);
}
var input = rootTC.query(By.css("input")).nativeElement;
var input = rootTC.debugElement.query(By.css("input")).nativeElement;
input.value = "aa";
input.selectionStart = 1;
dispatchEvent(input, "change");
@ -760,31 +771,31 @@ 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;
var rootTC: RootTestComponent;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then(
(root) => { rootTC = root; });
tick();
rootTC.componentInstance.name = "";
rootTC.debugElement.componentInstance.name = "";
rootTC.detectChanges();
// Type "aa" into the input.
var input = rootTC.query(By.css("input")).nativeElement;
var input = rootTC.debugElement.query(By.css("input")).nativeElement;
input.value = "aa";
input.selectionStart = 1;
dispatchEvent(input, "change");
tick();
rootTC.detectChanges();
expect(rootTC.componentInstance.name).toEqual("aa");
expect(rootTC.debugElement.componentInstance.name).toEqual("aa");
// Programatically update the input value to be "bb".
rootTC.componentInstance.name = "bb";
rootTC.debugElement.componentInstance.name = "bb";
tick();
rootTC.detectChanges();
expect(input.value).toEqual("bb");
// Programatically set it back to "aa".
rootTC.componentInstance.name = "aa";
rootTC.debugElement.componentInstance.name = "aa";
tick();
rootTC.detectChanges();
expect(input.value).toEqual("aa");

View File

@ -31,7 +31,8 @@ export function main() {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.createAsync(App).then((tc) => {
tc.detectChanges();
expect(asNativeElements(tc.componentViewChildren)).toHaveText('frame(lock)');
expect(asNativeElements(tc.debugElement.componentViewChildren))
.toHaveText('frame(lock)');
async.done();
});
}));

View File

@ -2,6 +2,7 @@ import {describe, it, expect, beforeEach, ddescribe, iit, xit, el} from 'angular
import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {SelectorMatcher} from 'angular2/src/core/render/dom/compiler/selector';
import {CssSelector} from 'angular2/src/core/render/dom/compiler/selector';
import {ListWrapper, MapWrapper} from 'angular2/src/core/facade/collection';
export function main() {
describe('SelectorMatcher', () => {

View File

@ -15,6 +15,7 @@ import {
import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {CompilePipeline} from 'angular2/src/core/render/dom/compiler/compile_pipeline';
import {MapWrapper, ListWrapper} from 'angular2/src/core/facade/collection';
import {
ProtoViewBuilder,
ElementBinderBuilder

View File

@ -3,6 +3,7 @@ import {
TextInterpolationParser
} from 'angular2/src/core/render/dom/compiler/text_interpolation_parser';
import {CompilePipeline} from 'angular2/src/core/render/dom/compiler/compile_pipeline';
import {MapWrapper, ListWrapper} from 'angular2/src/core/facade/collection';
import {Lexer, Parser, ASTWithSource} from 'angular2/src/core/change_detection/change_detection';
import {IgnoreChildrenStep} from './pipeline_spec';
import {

View File

@ -16,6 +16,7 @@ import {StyleUrlResolver} from 'angular2/src/core/render/dom/compiler/style_url_
import {UrlResolver} from 'angular2/src/core/services/url_resolver';
import {PromiseWrapper, Promise} from 'angular2/src/core/facade/async';
import {MapWrapper, ListWrapper} from 'angular2/src/core/facade/collection';
import {XHR} from 'angular2/src/core/render/xhr';
import {MockXHR} from 'angular2/src/core/render/xhr_mock';
import {ViewDefinition} from 'angular2/src/core/render/api';

View File

@ -13,6 +13,7 @@ import {
SpyObject,
} from 'angular2/test_lib';
import {MapWrapper} from 'angular2/src/core/facade/collection';
import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {DomTestbed, TestRootView, elRef} from './dom_testbed';

View File

@ -1,4 +1,5 @@
import {
RootTestComponent,
AsyncTestCompleter,
TestComponentBuilder,
beforeEach,
@ -58,7 +59,8 @@ export function main() {
describe('Router lifecycle hooks', () => {
var tcb: TestComponentBuilder;
var rootTC, rtr;
var rootTC: RootTestComponent;
var rtr;
beforeEachBindings(() => [
Pipeline,
@ -94,7 +96,7 @@ export function main() {
.then((_) => rtr.navigateByUrl('/on-activate'))
.then((_) => {
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('activate cmp');
expect(rootTC.debugElement.nativeElement).toHaveText('activate cmp');
expect(log).toEqual(['activate: null -> /on-activate']);
async.done();
});
@ -113,7 +115,7 @@ export function main() {
rtr.navigateByUrl('/parent-activate/child-activate')
.then((_) => {
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('parent {activate cmp}');
expect(rootTC.debugElement.nativeElement).toHaveText('parent {activate cmp}');
expect(log).toEqual([
'parent activate: null -> /parent-activate',
'activate: null -> /child-activate'
@ -130,7 +132,7 @@ export function main() {
.then((_) => rtr.navigateByUrl('/a'))
.then((_) => {
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('A');
expect(rootTC.debugElement.nativeElement).toHaveText('A');
expect(log).toEqual(['deactivate: /on-deactivate -> /a']);
async.done();
});
@ -146,12 +148,12 @@ export function main() {
if (ev.startsWith('deactivate')) {
completer.resolve(true);
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('parent {deactivate cmp}');
expect(rootTC.debugElement.nativeElement).toHaveText('parent {deactivate cmp}');
}
});
rtr.navigateByUrl('/a').then((_) => {
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('A');
expect(rootTC.debugElement.nativeElement).toHaveText('A');
expect(log).toEqual([
'deactivate: /child-deactivate -> null',
'parent deactivate: /parent-deactivate -> /a'
@ -169,14 +171,14 @@ export function main() {
.then((_) => {
rootTC.detectChanges();
expect(log).toEqual([]);
expect(rootTC.nativeElement).toHaveText('reuse {A}');
expect(rootTC.debugElement.nativeElement).toHaveText('reuse {A}');
expect(cmpInstanceCount).toBe(1);
})
.then((_) => rtr.navigateByUrl('/on-reuse/2/b'))
.then((_) => {
rootTC.detectChanges();
expect(log).toEqual(['reuse: /on-reuse/1 -> /on-reuse/2']);
expect(rootTC.nativeElement).toHaveText('reuse {B}');
expect(rootTC.debugElement.nativeElement).toHaveText('reuse {B}');
expect(cmpInstanceCount).toBe(1);
async.done();
});
@ -191,14 +193,14 @@ export function main() {
.then((_) => {
rootTC.detectChanges();
expect(log).toEqual([]);
expect(rootTC.nativeElement).toHaveText('reuse {A}');
expect(rootTC.debugElement.nativeElement).toHaveText('reuse {A}');
expect(cmpInstanceCount).toBe(1);
})
.then((_) => rtr.navigateByUrl('/never-reuse/2/b'))
.then((_) => {
rootTC.detectChanges();
expect(log).toEqual([]);
expect(rootTC.nativeElement).toHaveText('reuse {B}');
expect(rootTC.debugElement.nativeElement).toHaveText('reuse {B}');
expect(cmpInstanceCount).toBe(2);
async.done();
});
@ -217,7 +219,7 @@ export function main() {
rtr.navigateByUrl('/can-activate/a')
.then((_) => {
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('canActivate {A}');
expect(rootTC.debugElement.nativeElement).toHaveText('canActivate {A}');
expect(log).toEqual(['canActivate: null -> /can-activate']);
async.done();
});
@ -237,7 +239,7 @@ export function main() {
rtr.navigateByUrl('/can-activate/a')
.then((_) => {
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('');
expect(rootTC.debugElement.nativeElement).toHaveText('');
expect(log).toEqual(['canActivate: null -> /can-activate']);
async.done();
});
@ -251,7 +253,7 @@ export function main() {
.then((_) => rtr.navigateByUrl('/can-deactivate/a'))
.then((_) => {
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('canDeactivate {A}');
expect(rootTC.debugElement.nativeElement).toHaveText('canDeactivate {A}');
expect(log).toEqual([]);
ObservableWrapper.subscribe<string>(eventBus, (ev) => {
@ -262,7 +264,7 @@ export function main() {
rtr.navigateByUrl('/a').then((_) => {
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('A');
expect(rootTC.debugElement.nativeElement).toHaveText('A');
expect(log).toEqual(['canDeactivate: /can-deactivate -> /a']);
async.done();
});
@ -276,7 +278,7 @@ export function main() {
.then((_) => rtr.navigateByUrl('/can-deactivate/a'))
.then((_) => {
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('canDeactivate {A}');
expect(rootTC.debugElement.nativeElement).toHaveText('canDeactivate {A}');
expect(log).toEqual([]);
ObservableWrapper.subscribe<string>(eventBus, (ev) => {
@ -287,7 +289,7 @@ export function main() {
rtr.navigateByUrl('/a').then((_) => {
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('canDeactivate {A}');
expect(rootTC.debugElement.nativeElement).toHaveText('canDeactivate {A}');
expect(log).toEqual(['canDeactivate: /can-deactivate -> /a']);
async.done();
});

View File

@ -1,4 +1,5 @@
import {
RootTestComponent,
AsyncTestCompleter,
TestComponentBuilder,
beforeEach,
@ -42,7 +43,8 @@ export function main() {
describe('navigation', () => {
var tcb: TestComponentBuilder;
var rootTC, rtr;
var rootTC: RootTestComponent;
var rtr;
beforeEachBindings(() => [
Pipeline,
@ -78,7 +80,7 @@ export function main() {
.then((_) => rtr.navigateByUrl('/test'))
.then((_) => {
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('hello');
expect(rootTC.debugElement.nativeElement).toHaveText('hello');
async.done();
});
}));
@ -91,12 +93,12 @@ export function main() {
.then((_) => rtr.navigateByUrl('/user/brian'))
.then((_) => {
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('hello brian');
expect(rootTC.debugElement.nativeElement).toHaveText('hello brian');
})
.then((_) => rtr.navigateByUrl('/user/igor'))
.then((_) => {
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('hello igor');
expect(rootTC.debugElement.nativeElement).toHaveText('hello igor');
async.done();
});
}));
@ -108,7 +110,7 @@ export function main() {
.then((_) => rtr.navigateByUrl('/a/b'))
.then((_) => {
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('outer { inner { hello } }');
expect(rootTC.debugElement.nativeElement).toHaveText('outer { inner { hello } }');
async.done();
});
}));
@ -120,7 +122,7 @@ export function main() {
.then((_) => rtr.navigateByUrl('/a/b'))
.then((_) => {
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('outer { inner { hello } }');
expect(rootTC.debugElement.nativeElement).toHaveText('outer { inner { hello } }');
async.done();
});
}));
@ -136,7 +138,7 @@ export function main() {
.then((_) => rtr.navigateByUrl('/original'))
.then((_) => {
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('hello');
expect(rootTC.debugElement.nativeElement).toHaveText('hello');
expect(location.urlChanges).toEqual(['/redirected']);
async.done();
});
@ -150,13 +152,14 @@ export function main() {
.then((_) => {
rootTC.detectChanges();
expect(cmpInstanceCount).toBe(1);
expect(rootTC.nativeElement).toHaveText('team angular { hello rado }');
expect(rootTC.debugElement.nativeElement).toHaveText('team angular { hello rado }');
})
.then((_) => rtr.navigateByUrl('/team/angular/user/victor'))
.then((_) => {
rootTC.detectChanges();
expect(cmpInstanceCount).toBe(1);
expect(rootTC.nativeElement).toHaveText('team angular { hello victor }');
expect(rootTC.debugElement.nativeElement)
.toHaveText('team angular { hello victor }');
async.done();
});
}));
@ -170,14 +173,14 @@ export function main() {
rootTC.detectChanges();
expect(cmpInstanceCount).toBe(1);
expect(childCmpInstanceCount).toBe(1);
expect(rootTC.nativeElement).toHaveText('team angular { hello rado }');
expect(rootTC.debugElement.nativeElement).toHaveText('team angular { hello rado }');
})
.then((_) => rtr.navigateByUrl('/team/dart/user/rado'))
.then((_) => {
rootTC.detectChanges();
expect(cmpInstanceCount).toBe(2);
expect(childCmpInstanceCount).toBe(2);
expect(rootTC.nativeElement).toHaveText('team dart { hello rado }');
expect(rootTC.debugElement.nativeElement).toHaveText('team dart { hello rado }');
async.done();
});
}));
@ -190,7 +193,8 @@ export function main() {
.then((_) => rtr.navigateByUrl('/route-data'))
.then((_) => {
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText(Json.stringify({'isAdmin': true}));
expect(rootTC.debugElement.nativeElement)
.toHaveText(Json.stringify({'isAdmin': true}));
async.done();
});
}));
@ -205,7 +209,8 @@ export function main() {
.then((_) => rtr.navigateByUrl('/route-data'))
.then((_) => {
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText(Json.stringify({'isAdmin': true}));
expect(rootTC.debugElement.nativeElement)
.toHaveText(Json.stringify({'isAdmin': true}));
async.done();
});
}));
@ -218,7 +223,7 @@ export function main() {
.then((_) => rtr.navigateByUrl('/route-data-default'))
.then((_) => {
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('null');
expect(rootTC.debugElement.nativeElement).toHaveText('null');
async.done();
});
}));
@ -231,7 +236,7 @@ export function main() {
.then((_) => rtr.navigateByUrl('/route-data-array'))
.then((_) => {
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText(Json.stringify([1, 2, 3]));
expect(rootTC.debugElement.nativeElement).toHaveText(Json.stringify([1, 2, 3]));
async.done();
});
}));
@ -245,7 +250,7 @@ export function main() {
.then((_) => rtr.navigateByUrl('/route-data-string'))
.then((_) => {
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText(Json.stringify('hello world'));
expect(rootTC.debugElement.nativeElement).toHaveText(Json.stringify('hello world'));
async.done();
});
}));
@ -257,7 +262,7 @@ export function main() {
.then((_) => rtr.navigateByUrl('/hello(modal)'))
.then((_) => {
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('main {hello} | aux {modal}');
expect(rootTC.debugElement.nativeElement).toHaveText('main {hello} | aux {modal}');
async.done();
});
}));

View File

@ -71,9 +71,9 @@ export function main() {
it('should rethrow exceptions from component constructors',
inject([AsyncTestCompleter, TestComponentBuilder], (async, tcb: TestComponentBuilder) => {
tcb.createAsync(AppCmp).then((rootTC) => {
var router = rootTC.componentInstance.router;
var router = rootTC.debugElement.componentInstance.router;
PromiseWrapper.catchError(router.navigateByUrl('/cause-error'), (error) => {
expect(rootTC.nativeElement).toHaveText('outer { oh no }');
expect(rootTC.debugElement.nativeElement).toHaveText('outer { oh no }');
expect(error).toContainError('oops!');
async.done();
});
@ -89,7 +89,7 @@ export function main() {
tcb.createAsync(HierarchyAppCmp)
.then((rootTC) => {
var router = rootTC.componentInstance.router;
var router = rootTC.debugElement.componentInstance.router;
var position = 0;
var flipped = false;
var history =
@ -100,8 +100,8 @@ export function main() {
]
router.subscribe((_) => {
var location = rootTC.componentInstance.location;
var element = rootTC.nativeElement;
var location = rootTC.debugElement.componentInstance.location;
var element = rootTC.debugElement.nativeElement;
var path = location.path();
var entry = history[position];
@ -140,10 +140,12 @@ export function main() {
tcb.createAsync(HierarchyAppCmp)
.then((rootTC) => {
var router = rootTC.componentInstance.router;
var router = rootTC.debugElement.componentInstance.router;
router.subscribe((_) => {
expect(rootTC.nativeElement).toHaveText('root { parent { hello } }');
expect(rootTC.componentInstance.location.path()).toEqual('/parent/child');
expect(rootTC.debugElement.nativeElement)
.toHaveText('root { parent { hello } }');
expect(rootTC.debugElement.componentInstance.location.path())
.toEqual('/parent/child');
async.done();
});
router.navigateByUrl('/parent/child');
@ -158,10 +160,11 @@ export function main() {
tcb.createAsync(HierarchyAppCmp)
.then((rootTC) => {
var router = rootTC.componentInstance.router;
var router = rootTC.debugElement.componentInstance.router;
router.subscribe((_) => {
expect(rootTC.nativeElement).toHaveText('root { parent { hello } }');
expect(rootTC.componentInstance.location.path())
expect(rootTC.debugElement.nativeElement)
.toHaveText('root { parent { hello } }');
expect(rootTC.debugElement.componentInstance.location.path())
.toEqual('/my/app/parent/child');
async.done();
});
@ -180,11 +183,12 @@ export function main() {
inject([AsyncTestCompleter, TestComponentBuilder], (async, tcb: TestComponentBuilder) => {
tcb.createAsync(QueryStringAppCmp)
.then((rootTC) => {
var router = rootTC.componentInstance.router;
var router = rootTC.debugElement.componentInstance.router;
router.subscribe((_) => {
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('qParam = search-for-something');
expect(rootTC.debugElement.nativeElement)
.toHaveText('qParam = search-for-something');
/*
expect(applicationRef.hostComponent.location.path())
.toEqual('/qs?q=search-for-something');*/

View File

@ -1,4 +1,5 @@
import {
RootTestComponent,
AsyncTestCompleter,
beforeEach,
ddescribe,
@ -42,7 +43,8 @@ import {DOM} from 'angular2/src/core/dom/dom_adapter';
export function main() {
describe('router-link directive', function() {
var tcb: TestComponentBuilder;
var rootTC, router, location;
var rootTC: RootTestComponent;
var router, location;
beforeEachBindings(() => [
Pipeline,
@ -104,10 +106,11 @@ export function main() {
[new Route({path: '/user/:name', component: UserCmp, as: 'user'})]))
.then((_) => router.navigateByUrl('/a/b'))
.then((_) => {
rootTC.componentInstance.name = 'brian';
rootTC.debugElement.componentInstance.name = 'brian';
rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('brian');
expect(DOM.getAttribute(rootTC.componentViewChildren[0].nativeElement, 'href'))
expect(rootTC.debugElement.nativeElement).toHaveText('brian');
expect(DOM.getAttribute(rootTC.debugElement.componentViewChildren[0].nativeElement,
'href'))
.toEqual('/user/brian');
async.done();
});
@ -121,9 +124,10 @@ export function main() {
.then((_) => router.navigateByUrl('/page/1'))
.then((_) => {
rootTC.detectChanges();
expect(DOM.getAttribute(
rootTC.componentViewChildren[1].componentViewChildren[0].nativeElement,
'href'))
expect(DOM.getAttribute(rootTC.debugElement.componentViewChildren[1]
.componentViewChildren[0]
.nativeElement,
'href'))
.toEqual('/page/2');
async.done();
});
@ -142,9 +146,10 @@ export function main() {
.then((_) => router.navigate(['/child-with-grandchild']))
.then((_) => {
rootTC.detectChanges();
expect(DOM.getAttribute(
rootTC.componentViewChildren[1].componentViewChildren[0].nativeElement,
'href'))
expect(DOM.getAttribute(rootTC.debugElement.componentViewChildren[1]
.componentViewChildren[0]
.nativeElement,
'href'))
.toEqual('/child-with-grandchild/grandchild');
async.done();
});
@ -158,12 +163,13 @@ export function main() {
.then((_) => router.navigateByUrl('/book/1984/page/1'))
.then((_) => {
rootTC.detectChanges();
expect(DOM.getAttribute(
rootTC.componentViewChildren[1].componentViewChildren[0].nativeElement,
'href'))
expect(DOM.getAttribute(rootTC.debugElement.componentViewChildren[1]
.componentViewChildren[0]
.nativeElement,
'href'))
.toEqual('/book/1984/page/100');
expect(DOM.getAttribute(rootTC.componentViewChildren[1]
expect(DOM.getAttribute(rootTC.debugElement.componentViewChildren[1]
.componentViewChildren[2]
.componentViewChildren[0]
.nativeElement,
@ -184,7 +190,7 @@ export function main() {
<a [router-link]="['./better-child']" class="better-child-link">Better Child</a>
<router-outlet></router-outlet>`))
.then((_) => {
var element = rootTC.nativeElement;
var element = rootTC.debugElement.nativeElement;
rootTC.detectChanges();
@ -219,7 +225,7 @@ export function main() {
<a [router-link]="['./child-with-grandchild/grandchild']" class="child-with-grandchild-link">Better Child</a>
<router-outlet></router-outlet>`))
.then((_) => {
var element = rootTC.nativeElement;
var element = rootTC.debugElement.nativeElement;
rootTC.detectChanges();
@ -251,7 +257,7 @@ export function main() {
describe('when clicked', () => {
var clickOnElement = function(view) {
var anchorEl = rootTC.componentViewChildren[0].nativeElement;
var anchorEl = rootTC.debugElement.componentViewChildren[0].nativeElement;
var dispatchedEvent = DOM.createMouseEvent('click');
DOM.dispatchEvent(anchorEl, dispatchedEvent);
return dispatchedEvent;
@ -300,8 +306,8 @@ export function main() {
});
}
function getHref(tc) {
return DOM.getAttribute(tc.componentViewChildren[0].nativeElement, 'href');
function getHref(tc: RootTestComponent) {
return DOM.getAttribute(tc.debugElement.componentViewChildren[0].nativeElement, 'href');
}
@Component({selector: 'my-comp'})

View File

@ -10,6 +10,8 @@ import {
SpyObject
} from 'angular2/test_lib';
import {Map, StringMap, StringMapWrapper} from 'angular2/src/core/facade/collection';
import {RouteRecognizer} from 'angular2/src/router/route_recognizer';
import {ComponentInstruction} from 'angular2/src/router/instruction';

View File

@ -51,7 +51,7 @@ export function main() {
tcb.createAsync(TestComponent)
.then((testComponent) => {
testComponent.detectChanges();
let anchorElement = testComponent.query(By.css('a')).nativeElement;
let anchorElement = testComponent.debugElement.query(By.css('a')).nativeElement;
expect(DOM.getAttribute(anchorElement, 'href')).toEqual('/detail');
async.done();
});
@ -65,7 +65,7 @@ export function main() {
.then((testComponent) => {
testComponent.detectChanges();
// TODO: shouldn't this be just 'click' rather than '^click'?
testComponent.query(By.css('a')).triggerEventHandler('click', null);
testComponent.debugElement.query(By.css('a')).triggerEventHandler('click', null);
expect(router.spy('navigateByInstruction')).toHaveBeenCalledWith(dummyInstruction);
async.done();
});

View File

@ -93,66 +93,66 @@ class TestViewBindingsComp {
export function main() {
describe('test component builder', function() {
it('should instantiate a component with valid DOM',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb, async) => {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.createAsync(ChildComp).then((rootTestComponent) => {
rootTestComponent.detectChanges();
expect(rootTestComponent.nativeElement).toHaveText('Original Child');
expect(rootTestComponent.debugElement.nativeElement).toHaveText('Original Child');
async.done();
});
}));
it('should allow changing members of the component',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb, async) => {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.createAsync(MyIfComp).then((rootTestComponent) => {
rootTestComponent.detectChanges();
expect(rootTestComponent.nativeElement).toHaveText('MyIf()');
expect(rootTestComponent.debugElement.nativeElement).toHaveText('MyIf()');
rootTestComponent.componentInstance.showMore = true;
rootTestComponent.debugElement.componentInstance.showMore = true;
rootTestComponent.detectChanges();
expect(rootTestComponent.nativeElement).toHaveText('MyIf(More)');
expect(rootTestComponent.debugElement.nativeElement).toHaveText('MyIf(More)');
async.done();
});
}));
it('should override a template',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb, async) => {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideTemplate(MockChildComp, '<span>Mock</span>')
.createAsync(MockChildComp)
.then((rootTestComponent) => {
rootTestComponent.detectChanges();
expect(rootTestComponent.nativeElement).toHaveText('Mock');
expect(rootTestComponent.debugElement.nativeElement).toHaveText('Mock');
async.done();
});
}));
it('should override a view',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb, async) => {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(ChildComp,
new ViewMetadata({template: '<span>Modified {{childBinding}}</span>'}))
.createAsync(ChildComp)
.then((rootTestComponent) => {
rootTestComponent.detectChanges();
expect(rootTestComponent.nativeElement).toHaveText('Modified Child');
expect(rootTestComponent.debugElement.nativeElement).toHaveText('Modified Child');
async.done();
});
}));
it('should override component dependencies',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb, async) => {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideDirective(ParentComp, ChildComp, MockChildComp)
.createAsync(ParentComp)
.then((rootTestComponent) => {
rootTestComponent.detectChanges();
expect(rootTestComponent.nativeElement).toHaveText('Parent(Mock)');
expect(rootTestComponent.debugElement.nativeElement).toHaveText('Parent(Mock)');
async.done();
});
@ -160,14 +160,14 @@ export function main() {
it("should override child component's dependencies",
inject([TestComponentBuilder, AsyncTestCompleter], (tcb, async) => {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideDirective(ParentComp, ChildComp, ChildWithChildComp)
.overrideDirective(ChildWithChildComp, ChildChildComp, MockChildChildComp)
.createAsync(ParentComp)
.then((rootTestComponent) => {
rootTestComponent.detectChanges();
expect(rootTestComponent.nativeElement)
expect(rootTestComponent.debugElement.nativeElement)
.toHaveText('Parent(Original Child(ChildChild Mock))');
async.done();
@ -175,13 +175,13 @@ export function main() {
}));
it('should override a binding',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb, async) => {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideBindings(TestBindingsComp, [bind(FancyService).toClass(MockFancyService)])
.createAsync(TestBindingsComp)
.then((rootTestComponent) => {
rootTestComponent.detectChanges();
expect(rootTestComponent.nativeElement)
expect(rootTestComponent.debugElement.nativeElement)
.toHaveText('injected value: mocked out value');
async.done();
});
@ -189,14 +189,14 @@ export function main() {
it('should override a viewBinding',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb, async) => {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideViewBindings(TestViewBindingsComp,
[bind(FancyService).toClass(MockFancyService)])
.createAsync(TestViewBindingsComp)
.then((rootTestComponent) => {
rootTestComponent.detectChanges();
expect(rootTestComponent.nativeElement)
expect(rootTestComponent.debugElement.nativeElement)
.toHaveText('injected value: mocked out value');
async.done();
});

View File

@ -2,9 +2,3 @@
export * from './test';
export * from './src/test_lib/utils';
export * from './src/test_lib/fake_async';
export {ComponentRef, HostViewRef} from './src/core/compiler';
// This interface is referenced by TestComponents, however we can't export it directly from router
// because router pulls in dart:html & dart:js and we import test_lib in standalone VM tests
// so we re-create the interface here.
export interface InjectableReference {}

View File

@ -1,16 +1,6 @@
export * from '../src/core/facade';
export * from "../src/web_workers/ui/application";
export * from '../src/core/zone';
export * from "../src/web_workers/ui/application";
export * from "../src/web_workers/shared/client_message_broker";
export * from "../src/web_workers/shared/service_message_broker";
export * from "../src/web_workers/shared/serializer";
export * from '../src/web_workers/shared/render_proto_view_ref_store';
export * from '../src/web_workers/shared/render_view_with_fragments_store';
export * from '../src/core/render/api';
export * from '../src/core/change_detection';
export * from '../src/core/di';
export {Reflector, ReflectionInfo} from '../src/core/reflection/reflection';
export {
PlatformReflectionCapabilities
} from '../src/core/reflection/platform_reflection_capabilities';
export {SetterFn, GetterFn, MethodFn} from '../src/core/reflection/types';
export {PRIMITIVE} from '../src/web_workers/shared/serializer';

View File

@ -7,6 +7,7 @@ export * from '../src/core/facade';
// Do not export application in web_worker,
// web_worker exports its own
// export * from '../src/core/application';
export * from '../src/core/application_ref';
export * from '../src/core/services';
export * from '../src/core/compiler';
export * from '../src/core/lifecycle';
@ -14,22 +15,23 @@ export * from '../src/core/zone';
// Do not export render in web_worker
// export * from '../src/core/render';
// Add special import for just render API
export * from '../src/core/application_ref';
export * from '../src/core/application_tokens';
export * from '../src/core/render/api';
// TODO: Hard coded exports from render that need to be cleaned up
export {
RenderEventDispatcher,
Renderer,
RenderElementRef,
RenderViewRef,
RenderProtoViewRef,
RenderFragmentRef,
RenderViewWithFragments
} from '../src/core/render/render';
export * from '../src/core/directives';
export * from '../src/core/forms';
export * from '../src/core/debug';
export * from '../src/core/change_detection';
export * from '../profile';
export * from '../src/web_workers/worker/application';
export * from '../src/web_workers/shared/client_message_broker';
export * from '../src/web_workers/shared/service_message_broker';
export * from '../src/web_workers/shared/serializer';
export * from '../src/web_workers/shared/render_proto_view_ref_store';
export * from '../src/web_workers/shared/render_view_with_fragments_store';
export {Reflector, ReflectionInfo} from '../src/core/reflection/reflection';
export {
PlatformReflectionCapabilities
} from '../src/core/reflection/platform_reflection_capabilities';
export {SetterFn, GetterFn, MethodFn} from '../src/core/reflection/types';
export {PRIMITIVE} from '../src/web_workers/shared/serializer';

View File

@ -8,8 +8,14 @@ var broker = instance.app.createClientMessageBroker(ECHO_CHANNEL, false);
document.getElementById("send_echo")
.addEventListener("click", (e) => {
var val = (<HTMLInputElement>document.getElementById("echo_input")).value;
var fnArg = new FnArg(val, PRIMITIVE);
var args = new UiArguments("echo", [fnArg]);
// TODO(jteplitz602): Replace default constructors with real constructors
// once they're in the .d.ts file (#3926)
var args = new UiArguments();
args.method = "echo";
var fnArg = new FnArg();
fnArg.value = val;
fnArg.type = PRIMITIVE;
args.args = [fnArg];
broker.runOnService(args, PRIMITIVE)
.then((echo_result: string) => {

View File

@ -3,8 +3,7 @@ library angular2.transform.common.directive_metadata_reader;
import 'package:analyzer/analyzer.dart';
import 'package:analyzer/src/generated/element.dart';
import 'package:angular2/src/core/render/api.dart';
import 'package:angular2/src/core/change_detection/change_detection.dart'
show ChangeDetectionStrategy;
import 'package:angular2/src/core/change_detection/change_detection.dart';
/// Reads [RenderDirectiveMetadata] from the `node`. `node` is expected to be an
/// instance of [ClassDeclaration] (a class which may have a [Directive] or