@sprucelabs/spruce-cli
Version:
Command line interface for building Spruce skills.
75 lines • 3.93 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 AbstractErrorTest_1 = __importDefault(require("../../../tests/AbstractErrorTest"));
const test_utility_1 = __importDefault(require("../../../tests/utilities/test.utility"));
class CreatingANewErrorBuilderTest extends AbstractErrorTest_1.default {
static async hasCreateAction() {
test_utils_1.assert.isFunction(this.Action('error', 'create').execute);
}
static async createsValidBuilder() {
const action = await this.installErrorsAndGetCreateAction();
const results = await action.execute({
nameReadable: 'Test failed',
nameCamel: 'testFailed',
});
test_utils_1.assert.isFalsy(results.errors);
const match = test_utility_1.default.assertFileByNameInGeneratedFiles(/testFailed.builder/, results.files);
await this.Service('typeChecker').check(match);
}
static async buildCreatesValidSchemaAndOptionsFile() {
const action = await this.installErrorsAndGetCreateAction();
const results = await action.execute({
nameReadable: 'Test pass',
nameCamel: 'testPass',
});
test_utils_1.assert.isFalsy(results.errors);
test_utility_1.default.assertFileByNameInGeneratedFiles(/testPass\.schema/, results.files);
test_utility_1.default.assertFileByNameInGeneratedFiles(/options\.types/, results.files);
await this.assertValidActionResponseFiles(results);
}
static async buildCreatesValidSchemaAndOptionsFileWhenFetchCoreSchemasFalse() {
const action = await this.installErrorsAndGetCreateAction();
const results = await action.execute({
nameReadable: 'Test pass',
nameCamel: 'testPass',
shouldFetchCoreSchemas: false,
});
test_utils_1.assert.isFalsy(results.errors);
test_utility_1.default.assertFileByNameInGeneratedFiles(/testPass\.schema/, results.files);
test_utility_1.default.assertFileByNameInGeneratedFiles(/options\.types/, results.files);
await this.assertValidActionResponseFiles(results);
const cli = await this.Cli();
const health = await cli.checkHealth();
test_utils_1.assert.isFalsy(health.schema?.errors);
test_utils_1.assert.isTruthy(health.schema?.schemas);
test_utils_1.assert.isLength(health.schema.schemas, 0);
}
static async installErrorsAndGetCreateAction() {
await this.installErrorFeature('errors');
return this.Action('error', 'create');
}
}
exports.default = CreatingANewErrorBuilderTest;
__decorate([
(0, test_utils_1.test)()
], CreatingANewErrorBuilderTest, "hasCreateAction", null);
__decorate([
(0, test_utils_1.test)()
], CreatingANewErrorBuilderTest, "createsValidBuilder", null);
__decorate([
(0, test_utils_1.test)()
], CreatingANewErrorBuilderTest, "buildCreatesValidSchemaAndOptionsFile", null);
__decorate([
(0, test_utils_1.test)()
], CreatingANewErrorBuilderTest, "buildCreatesValidSchemaAndOptionsFileWhenFetchCoreSchemasFalse", null);
//# sourceMappingURL=CreatingANewErrorBuilder.test.js.map