UNPKG

@sprucelabs/spruce-cli

Version:

Command line interface for building Spruce skills.

104 lines 4.68 kB
"use strict"; 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 spruce_skill_utils_1 = require("@sprucelabs/spruce-skill-utils"); const test_utils_1 = require("@sprucelabs/test-utils"); const AbstractCliTest_1 = __importDefault(require("../../../tests/AbstractCliTest")); class SettingUpPolishTest extends AbstractCliTest_1.default { static async hasCreateAction() { test_utils_1.assert.isFunction(this.Action('polish', 'setup').execute); } static async setsUpExpectedScript() { await this.installSkillAndSetupPolish(); await this.assertPolishScriptWrittenToExpectedPlace(); } static async polishResultsAreExpected() { const results = await this.installSkillAndSetupPolish(); const { filename, destination } = await this.generateExpectedFile(); test_utils_1.assert.isLength(results.files, 1); test_utils_1.assert.isEqualDeep(results, { files: [ { name: filename, description: `Polish script at ${filename}!`, path: destination, action: 'generated', }, ], }); } static async createsExpectedScript() { await this.installSkillAndSetupPolish(); const pkg = this.Service('pkg'); const scripts = pkg.get('scripts'); test_utils_1.assert.isEqual(scripts.polish, 'heartwood-polish'); } static async makeSureScriptHasSomethingAndIsValid() { const results = await this.installSkillAndSetupPolish(); const { destination } = await this.generateExpectedFile(); const contents = spruce_skill_utils_1.diskUtil.readFile(destination); test_utils_1.assert.isNotEqual(contents, ''); await this.assertValidActionResponseFiles(results); } static async polishCreatesExpectedFileNameBasedOnSkillsNamespace() { await this.installSkill(); const pkg = await this.Service('pkg'); const namespace = 'my-skill'; pkg.set({ path: ['skill', 'namespace'], value: namespace, }); await this.setupPolish(); await this.assertPolishScriptWrittenToExpectedPlace(); } static async assertPolishScriptWrittenToExpectedPlace() { const { destination } = await this.generateExpectedFile(); test_utils_1.assert.isTrue(spruce_skill_utils_1.diskUtil.doesFileExist(destination), `Did not find polish script at ${destination}!`); } static async generateExpectedFile() { const store = this.Store('skill'); const namespace = await store.loadCurrentSkillsNamespace(); const filename = `${spruce_skill_utils_1.namesUtil.toKebab(namespace)}.polish.ts`; const destination = this.resolvePath('src', filename); return { filename, destination }; } static async installSkillAndSetupPolish() { await this.installSkill(); const results = await this.setupPolish(); return results; } static async setupPolish() { return await this.Action('polish', 'setup').execute({}); } static async installSkill() { await this.FeatureFixture().installCachedFeatures('polish'); } } exports.default = SettingUpPolishTest; __decorate([ (0, test_utils_1.test)() ], SettingUpPolishTest, "hasCreateAction", null); __decorate([ (0, test_utils_1.test)() ], SettingUpPolishTest, "setsUpExpectedScript", null); __decorate([ (0, test_utils_1.test)() ], SettingUpPolishTest, "polishResultsAreExpected", null); __decorate([ (0, test_utils_1.test)() ], SettingUpPolishTest, "createsExpectedScript", null); __decorate([ (0, test_utils_1.test)() ], SettingUpPolishTest, "makeSureScriptHasSomethingAndIsValid", null); __decorate([ (0, test_utils_1.test)() ], SettingUpPolishTest, "polishCreatesExpectedFileNameBasedOnSkillsNamespace", null); //# sourceMappingURL=SettingUpPolish.test.js.map