feat(mocks): Mark mock objects @Injectable()

Make mock objects `@Injectable()` to allow using them in compiled tests.

Closes #5576
This commit is contained in:
Tim Blasi 2015-12-03 09:06:42 -08:00 committed by Jeremy Elbourn
parent e9f873a365
commit 35e32bbea1
8 changed files with 17 additions and 1 deletions

View File

@ -1,8 +1,10 @@
import {Injectable} from 'angular2/src/core/di';
import {Map, MapWrapper, ListWrapper} from 'angular2/src/facade/collection';
import {Type, isPresent, stringify, isBlank, print} from 'angular2/src/facade/lang';
import {DirectiveMetadata, ComponentMetadata} from '../core/metadata';
import {DirectiveResolver} from 'angular2/src/core/linker/directive_resolver';
@Injectable()
export class MockDirectiveResolver extends DirectiveResolver {
private _providerOverrides = new Map<Type, any[]>();
private viewProviderOverrides = new Map<Type, any[]>();

View File

@ -1,7 +1,9 @@
import {Injectable} from 'angular2/src/core/di';
import {EventEmitter, ObservableWrapper} from 'angular2/src/facade/async';
import {ListWrapper} from 'angular2/src/facade/collection';
import {Location} from 'angular2/src/router/location';
@Injectable()
export class SpyLocation implements Location {
urlChanges: string[] = [];
/** @internal */

View File

@ -1,10 +1,12 @@
import {ApplicationRef} from 'angular2/src/core/application_ref';
import {Injectable} from 'angular2/src/core/di';
import {Type} from 'angular2/src/facade/lang';
import {ComponentRef} from 'angular2/src/core/linker/dynamic_component_loader';
import {Provider, Injector} from 'angular2/src/core/di';
import {NgZone} from 'angular2/src/core/zone/ng_zone';
import {Promise} from 'angular2/src/facade/async';
@Injectable()
export class MockApplicationRef extends ApplicationRef {
registerBootstrapListener(listener: (ref: ComponentRef) => void): void {}
@ -23,4 +25,4 @@ export class MockApplicationRef extends ApplicationRef {
tick(): void {}
get componentTypes(): Type[] { return null; };
}
}

View File

@ -1,7 +1,9 @@
import {Injectable} from 'angular2/src/core/di';
import {EventEmitter, ObservableWrapper} from 'angular2/src/facade/async';
import {LocationStrategy} from 'angular2/src/router/location_strategy';
@Injectable()
export class MockLocationStrategy extends LocationStrategy {
internalBaseHref: string = '/';
internalPath: string = '/';

View File

@ -1,6 +1,8 @@
import {Injectable} from 'angular2/src/core/di';
import {NgZone} from 'angular2/src/core/zone/ng_zone';
import {EventEmitter, ObservableWrapper} from 'angular2/src/facade/async';
@Injectable()
export class MockNgZone extends NgZone {
/** @internal */
_mockOnEventDone: EventEmitter<any>;

View File

@ -1,3 +1,4 @@
import {Injectable} from 'angular2/src/core/di';
import {Map, MapWrapper, ListWrapper} from 'angular2/src/facade/collection';
import {Type, isPresent, stringify, isBlank} from 'angular2/src/facade/lang';
import {BaseException, WrappedException} from 'angular2/src/facade/exceptions';
@ -5,6 +6,7 @@ import {BaseException, WrappedException} from 'angular2/src/facade/exceptions';
import {ViewMetadata} from '../core/metadata';
import {ViewResolver} from 'angular2/src/core/linker/view_resolver';
@Injectable()
export class MockViewResolver extends ViewResolver {
/** @internal */
_views = new Map<Type, ViewMetadata>();

View File

@ -1,7 +1,9 @@
import {Injectable} from 'angular2/src/core/di';
import {ListWrapper, MapWrapper} from 'angular2/src/facade/collection';
import {DOM} from 'angular2/src/platform/dom/dom_adapter';
import {isPresent, isString, RegExpWrapper, StringWrapper, RegExp} from 'angular2/src/facade/lang';
@Injectable()
export class Log {
/** @internal */
_result: any[];

View File

@ -1,3 +1,4 @@
import {Injectable} from 'angular2/src/core/di';
import {
AsyncTestCompleter,
inject,
@ -21,6 +22,7 @@ function microTask(fn: Function): void {
PromiseWrapper.resolve(null).then((_) => { fn(); });
}
@Injectable()
class MockNgZone extends NgZone {
_onTurnStartStream: EventEmitter<any>;
get onTurnStart() { return this._onTurnStartStream; }