UNPKG

@sprucelabs/spruce-cli

Version:

Command line interface for building Spruce skills.

78 lines 3.59 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 AbstractSkillTest_1 = __importDefault(require("../../../tests/AbstractSkillTest")); const test_utility_1 = __importDefault(require("../../../tests/utilities/test.utility")); class KeepingViewsInSyncTest extends AbstractSkillTest_1.default { static skillCacheKey = 'views'; static action; static async beforeEach() { await super.beforeEach(); this.action = this.Action('view', 'sync'); } static async hasSyncAction() { test_utils_1.assert.isFunction(this.action.execute); } static async syncingWithNoViewsGeneratesNothing() { const results = await this.action.execute(); test_utils_1.assert.isFalsy(results.errors); test_utils_1.assert.isFalsy(results.files); } static async createsValidCombinedEventsFileWhenCreatingANewSvc() { const results = await this.Action('view', 'create').execute({ viewType: 'skillView', isRoot: true, }); await this.assertValuedViewsFile(results); } static async generatesValidTypesFileWithNoSkillViews() { const results = await this.Action('view', 'create').execute({ viewType: 'view', nameReadable: 'test', viewModel: 'Card', }); test_utils_1.assert.isFalsy(results.errors); await this.assertValuedViewsFile(results); } static async exportUndefinedApp() { const testScript = `import { App } from '#` + `spruce/views/views' if (App !== undefined) { throw new Error('App should be undefined') }`; const testScriptPath = this.resolvePath('src/test.ts'); spruce_skill_utils_1.diskUtil.writeFile(testScriptPath, testScript); await this.Service('typeChecker').check(testScriptPath); } static async assertValuedViewsFile(results) { const match = test_utility_1.default.assertFileByPathInGeneratedFiles(`views/views.ts`, results.files); await this.Service('typeChecker').check(match); } } exports.default = KeepingViewsInSyncTest; __decorate([ (0, test_utils_1.test)() ], KeepingViewsInSyncTest, "hasSyncAction", null); __decorate([ (0, test_utils_1.test)() ], KeepingViewsInSyncTest, "syncingWithNoViewsGeneratesNothing", null); __decorate([ (0, test_utils_1.test)() ], KeepingViewsInSyncTest, "createsValidCombinedEventsFileWhenCreatingANewSvc", null); __decorate([ (0, test_utils_1.test)() ], KeepingViewsInSyncTest, "generatesValidTypesFileWithNoSkillViews", null); __decorate([ (0, test_utils_1.test)() ], KeepingViewsInSyncTest, "exportUndefinedApp", null); //# sourceMappingURL=KeepingViewsInSync.test.js.map