@sprucelabs/spruce-cli
Version:
Command line interface for building Spruce skills.
75 lines • 3.47 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 AbstractSkillTest_1 = __importDefault(require("../../../tests/AbstractSkillTest"));
class PublishingASkillTest extends AbstractSkillTest_1.default {
static skillCacheKey = 'skills';
static action;
static skills;
static async beforeEach() {
await super.beforeEach();
this.action = this.Action('skill', 'publish');
this.skills = this.Store('skill');
await this.login();
}
static async requiresRegistrationBeforePublishing() {
const results = await this.execute();
test_utils_1.assert.isTruthy(results.errors, 'Expected errors but got none.');
test_utils_1.errorAssert.assertError(results.errors[0], 'NO_SKILLS_REGISTERED');
}
static async publishesSkillIfRegistered() {
await this.register();
await this.executeAndAssertNoErrors();
const skill = await this.loadCurrentSkill();
test_utils_1.assert.isTrue(skill.isPublished, 'Expected skill to be published.');
test_utils_1.assert.isTrue(skill.canBeInstalled, 'Expected skill to be installable.');
}
static async canSetToInstallable() {
await this.skills.unregisterSkill();
await this.register();
await this.executeAndAssertNoErrors({ isInstallable: false });
const skill = await this.loadCurrentSkill();
test_utils_1.assert.isTrue(skill.isPublished, 'Expected skill to be published.');
test_utils_1.assert.isFalse(skill.canBeInstalled, 'Expected skill to not be installable.');
}
static async loadCurrentSkill() {
return await this.Store('skill').loadCurrentSkill();
}
static async register() {
const slug = `my-new-skill-${new Date().getTime()}`;
await this.skills.register({
name: 'Publish skill test',
slug,
});
}
static async executeAndAssertNoErrors(options) {
const results = await this.execute(options);
test_utils_1.assert.isFalsy(results.errors, 'Expected no errors but got some.');
}
static async login() {
await this.people.loginAsDemoPerson('720-253-5250');
}
static async execute(options) {
return await this.action.execute(options);
}
}
exports.default = PublishingASkillTest;
__decorate([
(0, test_utils_1.test)()
], PublishingASkillTest, "requiresRegistrationBeforePublishing", null);
__decorate([
(0, test_utils_1.test)()
], PublishingASkillTest, "publishesSkillIfRegistered", null);
__decorate([
(0, test_utils_1.test)()
], PublishingASkillTest, "canSetToInstallable", null);
//# sourceMappingURL=PublishingASkill.test.js.map