feat(PromisePipe): remove ref onDestroy
This commit is contained in:
parent
dee4ecbb3f
commit
4afd2b4138
|
@ -44,7 +44,11 @@ export class PromisePipe extends Pipe {
|
|||
supports(promise): boolean { return PromiseWrapper.isPromise(promise); }
|
||||
|
||||
onDestroy(): void {
|
||||
// NO-OP
|
||||
if (isPresent(this._sourcePromise)) {
|
||||
this._latestValue = null;
|
||||
this._latestReturnedValue = null;
|
||||
this._sourcePromise = null;
|
||||
}
|
||||
}
|
||||
|
||||
transform(promise: Promise<any>): any {
|
||||
|
|
|
@ -84,6 +84,26 @@ export function main() {
|
|||
async.done();
|
||||
}, 0)
|
||||
}));
|
||||
|
||||
describe("onDestroy", () => {
|
||||
it("should do nothing when no source", () => {
|
||||
expect(() => pipe.onDestroy()).not.toThrow();
|
||||
});
|
||||
|
||||
it("should dispose of the existing source", inject([AsyncTestCompleter], (async) => {
|
||||
pipe.transform(completer.promise);
|
||||
expect(pipe.transform(completer.promise)).toBe(null);
|
||||
completer.resolve(message)
|
||||
|
||||
|
||||
TimerWrapper.setTimeout(() => {
|
||||
expect(pipe.transform(completer.promise)).toEqual(new WrappedValue(message));
|
||||
pipe.onDestroy();
|
||||
expect(pipe.transform(completer.promise)).toBe(null);
|
||||
async.done();
|
||||
}, 0);
|
||||
}));
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue