@sprucelabs/spruce-cli
Version:
Command line interface for building Spruce skills.
64 lines • 2.73 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 ServiceFactory_1 = __importDefault(require("../../../services/ServiceFactory"));
const AbstractSkillTest_1 = __importDefault(require("../../../tests/AbstractSkillTest"));
class SyncingViewsLintsFilesTest extends AbstractSkillTest_1.default {
static skillCacheKey = 'views';
static async beforeEach() {
await super.beforeEach();
this.commandFaker.fakeCommand(/.*/, 0);
ServiceFactory_1.default.setFactoryClass('lint', MockLintService);
}
static async shouldLintGeneratedFiles() {
await this.createView();
await this.executeSync();
MockLintService.assertWasHit();
}
static async fixesWithExpectedPattern() {
await this.executeSync();
MockLintService.assertFixPattern(this.resolvePath('src/viewControllers/testView.vc.ts'));
}
static async executeSync() {
await this.Action('view', 'sync').execute({});
}
static async createView() {
await this.Action('view', 'create').execute({
nameReadable: 'Test view!',
namePascal: 'testView',
viewModel: 'Card',
viewType: 'view',
});
}
}
exports.default = SyncingViewsLintsFilesTest;
__decorate([
(0, test_utils_1.test)()
], SyncingViewsLintsFilesTest, "shouldLintGeneratedFiles", null);
__decorate([
(0, test_utils_1.test)()
], SyncingViewsLintsFilesTest, "fixesWithExpectedPattern", null);
class MockLintService {
static wasHit = false;
static fixPattern;
async fix(pattern) {
MockLintService.wasHit = true;
MockLintService.fixPattern = pattern;
}
static assertWasHit() {
test_utils_1.assert.isTrue(this.wasHit, `Lint service was not hit!`);
}
static assertFixPattern(pattern) {
test_utils_1.assert.isEqual(this.fixPattern, pattern);
}
}
//# sourceMappingURL=SyncingViewsLintsFiles.test.js.map