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

100% Statements 9/9
100% Branches 0/0
100% Functions 2/2
100% Lines 7/7
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19           204×   5303× 2655×       204×   204×    
import {
    SpyCall,
    Spy
} from "./_namespace";
 
export function SpyOn(target: any, functionName: string) {
 
  let spy = new Spy(target[functionName], target);
 
  target[functionName] = (...args: Array<any>) => {
    return spy.call(args);
  };
 
  // expose spy's calls on function
  target[functionName].calls = spy.calls;
 
  return spy;
}