UNPKG

@sprucelabs/spruce-cli

Version:

Command line interface for building Spruce skills.

61 lines 2.85 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 AbstractCliTest_1 = __importDefault(require("../../tests/AbstractCliTest")); const test_utility_1 = __importDefault(require("../../tests/utilities/test.utility")); class FeatureFixtureTest extends AbstractCliTest_1.default { static cacheDirs = []; static cacheKey = `feature-fixture-${new Date().getTime()}`; static async setsUpCachedDir() { const cachedDir = await this.installSkill(); this.cacheDirs.push(cachedDir); } static async setsUpSecondCachedDir() { const cachedDir = await this.installSkill(); this.cacheDirs.push(cachedDir); } static async afterAll() { await super.afterAll(); if (test_utility_1.default.shouldCleanupTestSkillDirs()) { // first dir should stay because it's the cached source test_utils_1.assert.isTrue(spruce_skill_utils_1.diskUtil.doesDirExist(this.cacheDirs[0])); // all other dirs are deleted test_utils_1.assert.isFalse(spruce_skill_utils_1.diskUtil.doesDirExist(this.cacheDirs[1])); } } static async installSkill() { const fixture = this.FeatureFixture({ shouldGenerateCacheIfMissing: true, }); await fixture.installFeatures([ { code: 'skill', options: { name: 'cache-cleaning', description: 'testing deleting cached dirs', }, }, ], this.cacheKey); const cachedDir = this.resolvePath(''); test_utils_1.assert.isTrue(spruce_skill_utils_1.diskUtil.doesDirExist(cachedDir)); return cachedDir; } } exports.default = FeatureFixtureTest; __decorate([ (0, test_utils_1.test)() ], FeatureFixtureTest, "setsUpCachedDir", null); __decorate([ (0, test_utils_1.test)() ], FeatureFixtureTest, "setsUpSecondCachedDir", null); //# sourceMappingURL=FeatureFixture.test.js.map