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 {Map, MapWrapper, ListWrapper} from 'angular2/src/facade/collection';
import {Type, isPresent, stringify, isBlank, print} from 'angular2/src/facade/lang'; import {Type, isPresent, stringify, isBlank, print} from 'angular2/src/facade/lang';
import {DirectiveMetadata, ComponentMetadata} from '../core/metadata'; import {DirectiveMetadata, ComponentMetadata} from '../core/metadata';
import {DirectiveResolver} from 'angular2/src/core/linker/directive_resolver'; import {DirectiveResolver} from 'angular2/src/core/linker/directive_resolver';
@Injectable()
export class MockDirectiveResolver extends DirectiveResolver { export class MockDirectiveResolver extends DirectiveResolver {
private _providerOverrides = new Map<Type, any[]>(); private _providerOverrides = new Map<Type, any[]>();
private viewProviderOverrides = 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 {EventEmitter, ObservableWrapper} from 'angular2/src/facade/async';
import {ListWrapper} from 'angular2/src/facade/collection'; import {ListWrapper} from 'angular2/src/facade/collection';
import {Location} from 'angular2/src/router/location'; import {Location} from 'angular2/src/router/location';
@Injectable()
export class SpyLocation implements Location { export class SpyLocation implements Location {
urlChanges: string[] = []; urlChanges: string[] = [];
/** @internal */ /** @internal */

View File

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

View File

@ -1,7 +1,9 @@
import {Injectable} from 'angular2/src/core/di';
import {EventEmitter, ObservableWrapper} from 'angular2/src/facade/async'; import {EventEmitter, ObservableWrapper} from 'angular2/src/facade/async';
import {LocationStrategy} from 'angular2/src/router/location_strategy'; import {LocationStrategy} from 'angular2/src/router/location_strategy';
@Injectable()
export class MockLocationStrategy extends LocationStrategy { export class MockLocationStrategy extends LocationStrategy {
internalBaseHref: string = '/'; internalBaseHref: string = '/';
internalPath: 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 {NgZone} from 'angular2/src/core/zone/ng_zone';
import {EventEmitter, ObservableWrapper} from 'angular2/src/facade/async'; import {EventEmitter, ObservableWrapper} from 'angular2/src/facade/async';
@Injectable()
export class MockNgZone extends NgZone { export class MockNgZone extends NgZone {
/** @internal */ /** @internal */
_mockOnEventDone: EventEmitter<any>; _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 {Map, MapWrapper, ListWrapper} from 'angular2/src/facade/collection';
import {Type, isPresent, stringify, isBlank} from 'angular2/src/facade/lang'; import {Type, isPresent, stringify, isBlank} from 'angular2/src/facade/lang';
import {BaseException, WrappedException} from 'angular2/src/facade/exceptions'; 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 {ViewMetadata} from '../core/metadata';
import {ViewResolver} from 'angular2/src/core/linker/view_resolver'; import {ViewResolver} from 'angular2/src/core/linker/view_resolver';
@Injectable()
export class MockViewResolver extends ViewResolver { export class MockViewResolver extends ViewResolver {
/** @internal */ /** @internal */
_views = new Map<Type, ViewMetadata>(); _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 {ListWrapper, MapWrapper} from 'angular2/src/facade/collection';
import {DOM} from 'angular2/src/platform/dom/dom_adapter'; import {DOM} from 'angular2/src/platform/dom/dom_adapter';
import {isPresent, isString, RegExpWrapper, StringWrapper, RegExp} from 'angular2/src/facade/lang'; import {isPresent, isString, RegExpWrapper, StringWrapper, RegExp} from 'angular2/src/facade/lang';
@Injectable()
export class Log { export class Log {
/** @internal */ /** @internal */
_result: any[]; _result: any[];

View File

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