fix(tests): fix tests

This commit is contained in:
vsavkin 2015-10-08 08:22:11 -07:00
parent 5458036de7
commit 8b725c77fd
26 changed files with 82 additions and 86 deletions

View File

@ -60,7 +60,7 @@ module.exports = new Package('angular-v2-docs', [jsdocPackage, nunjucksPackage,
{
id: 'angular2/router',
references: ['./angular2.d.ts'],
remapTypes: {Type: 'ng.Type', InjectableReference: 'ng.InjectableReference'},
remapTypes: {Type: 'ng.Type', InjectableReference: 'ng.InjectableReference', ElementRef: 'ng.ElementRef', DynamicComponentLoader: 'ng.DynamicComponentLoader'},
modules: {'angular2/router': {namespace: 'ngRouter', id: 'angular2/router'}}
},
{

View File

@ -16,8 +16,8 @@ var packageSources = {
'utf': 'packages/utf',
// Local dependencies, transpiled from the source.
'angular2/test/': 'dist/dart/angular2/test/',
'angular2': 'dist/dart/angular2/lib',
'angular2/test/': 'dist/dart/angular2/test/',
'http': 'dist/dart/http/lib',
'angular2_material': 'dist/dart/angular2_material/lib',
'benchpress': 'dist/dart/benchpress/lib',

View File

@ -29,7 +29,7 @@ import {
} from 'angular2/src/core/linker/dynamic_component_loader';
import {TestabilityRegistry, Testability} from 'angular2/src/core/testability/testability';
import {Renderer} from 'angular2/src/core/render/api';
import {DomRenderer, DOCUMENT} from 'angular2/src/core/render/render';
import {DomRenderer, DomRenderer_, DOCUMENT} from 'angular2/src/core/render/render';
import {
SharedStylesHost,
DomSharedStylesHost
@ -55,7 +55,7 @@ export function applicationDomBindings(): Array<Type | Binding | any[]> {
new Binding(EVENT_MANAGER_PLUGINS, {toClass: DomEventsPlugin, multi: true}),
new Binding(EVENT_MANAGER_PLUGINS, {toClass: KeyEventsPlugin, multi: true}),
new Binding(EVENT_MANAGER_PLUGINS, {toClass: HammerGesturesPlugin, multi: true}),
DomRenderer,
bind(DomRenderer).toClass(DomRenderer_),
bind(Renderer).toAlias(DomRenderer),
DomSharedStylesHost,
bind(SharedStylesHost).toAlias(DomSharedStylesHost),

View File

@ -74,7 +74,7 @@ function _componentBindings(appComponentType: Type): Array<Type | Binding | any[
return componentRef;
});
},
[bind(DynamicComponentLoader).toClass(DynamicComponentLoader_), Injector]),
[DynamicComponentLoader, Injector]),
bind(appComponentType)
.toFactory((p: Promise<any>) => p.then(ref => ref.instance), [APP_COMPONENT_REF_PROMISE]),

View File

@ -10,7 +10,7 @@ import {Promise, PromiseWrapper} from 'angular2/src/core/facade/async';
export abstract class RuntimeCompiler extends Compiler {}
@Injectable()
export class RuntimeCompiler_ extends Compiler_ {
export class RuntimeCompiler_ extends Compiler_ implements RuntimeCompiler {
constructor(_protoViewFactory: ProtoViewFactory, private _templateCompiler: TemplateCompiler) {
super(_protoViewFactory);
}

View File

@ -135,6 +135,9 @@ export class CyclicDependencyError extends AbstractBindingError {
* ```
*/
export abstract class InstantiationError extends WrappedException {
constructor(message, originalException, originalStack, context) {
super(message, originalException, originalStack, context);
}
abstract addKey(injector: Injector, key: Key): void;
get wrapperMessage(): string { return unimplemented(); };
get causeKey(): Key { return unimplemented(); };

View File

@ -30,7 +30,7 @@ import {
BindingWithVisibility,
DependencyProvider
} from 'angular2/src/core/di/injector';
import {resolveBinding, ResolvedFactory} from 'angular2/src/core/di/binding';
import {resolveBinding, ResolvedFactory, ResolvedBinding_} from 'angular2/src/core/di/binding';
import {AttributeMetadata, QueryMetadata} from '../metadata/di';
@ -53,7 +53,6 @@ import {PipeBinding} from '../pipes/pipe_binding';
import {LifecycleHooks} from './interfaces';
import {ViewContainerRef_} from "./view_container_ref";
import {ResolvedBinding_} from "../di/binding";
var _staticKeys;

View File

@ -1,7 +1,6 @@
import {BaseException, unimplemented} from 'angular2/src/core/facade/exceptions';
import {ViewRef, ViewRef_} from './view_ref';
import {RenderViewRef, RenderElementRef, Renderer} from 'angular2/src/core/render/api';
import {ChangeDetectorRef} from "../change_detection/change_detector_ref";
/**
* Represents a location in a View that has an injection, change-detection and render context

View File

@ -1,8 +1,7 @@
import {Type} from 'angular2/src/core/facade/lang';
import {ResolvedFactory, resolveBinding} from 'angular2/src/core/di/binding';
import {ResolvedFactory, resolveBinding, ResolvedBinding_} from 'angular2/src/core/di/binding';
import {Key, ResolvedBinding, Binding} from 'angular2/src/core/di';
import {PipeMetadata} from '../metadata/directives';
import {ResolvedBinding_} from "../di/binding";
export class PipeBinding extends ResolvedBinding_ {
constructor(public name: string, public pure: boolean, key: Key,

View File

@ -1,9 +1,15 @@
import {Type, isPresent, isFunction, global, stringify} from 'angular2/src/core/facade/lang';
import {
Type,
isPresent,
isFunction,
global,
stringify,
ConcreteType
} from 'angular2/src/core/facade/lang';
import {BaseException, WrappedException} from 'angular2/src/core/facade/exceptions';
import {ListWrapper} from 'angular2/src/core/facade/collection';
import {GetterFn, SetterFn, MethodFn} from './types';
import {PlatformReflectionCapabilities} from 'platform_reflection_capabilities';
import {ConcreteType} from "../facade/lang";
export class ReflectionCapabilities implements PlatformReflectionCapabilities {
private _reflect: any;

View File

@ -1,5 +1,4 @@
import {global, Type, isFunction, stringify} from 'angular2/src/core/facade/lang';
import {ConcreteType} from "../facade/lang";
import {ConcreteType, global, Type, isFunction, stringify} from 'angular2/src/core/facade/lang';
/**
* Declares the interface to be used with {@link Class}.

View File

@ -293,3 +293,7 @@ class NgZone {
zoneValues: {'_innerZone': true});
}
}
class NgZone_ extends NgZone {
NgZone_({bool enableLongStackTrace}) : super(enableLongStackTrace: enableLongStackTrace);
}

View File

@ -1,6 +1,6 @@
import {Promise, PromiseWrapper} from 'angular2/src/core/facade/async';
import {StringMapWrapper} from 'angular2/src/core/facade/collection';
import {isBlank, isPresent} from 'angular2/src/core/facade/lang';
import {isBlank, isPresent, Type} from 'angular2/src/core/facade/lang';
import {BaseException, WrappedException} from 'angular2/src/core/facade/exceptions';
import {Directive, Attribute} from 'angular2/src/core/metadata';
@ -12,7 +12,6 @@ import {ComponentInstruction, RouteParams} from './instruction';
import {ROUTE_DATA} from './route_data';
import * as hookMod from './lifecycle_annotations';
import {hasLifecycleHook} from './route_lifecycle_reflector';
import {Type} from "../core/facade/lang";
let _resolveToTrue = PromiseWrapper.resolve(true);
@ -25,59 +24,14 @@ let _resolveToTrue = PromiseWrapper.resolve(true);
* <router-outlet></router-outlet>
* ```
*/
export abstract class RouterOutlet {
name: string = null;
/**
* Called by the Router to instantiate a new component during the commit phase of a navigation.
* This method in turn is responsible for calling the `onActivate` hook of its child.
*/
abstract activate(nextInstruction: ComponentInstruction): Promise<any>;
/**
* Called by the {@link Router} during the commit phase of a navigation when an outlet
* reuses a component between different routes.
* This method in turn is responsible for calling the `onReuse` hook of its child.
*/
abstract reuse(nextInstruction: ComponentInstruction): Promise<any>;
/**
* Called by the {@link Router} when an outlet reuses a component across navigations.
* This method in turn is responsible for calling the `onReuse` hook of its child.
*/
abstract deactivate(nextInstruction: ComponentInstruction): Promise<any>;
/**
* Called by the {@link Router} during recognition phase of a navigation.
*
* If this resolves to `false`, the given navigation is cancelled.
*
* This method delegates to the child component's `canDeactivate` hook if it exists,
* and otherwise resolves to true.
*/
abstract canDeactivate(nextInstruction: ComponentInstruction): Promise<boolean>;
/**
* Called by the {@link Router} during recognition phase of a navigation.
*
* If the new child component has a different Type than the existing child component,
* this will resolve to `false`. You can't reuse an old component when the new component
* is of a different Type.
*
* Otherwise, this method delegates to the child component's `canReuse` hook if it exists,
* or resolves to true if the hook is not present.
*/
abstract canReuse(nextInstruction: ComponentInstruction): Promise<boolean>;
}
@Directive({selector: 'router-outlet'})
export class RouterOutlet_ extends RouterOutlet {
export class RouterOutlet {
name: string = null;
private _componentRef: ComponentRef = null;
private _currentInstruction: ComponentInstruction = null;
constructor(private _elementRef: ElementRef, private _loader: DynamicComponentLoader,
private _parentRouter: routerMod.Router, @Attribute('name') nameAttr: string) {
super();
if (isPresent(nameAttr)) {
this.name = nameAttr;
this._parentRouter.registerAuxOutlet(this);
@ -86,6 +40,10 @@ export class RouterOutlet_ extends RouterOutlet {
}
}
/**
* Called by the Router to instantiate a new component during the commit phase of a navigation.
* This method in turn is responsible for calling the `onActivate` hook of its child.
*/
activate(nextInstruction: ComponentInstruction): Promise<any> {
var previousInstruction = this._currentInstruction;
this._currentInstruction = nextInstruction;
@ -107,6 +65,11 @@ export class RouterOutlet_ extends RouterOutlet {
});
}
/**
* Called by the {@link Router} during the commit phase of a navigation when an outlet
* reuses a component between different routes.
* This method in turn is responsible for calling the `onReuse` hook of its child.
*/
reuse(nextInstruction: ComponentInstruction): Promise<any> {
var previousInstruction = this._currentInstruction;
this._currentInstruction = nextInstruction;
@ -120,6 +83,10 @@ export class RouterOutlet_ extends RouterOutlet {
true);
}
/**
* Called by the {@link Router} when an outlet reuses a component across navigations.
* This method in turn is responsible for calling the `onReuse` hook of its child.
*/
deactivate(nextInstruction: ComponentInstruction): Promise<any> {
var next = _resolveToTrue;
if (isPresent(this._componentRef) && isPresent(this._currentInstruction) &&
@ -135,6 +102,14 @@ export class RouterOutlet_ extends RouterOutlet {
});
}
/**
* Called by the {@link Router} during recognition phase of a navigation.
*
* If this resolves to `false`, the given navigation is cancelled.
*
* This method delegates to the child component's `canDeactivate` hook if it exists,
* and otherwise resolves to true.
*/
canDeactivate(nextInstruction: ComponentInstruction): Promise<boolean> {
if (isBlank(this._currentInstruction)) {
return _resolveToTrue;
@ -146,6 +121,16 @@ export class RouterOutlet_ extends RouterOutlet {
return _resolveToTrue;
}
/**
* Called by the {@link Router} during recognition phase of a navigation.
*
* If the new child component has a different Type than the existing child component,
* this will resolve to `false`. You can't reuse an old component when the new component
* is of a different Type.
*
* Otherwise, this method delegates to the child component's `canReuse` hook if it exists,
* or resolves to true if the hook is not present.
*/
canReuse(nextInstruction: ComponentInstruction): Promise<boolean> {
var result;

View File

@ -21,7 +21,7 @@ import {bind, Inject, Injector, LifeCycle} from 'angular2/core';
import {ExceptionHandler} from 'angular2/src/core/facade/exceptions';
import {Testability, TestabilityRegistry} from 'angular2/src/core/testability/testability';
import {IS_DART} from '../platform';
import {ComponentRef_} from "../../src/core/linker/dynamic_component_loader";
import {ComponentRef_} from "angular2/src/core/linker/dynamic_component_loader";
@Component({selector: 'hello-app'})
@View({template: '{{greeting}} world!'})

View File

@ -14,7 +14,7 @@ import {
inject
} from 'angular2/test_lib';
import {SpyChangeDetector} from '../spies';
import {LifeCycle_} from "../../../src/core/life_cycle/life_cycle";
import {LifeCycle_} from "angular2/src/core/life_cycle/life_cycle";
export function main() {
describe("LifeCycle", () => {

View File

@ -24,7 +24,7 @@ import {Compiler} from 'angular2/src/core/linker/compiler';
import {ProtoViewFactory} from 'angular2/src/core/linker/proto_view_factory';
import {reflector, ReflectionInfo} from 'angular2/src/core/reflection/reflection';
import {AppProtoView} from 'angular2/src/core/linker/view';
import {Compiler_} from "../../../src/core/linker/compiler";
import {Compiler_} from "angular2/src/core/linker/compiler";
export function main() {
describe('Compiler', () => {
@ -37,8 +37,10 @@ export function main() {
protoViewFactorySpy = new SpyProtoViewFactory();
someProtoView = new AppProtoView(null, null, null, null, null, null);
protoViewFactorySpy.spy('createHost').andReturn(someProtoView);
return
[bind(ProtoViewFactory).toValue(protoViewFactorySpy), bind(Compiler).toClass(Compiler_)];
var factoryBinding = bind(ProtoViewFactory).toValue(protoViewFactorySpy);
var classBinding = bind(Compiler).toClass(Compiler_);
var bindings = [factoryBinding, classBinding];
return bindings;
});
beforeEach(inject([Compiler], (_compiler) => {

View File

@ -24,7 +24,7 @@ import {DynamicComponentLoader} from 'angular2/src/core/linker/dynamic_component
import {ElementRef} from 'angular2/src/core/linker/element_ref';
import {DOCUMENT} from 'angular2/src/core/render/render';
import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {RootTestComponent_} from "../../../src/test_lib/test_component_builder";
import {RootTestComponent_} from "angular2/src/test_lib/test_component_builder";
export function main() {
describe('DynamicComponentLoader', function() {

View File

@ -39,7 +39,7 @@ import {
} from 'angular2/src/core/metadata';
import {OnDestroy} from 'angular2/lifecycle_hooks';
import {bind, Injector, Binding, Optional, Inject, Injectable, Self, SkipSelf, InjectMetadata, Host, HostMetadata, SkipSelfMetadata} from 'angular2/core';
import {ViewContainerRef} from 'angular2/src/core/linker/view_container_ref';
import {ViewContainerRef, ViewContainerRef_} from 'angular2/src/core/linker/view_container_ref';
import {TemplateRef, TemplateRef_} from 'angular2/src/core/linker/template_ref';
import {ElementRef} from 'angular2/src/core/linker/element_ref';
import {DynamicChangeDetector, ChangeDetectorRef, Parser, Lexer} from 'angular2/src/core/change_detection/change_detection';
@ -905,7 +905,7 @@ export function main() {
it('should inject ViewContainerRef', () => {
var inj = injector(ListWrapper.concat([NeedsViewContainer], extraBindings));
expect(inj.get(NeedsViewContainer).viewContainer).toBeAnInstanceOf(ViewContainerRef);
expect(inj.get(NeedsViewContainer).viewContainer).toBeAnInstanceOf(ViewContainerRef_);
});
it("should inject TemplateRef", () => {

View File

@ -90,7 +90,7 @@ import {TemplateRef} from 'angular2/src/core/linker/template_ref';
import {DomRenderer} from 'angular2/src/core/render/dom/dom_renderer';
import {IS_DART} from '../../platform';
import {Compiler_} from "../../../src/core/linker/compiler";
import {Compiler_} from "angular2/src/core/linker/compiler";
const ANCHOR_ELEMENT = CONST_EXPR(new OpaqueToken('AnchorElement'));
@ -1018,9 +1018,8 @@ export function main() {
}));
describe('dynamic ViewContainers', () => {
it('should allow to create a ViewContainerRef at any bound location',
inject([TestComponentBuilder, AsyncTestCompleter, bind(Compiler).toClass(Compiler_)],
inject([TestComponentBuilder, AsyncTestCompleter, Compiler],
(tcb: TestComponentBuilder, async, compiler) => {
tcb.overrideView(MyComp, new ViewMetadata({
template: '<div><dynamic-vp #dynamic></dynamic-vp></div>',

View File

@ -1,7 +1,7 @@
import {ChangeDetectorRef} from 'angular2/src/core/change_detection/change_detection';
import {ChangeDetectorRef_} from 'angular2/src/core/change_detection/change_detector_ref';
import {SpyObject, proxy} from 'angular2/test_lib';
export class SpyChangeDetectorRef extends SpyObject {
constructor() { super(ChangeDetectorRef); }
constructor() { super(ChangeDetectorRef_); }
}

View File

@ -108,7 +108,6 @@ class FakeEventManagerPlugin extends EventManagerPlugin {
class FakeNgZone extends NgZone_ {
constructor() { super({enableLongStackTrace: false}); }
run(fn) { fn(); }
runOutsideAngular(fn) { return fn(); }

View File

@ -53,7 +53,7 @@ class SpyView extends SpyObject implements AppView {
}
@proxy
class SpyElementRef extends SpyObject implements ElementRef {
class SpyElementRef extends SpyObject implements ElementRef_ {
noSuchMethod(m) => super.noSuchMethod(m);
}

View File

@ -16,7 +16,8 @@ import {BrowserJsonp} from 'angular2/src/http/backends/browser_jsonp';
import {
JSONPConnection,
JSONPConnection_,
JSONPBackend
JSONPBackend,
JSONPBackend_
} from 'angular2/src/http/backends/jsonp_backend';
import {bind, Injector} from 'angular2/core';
import {isPresent, StringWrapper} from 'angular2/src/core/facade/lang';
@ -74,7 +75,7 @@ export function main() {
bind(ResponseOptions)
.toClass(BaseResponseOptions),
bind(BrowserJsonp).toClass(MockBrowserJsonp),
JSONPBackend
bind(JSONPBackend).toClass(JSONPBackend_)
]);
backend = injector.get(JSONPBackend);
let base = new BaseRequestOptions();

View File

@ -32,7 +32,7 @@ import {
} from 'angular2/router';
import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {ComponentInstruction_} from "../../src/router/instruction";
import {ComponentInstruction_} from "angular2/src/router/instruction";
var dummyInstruction = new Instruction(new ComponentInstruction_('detail', [], null), null, {});

View File

@ -1,7 +1,7 @@
import 'package:angular2/test_lib.dart' show SpyObject;
import 'package:angular2/core.dart' show LifeCycle, Injector, bind;
import 'package:angular2/src/core/linker/dynamic_component_loader.dart'
show ComponentRef;
show ComponentRef_;
import 'dart:js';
@proxy
@ -10,7 +10,7 @@ class SpyLifeCycle extends SpyObject implements LifeCycle {
}
@proxy
class SpyComponentRef extends SpyObject implements ComponentRef {
class SpyComponentRef extends SpyObject implements ComponentRef_ {
Injector injector;
SpyComponentRef() {

View File

@ -38,7 +38,7 @@ import {
RenderFragmentRef,
Renderer
} from "angular2/src/core/render/api";
import {DomRenderer} from 'angular2/src/core/render/dom/dom_renderer';
import {DomRenderer, DomRenderer_} from 'angular2/src/core/render/dom/dom_renderer';
import {DefaultRenderView} from 'angular2/src/core/render/view';
import {
RenderProtoViewRefStore,
@ -106,7 +106,8 @@ export function main() {
bind(RenderProtoViewRefStore)
.toValue(uiRenderProtoViewStore),
bind(RenderViewWithFragmentsStore).toValue(uiRenderViewStore),
bind(Renderer).toClass(DomRenderer)
bind(DomRenderer).toClass(DomRenderer_),
bind(Renderer).toAlias(DomRenderer)
]);
var uiSerializer = uiInjector.get(Serializer);
var domRenderer = uiInjector.get(DomRenderer);