cli-dev-dependencies
Version:
Customized dev dependencies for ContentStack projects
26 lines (25 loc) • 910 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.fancy = exports.spy = void 0;
const tslib_1 = require("tslib");
const sinon_1 = tslib_1.__importDefault(require("sinon"));
const test_1 = require("@oclif/test");
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;
exports.fancy = test_1.test.register('spy', spy);
exports.default = exports.fancy;