@sprucelabs/spruce-cli
Version:
Command line interface for building Spruce skills.
59 lines • 2.85 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 CommandService_1 = __importDefault(require("../../../services/CommandService"));
const AbstractSkillTest_1 = __importDefault(require("../../../tests/AbstractSkillTest"));
class WatchingSkillViewsTest extends AbstractSkillTest_1.default {
static skillCacheKey = 'views';
static oldBootExecute;
static action;
static wasHit = false;
static async beforeEach() {
await super.beforeEach();
this.wasHit = false;
this.action = this.Action('view', 'watch');
CommandService_1.default.fakeCommand('SHOULD_WATCH_VIEWS=true MAXIMUM_LOG_PREFIXES_LENGTH=0 yarn boot', {
code: 0,
callback: () => {
this.wasHit = true;
},
});
}
static async hasWatchSkillViewsEvent() {
test_utils_1.assert.isFunction(this.action.execute);
}
static async shouldCallBoot() {
void this.action.execute();
await this.wait(10);
test_utils_1.assert.isTrue(this.wasHit, 'did not run yarn boot with expected env vars');
}
static async doesNotCrashIfUsingCustomRemote() {
const envFile = this.resolvePath('.env');
const envContents = spruce_skill_utils_1.diskUtil.readFile(envFile);
const updated = envContents.replace('HOST="http://127.0.0.1:8081"', 'HOST="custom"');
spruce_skill_utils_1.diskUtil.writeFile(envFile, updated);
const results = await this.action.execute();
test_utils_1.assert.isFalsy(results.errors, 'Should not have errors');
}
}
exports.default = WatchingSkillViewsTest;
__decorate([
(0, test_utils_1.test)()
], WatchingSkillViewsTest, "hasWatchSkillViewsEvent", null);
__decorate([
(0, test_utils_1.test)()
], WatchingSkillViewsTest, "shouldCallBoot", null);
__decorate([
(0, test_utils_1.test)()
], WatchingSkillViewsTest, "doesNotCrashIfUsingCustomRemote", null);
//# sourceMappingURL=WatchingSkillViews.test.js.map