@sprucelabs/spruce-cli
Version:
Command line interface for building Spruce skills.
82 lines • 3.69 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 ServiceFactory_1 = __importDefault(require("../../../services/ServiceFactory"));
const AbstractCliTest_1 = __importDefault(require("../../../tests/AbstractCliTest"));
const MockLintService_1 = __importDefault(require("./MockLintService"));
class SyncingSchemasLintsOnceTest extends AbstractCliTest_1.default {
static writer;
static destinationPath;
static filepath;
static async beforeEach() {
await super.beforeEach();
this.destinationPath = this.resolvePath('/tmp', (0, test_utils_1.generateId)());
this.filepath = this.destinationPath;
ServiceFactory_1.default.setServiceClass('lint', MockLintService_1.default);
this.writer = this.writers.Writer('schema', {
fileDescriptions: [],
linter: new MockLintService_1.default(),
});
}
static async onlyLintsOnceWhenWritingLocalSchemas() {
await this.writeSchemasAndTypes();
MockLintService_1.default.assertPatterns([this.destinationPath]);
}
static async lintsAfterAllFilesAreWritten() {
const calls = [];
//@ts-ignore
this.writer.writeFileIfChangedMixinResults = async () => {
calls.push('writeFileIfChangedMixinResults');
return [];
};
//@ts-ignore
this.writer.lint = async () => {
calls.push('lint');
};
await this.writeSchemasAndTypes();
test_utils_1.assert.isEqualDeep(calls, [
'writeFileIfChangedMixinResults',
'writeFileIfChangedMixinResults',
'lint',
]);
}
static async writeSchemasAndTypes() {
await this.writer.writeSchemasAndTypes(this.filepath, {
fieldTemplateItems: [],
schemaTemplateItems: [
{
destinationDir: (0, test_utils_1.generateId)(),
id: (0, test_utils_1.generateId)(),
nameCamel: (0, test_utils_1.generateId)(),
namePascal: (0, test_utils_1.generateId)(),
nameReadable: (0, test_utils_1.generateId)(),
namespace: (0, test_utils_1.generateId)(),
schema: {
id: (0, test_utils_1.generateId)(),
namespace: (0, test_utils_1.generateId)(),
fields: {},
},
},
],
shouldImportCoreSchemas: false,
valueTypes: {},
});
}
}
exports.default = SyncingSchemasLintsOnceTest;
__decorate([
test_utils_1.test.only()
], SyncingSchemasLintsOnceTest, "onlyLintsOnceWhenWritingLocalSchemas", null);
__decorate([
(0, test_utils_1.test)()
], SyncingSchemasLintsOnceTest, "lintsAfterAllFilesAreWritten", null);
//# sourceMappingURL=SyncingSchemasLintsOnce.test.js.map