UNPKG

@sprucelabs/spruce-cli

Version:

Command line interface for building Spruce skills.

75 lines 3.44 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 constants_1 = require("../../../tests/constants"); class SettingUpASkillForTestingTest extends AbstractSkillTest_1.default { static skillCacheKey = 'tests'; static skillSlug = `test-skill-${new Date().getTime()}`; static async hasSetupAction() { test_utils_1.assert.isFunction(this.Action('test', 'setup').execute); } static async logsInAsDemoPerson() { const results = await this.Action('test', 'setup').execute({ demoNumber: constants_1.DEMO_NUMBER, skillSlug: this.skillSlug, }); test_utils_1.assert.isFalsy(results.errors); const auth = this.Service('auth'); const person = auth.getLoggedInPerson(); test_utils_1.assert.isTruthy(person); } static async registersCurrentSkill() { const auth = this.Service('auth'); const skill = auth.getCurrentSkill(); test_utils_1.assert.isTruthy(skill); } static async canRunAgainWithoutError() { const results = await this.Action('test', 'setup').execute({ demoNumber: constants_1.DEMO_NUMBER, skillSlug: this.skillSlug, }); test_utils_1.assert.isFalsy(results.errors); const auth = this.Service('auth'); const skill = auth.getCurrentSkill(); test_utils_1.assert.isEqual(skill?.slug, this.skillSlug); } static async canCorrectInvalidAuth() { const auth = this.Service('auth'); //@ts-ignore auth.updateCurrentSkill({ fail: true }); const results = await this.Action('test', 'setup').execute({ demoNumber: constants_1.DEMO_NUMBER, skillSlug: this.skillSlug, }); test_utils_1.assert.isFalsy(results.errors); const skill = auth.getCurrentSkill(); test_utils_1.assert.isEqual(skill?.slug, this.skillSlug); } } exports.default = SettingUpASkillForTestingTest; __decorate([ (0, test_utils_1.test)() ], SettingUpASkillForTestingTest, "hasSetupAction", null); __decorate([ (0, test_utils_1.test)() ], SettingUpASkillForTestingTest, "logsInAsDemoPerson", null); __decorate([ (0, test_utils_1.test)() ], SettingUpASkillForTestingTest, "registersCurrentSkill", null); __decorate([ (0, test_utils_1.test)() ], SettingUpASkillForTestingTest, "canRunAgainWithoutError", null); __decorate([ (0, test_utils_1.test)() ], SettingUpASkillForTestingTest, "canCorrectInvalidAuth", null); //# sourceMappingURL=SettingUpASkillForTesting.test.js.map