@sprucelabs/spruce-cli
Version:
Command line interface for building Spruce skills.
67 lines • 3.1 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 RemoteService_1 = __importDefault(require("../../../features/event/services/RemoteService"));
const ServiceFactory_1 = __importDefault(require("../../../services/ServiceFactory"));
const AbstractSkillTest_1 = __importDefault(require("../../../tests/AbstractSkillTest"));
class SettingRemoteDoesNotAskTwiceTest extends AbstractSkillTest_1.default {
static skillCacheKey = 'tests';
static async canSetRemoteWithoutOneAndOnlyBeAskedOnce() {
ServiceFactory_1.default.setServiceClass('remote', CountingRemoteService);
this.cleanEnv();
const promise = this.Action('event', 'setRemote', {
shouldAutoHandleDependencies: true,
}).execute({});
await this.confirmInstallSchemaFeature();
await this.confirmInstallPermissionFeature();
await this.confirmFinishedInstallingDependencies();
await this.waitForInput();
await this.ui.sendInput('local');
await promise;
}
static async confirmFinishedInstallingDependencies() {
await this.waitForInput();
await this.pressEnter();
}
static async confirmInstallPermissionFeature() {
await this.waitForInput();
await this.pressEnter();
}
static async confirmInstallSchemaFeature() {
await this.waitForInput();
await this.pressEnter();
}
static async pressEnter() {
await this.ui.sendInput('\n');
}
static cleanEnv() {
const envPath = this.resolvePath('.env');
spruce_skill_utils_1.diskUtil.deleteFile(envPath);
spruce_skill_utils_1.diskUtil.writeFile(envPath, 'SKILL_NAME="don\'t double me"');
}
}
exports.default = SettingRemoteDoesNotAskTwiceTest;
__decorate([
(0, test_utils_1.test)()
], SettingRemoteDoesNotAskTwiceTest, "canSetRemoteWithoutOneAndOnlyBeAskedOnce", null);
class CountingRemoteService extends RemoteService_1.default {
static wasCalled = false;
set(host) {
if (CountingRemoteService.wasCalled) {
throw new Error('Called twice');
}
super.set(host);
CountingRemoteService.wasCalled = true;
}
}
//# sourceMappingURL=SettingRemoteDoesNotAskTwice.test.js.map