@sprucelabs/spruce-cli
Version:
Command line interface for building Spruce skills.
59 lines • 2.57 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 AbstractPermissionsTest_1 = __importDefault(require("./support/AbstractPermissionsTest"));
class PermissionWriterTest extends AbstractPermissionsTest_1.default {
static file;
static async beforeEach() {
await super.beforeEach();
delete this.file;
}
static async writesProperContractId() {
const contractId = (0, test_utils_1.generateId)();
const perm1 = (0, test_utils_1.generateId)();
const perm2 = (0, test_utils_1.generateId)();
//@ts-ignore
await this.writeTypesFile({
[contractId]: [perm1, perm2],
});
await this.writeTestFileAndAssertValid(contractId, perm1, perm2);
}
static async writeFileIfChangedLints() {
const writer = this.Writer();
const destination = this.resolvePath((0, test_utils_1.generateId)() + '.ts');
let passedPattern;
//@ts-ignore
writer.lint = async (pattern) => {
passedPattern = pattern;
};
//@ts-ignore
await writer.writeFileIfChangedMixinResults(destination, 'contents', 'test');
test_utils_1.assert.isEqual(passedPattern, destination);
}
static async writeTypesFile(map) {
const writer = this.Writer();
await writer.writeTypesFile(this.cwd, map);
}
static Writer() {
return this.writers.Writer('permission', {
fileDescriptions: [],
});
}
}
exports.default = PermissionWriterTest;
__decorate([
(0, test_utils_1.test)()
], PermissionWriterTest, "writesProperContractId", null);
__decorate([
(0, test_utils_1.test)()
], PermissionWriterTest, "writeFileIfChangedLints", null);
//# sourceMappingURL=PermissionWriter.test.js.map