UNPKG

@sprucelabs/spruce-cli

Version:

Command line interface for building Spruce skills.

120 lines 5.49 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 test_utils_1 = require("@sprucelabs/test-utils"); const test_utils_2 = require("@sprucelabs/test-utils"); const AbstractSkillTest_1 = __importDefault(require("../../tests/AbstractSkillTest")); const constants_1 = require("../../tests/constants"); const uiAssert_utility_1 = __importDefault(require("../../tests/utilities/uiAssert.utility")); class ConfiguringDependenciesTest extends AbstractSkillTest_1.default { static skillCacheKey = 'skills'; static parentSkill; static async hasAddDependencyAction() { test_utils_1.assert.isFunction(this.Action('dependency', 'add').execute); } static async errorsWhenPassedBadNamespace() { await this.getSkillFixture().registerCurrentSkill({ name: 'current skill in adding deps', }); const results = await this.Action('dependency', 'add').execute({ namespace: 'waka-waka', }); test_utils_1.assert.isTruthy(results.errors); test_utils_2.errorAssert.assertError(results.errors[0], 'SKILL_NOT_FOUND'); } static async succeedsWhenPassedGoodNamespace() { const parentSkill = await this.getSkillFixture().seedDemoSkill({ name: 'dependent skill', }); const results = await this.Action('dependency', 'add').execute({ namespace: parentSkill.slug, }); test_utils_1.assert.isFalsy(results.errors); this.parentSkill = parentSkill; const settings = this.Service('settings'); const dependencies = settings.get('dependencies'); test_utils_1.assert.isEqualDeep(dependencies, [ { id: parentSkill.id, namespace: parentSkill.slug, }, ]); } static async cantAddDependencyTwice() { const err = test_utils_1.assert.doesThrow(() => this.Service('dependency').add({ id: this.parentSkill.id, namespace: this.parentSkill.slug, })); test_utils_2.errorAssert.assertError(err, 'DEPENDENCY_EXISTS'); } static async asksToSelectSkillWhenNoNamespacePassed() { const otherSkill = await this.getSkillFixture().seedDemoSkill({ name: 'dependent skill', }); const promise = this.Action('dependency', 'add').execute({}); await this.waitForInput(); const last = this.ui.getLastInvocation(); test_utils_1.assert.doesInclude(last.options.options.choices, { value: otherSkill.slug, label: otherSkill.name, }); await this.ui.sendInput(otherSkill.slug); const results = await promise; test_utils_1.assert.isFalsy(results.errors); const settings = this.Service('settings'); const dependencies = settings.get('dependencies'); test_utils_1.assert.isEqualDeep(dependencies[1], { id: otherSkill.id, namespace: otherSkill.slug, }); } static async doesNotShowSkillsThatAreAlreadySetAsADependency() { await this.people.loginAsDemoPerson(); void this.Action('dependency', 'add').execute({}); await this.waitForInput(); uiAssert_utility_1.default.assertSelectDidNotRenderChoice(this.ui, this.parentSkill.slug, this.parentSkill.name); this.ui.reset(); } static async canAddSkillThatWasCreatedBySomeoneElse() { const skill = await this.getSkillFixture().seedDemoSkill({ name: 'global dependency skill', isPublished: true, }); await this.people.loginAsDemoPerson(constants_1.DEMO_NUMBER_GLOBAL_EVENTS); const results = await this.Action('dependency', 'add').execute({ namespace: skill.slug, }); test_utils_1.assert.isFalsy(results.errors); } } exports.default = ConfiguringDependenciesTest; __decorate([ (0, test_utils_1.test)() ], ConfiguringDependenciesTest, "hasAddDependencyAction", null); __decorate([ (0, test_utils_1.test)() ], ConfiguringDependenciesTest, "errorsWhenPassedBadNamespace", null); __decorate([ (0, test_utils_1.test)() ], ConfiguringDependenciesTest, "succeedsWhenPassedGoodNamespace", null); __decorate([ (0, test_utils_1.test)() ], ConfiguringDependenciesTest, "cantAddDependencyTwice", null); __decorate([ (0, test_utils_1.test)() ], ConfiguringDependenciesTest, "asksToSelectSkillWhenNoNamespacePassed", null); __decorate([ (0, test_utils_1.test)() ], ConfiguringDependenciesTest, "doesNotShowSkillsThatAreAlreadySetAsADependency", null); __decorate([ (0, test_utils_1.test)() ], ConfiguringDependenciesTest, "canAddSkillThatWasCreatedBySomeoneElse", null); //# sourceMappingURL=AddingADependency.test.js.map