UNPKG

ts-mock-imports

Version:

Intuitive mocking for Typescript class imports

59 lines 2.62 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { if (ar || !(i in from)) { if (!ar) ar = Array.prototype.slice.call(from, 0, i); ar[i] = from[i]; } } return to.concat(ar || Array.prototype.slice.call(from)); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.StaticMockManager = void 0; var _1 = require("."); var StaticMockManager = (function (_super) { __extends(StaticMockManager, _super); function StaticMockManager() { return _super !== null && _super.apply(this, arguments) || this; } StaticMockManager.prototype.mock = function (funcName) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } return _super.prototype.mockFunction.apply(this, __spreadArray([funcName], args, false)); }; StaticMockManager.prototype.set = function (varName, replaceWith) { return _super.prototype.replace.call(this, varName, replaceWith); }; StaticMockManager.prototype.replace = function (name, arg) { this.stubClass[name] = arg; }; StaticMockManager.prototype.getAllFunctionNames = function (obj) { var funcNames = []; do { funcNames = funcNames.concat(Object.getOwnPropertyNames(obj) .filter(function (property) { return typeof obj[property] === 'function'; })); obj = Object.getPrototypeOf(obj); } while (obj && obj.prototype && obj.prototype !== Object.prototype); return funcNames; }; return StaticMockManager; }(_1.MockManager)); exports.StaticMockManager = StaticMockManager; //# sourceMappingURL=static-mock-manager.js.map