UNPKG

@sprucelabs/spruce-cli

Version:

Command line interface for building Spruce skills.

78 lines 3.63 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 globby_1 = __importDefault(require("@sprucelabs/globby")); const spruce_skill_utils_1 = require("@sprucelabs/spruce-skill-utils"); const test_utils_1 = require("@sprucelabs/test-utils"); const CommandService_1 = __importDefault(require("../../../services/CommandService")); const AbstractSkillTest_1 = __importDefault(require("../../../tests/AbstractSkillTest")); class WorkingWithViewsInNodeModuleTest extends AbstractSkillTest_1.default { static skillCacheKey = 'node'; static async beforeEach() { await super.beforeEach(); CommandService_1.default.fakeCommand(new RegExp(/^(?!code\b).*/), { code: 0, }); } static async creatingViewDoesNotWritePlugins() { const promise = this.Action('view', 'create', { shouldAutoHandleDependencies: true, }).execute({ viewType: 'view', nameReadable: 'My Test View', viewModel: 'Card', }); await this.waitForInput(); await this.ui.sendInput('n'); await this.waitForInput(); await this.ui.sendInput('y'); await this.waitForInput(); await this.ui.sendInput('y'); await this.waitForInput(); await this.ui.sendInput('y'); await this.waitForInput(); await this.ui.sendInput(''); await promise; await this.assertNoPluginsWritten(); } static async upgradingDoesNotWritePlugins() { await this.upgrade(); await this.assertNoPluginsWritten(); } static async upgradeDoesRecreateViewsTs() { const file = this.resolvePath('src/.spruce/views/views.ts'); const contents = spruce_skill_utils_1.diskUtil.readFile(file); spruce_skill_utils_1.diskUtil.deleteFile(file); await this.upgrade(); const newContents = spruce_skill_utils_1.diskUtil.readFile(file); test_utils_1.assert.isEqual(newContents, contents, 'views.ts should be rewritten.'); } static async upgrade() { await this.Action('node', 'upgrade').execute({}); } static async assertNoPluginsWritten() { const matches = await (0, globby_1.default)('src/.spruce/features/*.plugin.ts', { cwd: this.skillDir, }); test_utils_1.assert.isLength(matches, 0, `Should not create plugin files ${JSON.stringify(matches, null, 2)}.`); } } exports.default = WorkingWithViewsInNodeModuleTest; __decorate([ (0, test_utils_1.test)() ], WorkingWithViewsInNodeModuleTest, "creatingViewDoesNotWritePlugins", null); __decorate([ (0, test_utils_1.test)() ], WorkingWithViewsInNodeModuleTest, "upgradingDoesNotWritePlugins", null); __decorate([ (0, test_utils_1.test)() ], WorkingWithViewsInNodeModuleTest, "upgradeDoesRecreateViewsTs", null); //# sourceMappingURL=WorkingWithViewsInNodeModule.test.js.map