UNPKG

@sprucelabs/spruce-cli

Version:

Command line interface for building Spruce skills.

83 lines 4.12 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_skill_utils_1 = require("@sprucelabs/spruce-skill-utils"); const test_utils_1 = require("@sprucelabs/test-utils"); const LintService_1 = __importDefault(require("../../../services/LintService")); const AbstractSkillTest_1 = __importDefault(require("../../../tests/AbstractSkillTest")); const test_utility_1 = __importDefault(require("../../../tests/utilities/test.utility")); class TestingViewControllersTest extends AbstractSkillTest_1.default { static skillCacheKey = 'viewsWithTests'; static async beforeEach() { await super.beforeEach(); LintService_1.default.enableLinting(); } static async showsNotInstalled() { const viewFeature = this.cli.getFeature('view'); viewFeature.isInstalled = async () => false; void this.executeCreate(); await this.waitForInput(); const last = this.ui.getLastInvocation(); test_utils_1.assert.doesInclude(last.options.options.choices, { label: 'AbstractViewControllerTest (requires install)', }); this.ui.reset(); } static async canSelectAbstractTest() { void this.executeCreate(); await this.waitForInput(); const last = this.ui.getLastInvocation(); test_utils_1.assert.doesInclude(last.options.options.choices, { label: 'AbstractViewControllerTest', }); this.ui.reset(); } static async testsRun() { const promise = this.executeCreate(); await this.waitForInput(); this.selectOptionBasedOnLabel('AbstractViewControllerTest'); const results = await promise; test_utils_1.assert.isFalsy(results.errors); const match = test_utility_1.default.assertFileByNameInGeneratedFiles('RenderingRootViewController.test.ts', results.files); const contents = spruce_skill_utils_1.diskUtil.readFile(match); test_utils_1.assert.doesInclude(contents, 'RenderingRootViewControllerTest extends AbstractViewControllerTest'); test_utils_1.assert.doesInclude(contents, "import { AbstractViewControllerTest } from '@sprucelabs/spruce-view-plugin'"); await this.Service('build').build(); const testResults = await this.Action('test', 'test').execute({ shouldReportWhileRunning: false, }); test_utils_1.assert.isArray(testResults.errors); test_utils_1.assert.isLength(testResults.errors, 1); test_utils_1.assert.doesInclude(testResults.meta?.testResults.testFiles, { path: 'behavioral/RenderingRootViewController.test.ts', status: 'failed', }); } static async executeCreate() { return this.Action('test', 'create').execute({ type: 'behavioral', nameReadable: 'Rendering root view controller', nameCamel: 'renderingRootViewController', namePascal: 'RenderingRootViewController', }); } } exports.default = TestingViewControllersTest; __decorate([ (0, test_utils_1.test)() ], TestingViewControllersTest, "showsNotInstalled", null); __decorate([ (0, test_utils_1.test)() ], TestingViewControllersTest, "canSelectAbstractTest", null); __decorate([ (0, test_utils_1.test)() ], TestingViewControllersTest, "testsRun", null); //# sourceMappingURL=TestingViewControllers.test.js.map