UNPKG

declapract

Version:

A tool to declaratively define best practices, maintainable evolve them, and scalably enforce them.

50 lines 3.3 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const domain_1 = require("../../../../domain"); const dirPath_1 = require("../../../__test_assets__/dirPath"); const getProjectCheckDeclaration_1 = require("./getProjectCheckDeclaration"); describe('getProjectCheckDeclarationFromDirectory', () => { it('should define correctly when only one root level file check and a readme', () => __awaiter(void 0, void 0, void 0, function* () { const project = yield (0, getProjectCheckDeclaration_1.getProjectCheckDeclaration)({ purpose: domain_1.FileCheckPurpose.BEST_PRACTICE, declaredProjectDirectory: `${dirPath_1.testAssetsDirectoryPath}/example-best-practices-repo/src/practices/dates-and-times/best-practice`, }); expect(project.checks.length).toEqual(1); expect(project).toMatchSnapshot(); })); it('should define correctly when many files in many levels', () => __awaiter(void 0, void 0, void 0, function* () { const project = yield (0, getProjectCheckDeclaration_1.getProjectCheckDeclaration)({ purpose: domain_1.FileCheckPurpose.BEST_PRACTICE, declaredProjectDirectory: `${dirPath_1.testAssetsDirectoryPath}/example-best-practices-repo/src/practices/terraform/best-practice`, }); expect(project.checks.length).toEqual(7); expect(project).toMatchSnapshot(); })); it('should define correctly for a bad practice', () => __awaiter(void 0, void 0, void 0, function* () { const project = yield (0, getProjectCheckDeclaration_1.getProjectCheckDeclaration)({ purpose: domain_1.FileCheckPurpose.BAD_PRACTICE, declaredProjectDirectory: `${dirPath_1.testAssetsDirectoryPath}/example-best-practices-repo/src/practices/dates-and-times/bad-practices/moment`, }); expect(project.checks.length).toEqual(1); expect(project).toMatchSnapshot(); })); it('should still have the fix functions defined on the file checks', () => __awaiter(void 0, void 0, void 0, function* () { const project = yield (0, getProjectCheckDeclaration_1.getProjectCheckDeclaration)({ purpose: domain_1.FileCheckPurpose.BEST_PRACTICE, declaredProjectDirectory: `${dirPath_1.testAssetsDirectoryPath}/example-best-practices-repo/src/practices/prettier/best-practice`, }); expect(project.checks[0].fix).toBeDefined(); expect(project.checks[0].fix).not.toBeNull(); expect(project).toMatchSnapshot(); })); }); //# sourceMappingURL=getProjectCheckDeclaration.integration.test.js.map