@sprucelabs/spruce-cli
Version:
Command line interface for building Spruce skills.
74 lines • 3.94 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 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 TestingDataStoresTest extends AbstractSkillTest_1.default {
static skillCacheKey = 'storesWithTests';
static async cantSelectAbstractStoreIfStoreFeatureNotInstalled() {
const storeFeature = this.cli.getFeature('store');
storeFeature.isInstalled = async () => false;
void this.Action('test', 'create').execute({
type: 'behavioral',
nameReadable: 'Can book appointment',
nameCamel: 'canBookAppointment',
namePascal: 'CanBookAppointment',
});
await this.waitForInput();
const last = this.ui.getLastInvocation();
test_utils_1.assert.isTruthy(last.options.options.choices);
test_utils_1.assert.doesInclude(last.options.options.choices, {
label: 'AbstractStoreTest (requires install)',
});
this.ui.reset();
}
static async letsYouSelectAbstractStoreTest() {
LintService_1.default.enableLinting();
this.cli.getFeature('store').isInstalled = async () => true;
const promise = this.Action('test', 'create').execute({
type: 'behavioral',
nameReadable: 'Can book appointment',
nameCamel: 'canBookAppointment',
namePascal: 'CanBookAppointment',
});
await this.waitForInput();
const last = this.ui.getLastInvocation();
test_utils_1.assert.isTruthy(last.options.options.choices);
test_utils_1.assert.doesInclude(last.options.options.choices, {
label: 'AbstractStoreTest',
});
await this.selectOptionBasedOnLabel('AbstractStoreTest');
const results = await promise;
test_utils_1.assert.isFalsy(results.errors);
const match = test_utility_1.default.assertFileByNameInGeneratedFiles('CanBookAppointment.test.ts', results.files);
const contents = spruce_skill_utils_1.diskUtil.readFile(match);
test_utils_1.assert.doesInclude(contents, 'CanBookAppointmentTest extends AbstractStoreTest');
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);
const first = testResults.errors[0];
test_utils_1.assert.doesInclude(first.message, 'does not equal');
}
}
exports.default = TestingDataStoresTest;
__decorate([
(0, test_utils_1.test)()
], TestingDataStoresTest, "cantSelectAbstractStoreIfStoreFeatureNotInstalled", null);
__decorate([
(0, test_utils_1.test)()
], TestingDataStoresTest, "letsYouSelectAbstractStoreTest", null);
//# sourceMappingURL=TestingDataStores.test.js.map