UNPKG

@sprucelabs/spruce-cli

Version:

Command line interface for building Spruce skills.

75 lines 3.46 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 constants_1 = require("../../constants"); const AbstractSkillTest_1 = __importDefault(require("../../tests/AbstractSkillTest")); const ScriptUpdater_1 = __importDefault(require("../../updaters/ScriptUpdater")); class RememberingUpgradeSelectionsTest extends AbstractSkillTest_1.default { static skillCacheKey = 'schemas'; static async changedScriptsHasAlwaysSkipOptions() { const expected = this.getExpectedBuildCi(); const updater = this.ScriptUpdater('build.ci', 'taco'); await this.assertShowsAlwaysSkipOption(updater); await this.ui.sendInput('alwaysSkip'); await this.wait(100); const pkg = this.Service('pkg'); const ci = pkg.get(['scripts', 'build.ci']); test_utils_1.assert.isEqual(ci, expected); } static getExpectedBuildCi() { //@ts-ignore return this.featureInstaller.getFeature('skill').scripts['build.ci']; } static async shouldNotAskASecondTime() { const updater = this.ScriptUpdater('build.ci', 'taco2'); await updater.update(); const expected = this.getExpectedBuildCi(); const pkg = this.Service('pkg'); const ci = pkg.get(['scripts', 'build.ci']); test_utils_1.assert.isEqual(ci, expected); } static async stillAsksAboutDifferentScript() { const updater = this.ScriptUpdater('build.dev', 'taco'); await this.assertShowsAlwaysSkipOption(updater); await this.ui.sendInput('alwaysSkip'); } static ScriptUpdater(key, value) { const updater = new ScriptUpdater_1.default({ pkg: this.Service('pkg'), latestScripts: { [key]: value, }, ui: this.ui, settings: this.Service('settings'), }); return updater; } static async assertShowsAlwaysSkipOption(updater) { void updater.update(); await this.waitForInput(); const last = this.ui.getLastInvocation(); test_utils_1.assert.doesInclude(last, { 'options.options.choices[].value': constants_1.FILE_ACTION_ALWAYS_SKIP, }); } } exports.default = RememberingUpgradeSelectionsTest; __decorate([ (0, test_utils_1.test)() ], RememberingUpgradeSelectionsTest, "changedScriptsHasAlwaysSkipOptions", null); __decorate([ (0, test_utils_1.test)() ], RememberingUpgradeSelectionsTest, "shouldNotAskASecondTime", null); __decorate([ (0, test_utils_1.test)() ], RememberingUpgradeSelectionsTest, "stillAsksAboutDifferentScript", null); //# sourceMappingURL=RememberingUpgradeSelections.test.js.map