UNPKG

@sprucelabs/spruce-cli

Version:

Command line interface for building Spruce skills.

64 lines 3.11 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 ScriptLoader_1 = __importDefault(require("../../features/onboard/ScriptLoader")); const ScriptPlayer_1 = __importDefault(require("../../features/onboard/ScriptPlayer")); const AbstractCliTest_1 = __importDefault(require("../../tests/AbstractCliTest")); class OnboardingScriptLoaderTest extends AbstractCliTest_1.default { static commandExecuterCommands = []; static scripLoaderLoadScriptsFunction() { test_utils_1.assert.isFunction(ScriptLoader_1.default.LoadScripts); } static async loadingScriptsReturnsPlayer() { const player = await this.Player(); test_utils_1.assert.isTrue(player instanceof ScriptPlayer_1.default); } static async Player() { return await ScriptLoader_1.default.LoadScripts({ ui: this.ui, dir: this.resolveTestPath('../support/scripts'), onboardingStore: this.Store('onboarding'), commandExecuter: async (command) => { this.commandExecuterCommands.push(command); }, }); } static async playsLoadedScripts() { const player = await this.Player(); await player.playScriptWithKey('first'); test_utils_1.assert.doesInclude(this.ui.invocations, { command: 'renderLine', options: { message: 'hello world' }, }); test_utils_1.assert.doesInclude(this.ui.invocations, { command: 'renderLine', options: { message: 'second script' }, }); test_utils_1.assert.doesInclude(this.ui.invocations, { command: 'renderLine', options: { message: 'the last script' }, }); test_utils_1.assert.isLength(this.commandExecuterCommands, 1); test_utils_1.assert.isEqual(this.commandExecuterCommands[0], 'first script command executed'); } } exports.default = OnboardingScriptLoaderTest; __decorate([ (0, test_utils_1.test)() ], OnboardingScriptLoaderTest, "scripLoaderLoadScriptsFunction", null); __decorate([ (0, test_utils_1.test)() ], OnboardingScriptLoaderTest, "loadingScriptsReturnsPlayer", null); __decorate([ (0, test_utils_1.test)() ], OnboardingScriptLoaderTest, "playsLoadedScripts", null); //# sourceMappingURL=OnboardingScriptLoader.test.js.map