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

100% Statements 12/12
100% Branches 0/0
100% Functions 2/2
100% Lines 12/12
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19  252× 252× 4587× 4587× 4579×   4587×     252×   252× 252×    
"use strict";
var _spying_1 = require("../_spying");
function SpyOn(target, functionName) {
    var spy = new _spying_1.RestorableSpy(target, functionName);
    target[functionName] = function () {
        var args = [];
        for (var _i = 0; _i < arguments.length; _i++) {
            args[_i - 0] = arguments[_i];
        }
        return spy.call(args);
    };
    // expose spy's calls on function
    target[functionName].calls = spy.calls;
    // expose spy's restore function
    target[functionName].restore = spy.restore.bind(spy);
    return spy;
}
exports.SpyOn = SpyOn;
//# sourceMappingURL=spy-on.js.map