refactor(pipes): removed pipes from properties

BREAKING CHANGE:

This PR remove an ability to use pipes in the properties config. Instead, inject the pipe registry.
This commit is contained in:
vsavkin
2015-06-18 15:40:12 -07:00
parent ad7aca631d
commit 20a8f0dbe5
31 changed files with 261 additions and 270 deletions

View File

@ -0,0 +1,24 @@
library test_lib.spies;
import 'package:angular2/change_detection.dart';
import './test_lib.dart';
@proxy
class SpyChangeDetector extends SpyObject implements ChangeDetector {
noSuchMethod(m) => super.noSuchMethod(m);
}
@proxy
class SpyProtoChangeDetector extends SpyObject implements ProtoChangeDetector {
noSuchMethod(m) => super.noSuchMethod(m);
}
@proxy
class SpyPipe extends SpyObject implements Pipe {
noSuchMethod(m) => super.noSuchMethod(m);
}
@proxy
class SpyPipeFactory extends SpyObject implements PipeFactory {
noSuchMethod(m) => super.noSuchMethod(m);
}

View File

@ -3,45 +3,19 @@ import {
ProtoChangeDetector,
DynamicChangeDetector
} from 'angular2/change_detection';
import {BasePipe} from 'angular2/src/change_detection/pipes/pipe';
import {SpyObject, proxy} from './test_lib';
// Remove dummy methods after https://github.com/angular/ts2dart/issues/209 is fixed.
@proxy
export class SpyChangeDetector extends SpyObject implements ChangeDetector {
parent: ChangeDetector;
mode: string;
constructor() { super(DynamicChangeDetector, true); }
addChild(cd: ChangeDetector): void { return this.spy("addChild")(cd); }
addShadowDomChild(cd: ChangeDetector): void { return this.spy("addShadowDomChild")(cd); }
removeChild(cd: ChangeDetector): void { return this.spy("removeChild")(cd); }
removeShadowDomChild(cd: ChangeDetector): void { return this.spy("removeShadowDomChild")(cd); }
remove(): void { return this.spy("remove")(); }
hydrate(context: any, locals: any, directives: any): void {
return this.spy("hydrate")(context, locals, directives);
}
dehydrate(): void { return this.spy("dehydrate")(); }
markPathToRootAsCheckOnce(): void { return this.spy("markPathToRootAsCheckOnce")(); }
detectChanges(): void { return this.spy("detectChanges")(); }
checkNoChanges(): void { return this.spy("checkNoChanges")(); }
noSuchMethod(m) { return super.noSuchMethod(m) }
export class SpyChangeDetector extends SpyObject {
constructor() { super(DynamicChangeDetector); }
}
// Remove dummy methods after https://github.com/angular/ts2dart/issues/209 is fixed.
@proxy
export class SpyProtoChangeDetector extends SpyObject implements ProtoChangeDetector {
constructor() { super(DynamicChangeDetector, true); }
export class SpyProtoChangeDetector extends SpyObject {
constructor() { super(DynamicChangeDetector); }
}
instantiate(v: any): any { return this.spy("instantiate")(v); }
}
export class SpyPipe extends SpyObject {
constructor() { super(BasePipe); }
}
export class SpyPipeFactory extends SpyObject {}

View File

@ -187,7 +187,7 @@ class SpyFunction extends gns.SpyFunction {
class SpyObject extends gns.SpyObject {
final Map<String, SpyFunction> _spyFuncs = {};
SpyObject([arg, arg2]) {}
SpyObject([arg]) {}
SpyFunction spy(String funcName) =>
_spyFuncs.putIfAbsent(funcName, () => new SpyFunction(funcName));

View File

@ -274,7 +274,7 @@ export interface GuinessCompatibleSpy extends jasmine.Spy {
}
export class SpyObject {
constructor(type = null, forceSpyCreation: boolean = false) {
constructor(type = null) {
if (type) {
for (var prop in type.prototype) {
var m = null;
@ -287,11 +287,7 @@ export class SpyObject {
// should not matter.
}
if (typeof m === 'function') {
if (forceSpyCreation) {
this.createSpy(prop);
} else {
this.spy(prop);
}
this.spy(prop);
}
}
}
@ -301,14 +297,8 @@ export class SpyObject {
spy(name) {
if (!this[name]) {
return this.createSpy(name);
} else {
return this[name];
this[name] = this._createGuinnessCompatibleSpy(name);
}
}
createSpy(name) {
this[name] = this._createGuinnessCompatibleSpy(name);
return this[name];
}