all files / core/spying/ restorable-spy.ts

100% Statements 11/11
100% Branches 0/0
100% Functions 3/3
100% Lines 9/9
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19           290×   290× 290×        
import { Spy } from "./spy";
 
export class RestorableSpy extends Spy {
 
   private _functionName: string;
   private _target: any;
 
   public constructor(target: any, functionName: string) {
      super(target[functionName], target);
 
      this._functionName = functionName;
      this._target = target;
   }
 
   public restore() {
      this._target[this._functionName] = this.originalFunction;
   }
}