@sprucelabs/spruce-cli
Version:
Command line interface for building Spruce skills.
49 lines • 2.63 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const test_utils_1 = require("@sprucelabs/test-utils");
const test_utils_2 = require("@sprucelabs/test-utils");
const constants_1 = require("../../features/cache/constants");
const CommandService_1 = __importDefault(require("../../services/CommandService"));
const AbstractCliTest_1 = __importDefault(require("../../tests/AbstractCliTest"));
class ActionExecuter4Test extends AbstractCliTest_1.default {
static async beforeEach() {
await super.beforeEach();
CommandService_1.default.fakeCommand(/which docker/gis, {
code: 0,
});
CommandService_1.default.fakeCommand(constants_1.ENABLE_NPM_CACHE_COMMAND, {
code: 0,
});
}
static async canBeConfiguredToThrowWhenExecuteListenersReturnErrors(msg, willDid = 'will') {
await this.emitter.on(`feature.${willDid}-execute`, () => {
throw new Error(msg);
});
const err = await test_utils_1.assert.doesThrowAsync(() => this.Action('cache', 'enable').execute({}));
test_utils_2.errorAssert.assertError(err, 'LISTENER_ERROR', {
'originalError.message': msg,
});
}
static async stillReturnsIfNoErrorThrows() {
await this.Action('cache', 'enable').execute({});
}
}
exports.default = ActionExecuter4Test;
__decorate([
(0, test_utils_1.test)('throws by default with will-execute listener error 1', 'test'),
(0, test_utils_1.test)('throws by default with will-execute listener error 2', 'test2'),
(0, test_utils_1.test)('throws by default with did-execute listener error 1', 'test2', 'did')
], ActionExecuter4Test, "canBeConfiguredToThrowWhenExecuteListenersReturnErrors", null);
__decorate([
(0, test_utils_1.test)()
], ActionExecuter4Test, "stillReturnsIfNoErrorThrows", null);
//# sourceMappingURL=ActionExecuter4.test.js.map