@sprucelabs/spruce-cli
Version:
Command line interface for building Spruce skills.
85 lines • 3.66 kB
JavaScript
;
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 test_utils_2 = require("@sprucelabs/test-utils");
const LintService_1 = __importDefault(require("../../../services/LintService"));
const AbstractTestTest_1 = __importDefault(require("../../../tests/AbstractTestTest"));
class RunningTestsTest extends AbstractTestTest_1.default {
static hasCreatedTest;
static async beforeEach() {
await super.beforeEach();
this.hasCreatedTest = false;
LintService_1.default.enableLinting();
}
static async hasTestAction() {
await this.Cli();
test_utils_1.assert.isFunction(this.Action('test', 'test').execute);
}
static async runningTestsActuallyRunsTests() {
await this.installTests();
const creationResults = await this.createTest({
nameReadable: 'Can book appointment',
nameCamel: 'canBookAppointment',
namePascal: 'CanBookAppointment',
});
const file = creationResults.files?.[0];
test_utils_1.assert.isTruthy(file);
this.fixBadTest(file.path);
await this.createTest({
nameReadable: 'Can cancel appointment',
nameCamel: 'canCancelAppointment',
namePascal: 'CanCancelAppointment',
});
await this.Service('build').build();
const results = await this.Action('test', 'test').execute({
shouldReportWhileRunning: false,
});
test_utils_1.assert.isTruthy(results.errors);
test_utils_1.assert.isLength(results.errors, 1);
test_utils_2.errorAssert.assertError(results.errors[0], 'TEST_FAILED');
test_utils_1.assert.isTruthy(results.meta);
test_utils_1.assert.isTruthy(results.meta?.testResults);
test_utils_1.assert.doesInclude(results.meta?.testResults, {
wasKilled: false,
totalTestFiles: 2,
totalTestFilesComplete: 2,
totalFailed: 1,
totalPassed: 3,
totalSkipped: 0,
totalTests: 4,
totalTodo: 0,
});
}
static async createTest(options) {
const creationPromise = this.Action('test', 'create').execute({
type: 'behavioral',
...options,
});
if (this.hasCreatedTest) {
await this.waitForInput();
await this.ui.sendInput({ path: '.' });
}
this.hasCreatedTest = true;
await this.waitForInput();
await this.ui.sendInput('');
const creationResults = await creationPromise;
return creationResults;
}
}
exports.default = RunningTestsTest;
__decorate([
(0, test_utils_1.test)()
], RunningTestsTest, "hasTestAction", null);
__decorate([
(0, test_utils_1.test)()
], RunningTestsTest, "runningTestsActuallyRunsTests", null);
//# sourceMappingURL=RunningTests.test.js.map