UNPKG

@sprucelabs/spruce-cli

Version:

Command line interface for building Spruce skills.

79 lines 4.55 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_event_utils_1 = require("@sprucelabs/spruce-event-utils"); const test_utils_1 = require("@sprucelabs/test-utils"); const TerminalInterface_1 = __importDefault(require("../../interfaces/TerminalInterface")); const AbstractSkillTest_1 = __importDefault(require("../../tests/AbstractSkillTest")); class SettingRemoteTest extends AbstractSkillTest_1.default { static skillCacheKey = 'events'; static async hasSetRemoteAction() { test_utils_1.assert.isFunction(this.Action('event', 'setRemote').execute); } static async savesRemote(remote, expected) { await this.Action('event', 'setRemote').execute({ remote }); const env = this.Service('env'); const host = env.get('HOST'); test_utils_1.assert.isEqual(host, expected); } static async shouldAskForRemoteBeforeEventActionIsInvokedIfTerminalSupportsIt(feature, action) { TerminalInterface_1.default.setDoesSupportColor(true); const env = this.Service('env'); env.unset('HOST'); void this.Action(feature, action, { shouldAutoHandleDependencies: true, }).execute({}); await this.waitForInput(); const last = this.ui.getLastInvocation(); test_utils_1.assert.doesInclude(last.options.label, 'remote'); this.ui.reset(); } static async shouldThrowBeforeEventActionIsInvokedIfTerminalSupportsIt(action) { TerminalInterface_1.default.setDoesSupportColor(false); const env = this.Service('env'); env.unset('HOST'); const results = await this.Action('event', action, { shouldThrowOnListenerError: false, }).execute({}); test_utils_1.assert.isTruthy(results.errors); test_utils_1.assert.doesInclude(results.errors[0].stack, 'env.HOST'); } static async resultsOfCommandHasRemoteMixedIntoSummary() { this.Service('remote').set('developer'); const results = await this.Action('event', 'sync').execute({}); test_utils_1.assert.isTruthy(results.summaryLines); test_utils_1.assert.doesInclude(results.summaryLines, 'Remote: dev'); } } exports.default = SettingRemoteTest; __decorate([ (0, test_utils_1.test)() ], SettingRemoteTest, "hasSetRemoteAction", null); __decorate([ (0, test_utils_1.test)(`saves local as ${spruce_event_utils_1.REMOTE_LOCAL}`, `local`, `${spruce_event_utils_1.REMOTE_LOCAL}`), (0, test_utils_1.test)(`saves dev as ${spruce_event_utils_1.REMOTE_DEV}`, `developer`, `${spruce_event_utils_1.REMOTE_DEV}`), (0, test_utils_1.test)(`saves sandbox as ${spruce_event_utils_1.REMOTE_SANDBOX}`, `sandbox`, `${spruce_event_utils_1.REMOTE_SANDBOX}`), (0, test_utils_1.test)(`saves prod as ${spruce_event_utils_1.REMOTE_PROD}`, `production`, `${spruce_event_utils_1.REMOTE_PROD}`) ], SettingRemoteTest, "savesRemote", null); __decorate([ (0, test_utils_1.test)('create.event asks for remote on IS TTY', 'event', 'create'), (0, test_utils_1.test)('sync.events asks for remote on IS TTY', 'event', 'sync'), (0, test_utils_1.test)('login asks for remote on IS TTY', 'person', 'login'), (0, test_utils_1.test)('login.skill asks for remote on IS TTY', 'skill', 'login') ], SettingRemoteTest, "shouldAskForRemoteBeforeEventActionIsInvokedIfTerminalSupportsIt", null); __decorate([ (0, test_utils_1.test)('create.event throws for remote on NOT TTY', 'create', false), (0, test_utils_1.test)('sync.events throws for remote on NOT TTY', 'sync', false) ], SettingRemoteTest, "shouldThrowBeforeEventActionIsInvokedIfTerminalSupportsIt", null); __decorate([ (0, test_utils_1.test)() ], SettingRemoteTest, "resultsOfCommandHasRemoteMixedIntoSummary", null); //# sourceMappingURL=SettingRemote.test.js.map