UNPKG

@contentstack/cli-dev-dependencies

Version:

Customized dev dependencies for ContentStack projects

25 lines (24 loc) 877 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.spy = void 0; const tslib_1 = require("tslib"); const sinon_1 = tslib_1.__importDefault(require("sinon")); const upperFirst_1 = tslib_1.__importDefault(require("lodash/upperFirst")); function spy(object, path, prefix) { if (object === undefined || path === undefined) throw new Error('should not be undefined'); return { run(ctx) { if (!ctx.spy) { ctx.spy = {}; } ctx.spy[(prefix && typeof path === 'string' ? `${prefix}${(0, upperFirst_1.default)(path)}` : path)] = sinon_1.default.spy(object, path); }, finally() { sinon_1.default.restore(); }, }; } exports.spy = spy; // export const fancy = test.register('spy', spy) as unknown as TestWitSpyType; // export default fancy;