UNPKG

@sprucelabs/spruce-cli

Version:

Command line interface for building Spruce skills.

88 lines 3.88 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 AbstractSkillTest_1 = __importDefault(require("../../../../tests/AbstractSkillTest")); const StaticToInstanceMigrator_1 = __importDefault(require("../../../../tests/staticToInstanceMigration/StaticToInstanceMigrator")); class MigratingTestsTest extends AbstractSkillTest_1.default { static action; static skillCacheKey = 'tests'; static async beforeEach() { await super.beforeEach(); StaticToInstanceMigrator_1.default.Class = FakeStaticToInstanceMigrator; this.action = this.Action('test', 'migrate'); } static async hasMigrateAction() { test_utils_1.assert.isFunction(this.Action('test', 'migrate').execute); } static async migrateCreatsMigrator() { const results = await this.execute(); test_utils_1.assert.isFalsy(results.errors); test_utils_1.assert.isTruthy(this.migrator, 'Migrator not created'); } static async migratorRunsMigratePassingLookupDir() { await this.execute(); this.migrator.assertLookupCalledWith(this.resolvePath('src', '__tests__')); } static async returnsResultsFromMigrator(totalTestsSkipped, totalTestsUpdated) { FakeStaticToInstanceMigrator.runResults = { totalTestsSkipped, totalTestsUpdated, }; const results = await this.execute(); test_utils_1.assert.isEqualDeep(results, { headline: 'Migrated tests from static to instance based.', summaryLines: [ `${totalTestsUpdated} test${totalTestsUpdated === 1 ? '' : 's'} updated`, `${totalTestsSkipped} test${totalTestsSkipped === 1 ? '' : 's'} skipped`, ], }); } static get migrator() { return FakeStaticToInstanceMigrator.instance; } static async execute() { return await this.action.execute(); } } exports.default = MigratingTestsTest; __decorate([ (0, test_utils_1.test)() ], MigratingTestsTest, "hasMigrateAction", null); __decorate([ (0, test_utils_1.test)() ], MigratingTestsTest, "migrateCreatsMigrator", null); __decorate([ (0, test_utils_1.test)() ], MigratingTestsTest, "migratorRunsMigratePassingLookupDir", null); __decorate([ (0, test_utils_1.test)('returns results from migrator 1', 1, 1), (0, test_utils_1.test)('returns results from migrator 2', 2, 3) ], MigratingTestsTest, "returnsResultsFromMigrator", null); class FakeStaticToInstanceMigrator { static instance; passedLookupDir; static runResults; constructor(_options) { FakeStaticToInstanceMigrator.instance = this; } async run(lookupDir) { this.passedLookupDir = lookupDir; return (FakeStaticToInstanceMigrator.runResults ?? { totalTestsUpdated: 0, totalTestsSkipped: 0, }); } assertLookupCalledWith(expected) { test_utils_1.assert.isEqual(this.passedLookupDir, expected, `Migrator.run was not called with expected lookup dir.`); } } //# sourceMappingURL=MigratingTests.test.js.map