UNPKG

declapract

Version:

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

52 lines 3.45 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 dirPath_1 = require("../../../__test_assets__/dirPath"); const readPracticeDeclaration_1 = require("./readPracticeDeclaration"); describe('readPracticeDeclarationFromDirectory', () => { it('should define correctly when only the best-practice is defined', () => __awaiter(void 0, void 0, void 0, function* () { const practice = yield (0, readPracticeDeclaration_1.readPracticeDeclaration)({ declaredPracticeDirectory: `${dirPath_1.testAssetsDirectoryPath}/example-best-practices-repo/src/practices/util-sleep`, }); // console.log(JSON.stringify(practice, null, 2)); expect(practice.bestPractice).not.toEqual(null); expect(practice.badPractices.length).toEqual(0); expect(practice).toMatchSnapshot(); })); it('should define correctly when a bad-practice is defined', () => __awaiter(void 0, void 0, void 0, function* () { const practice = yield (0, readPracticeDeclaration_1.readPracticeDeclaration)({ declaredPracticeDirectory: `${dirPath_1.testAssetsDirectoryPath}/example-best-practices-repo/src/practices/dates-and-times`, }); expect(practice.bestPractice).not.toEqual(null); expect(practice.badPractices.length).toEqual(1); expect(practice).toMatchSnapshot(); })); it('should define correctly when best and bad practices are defined', () => __awaiter(void 0, void 0, void 0, function* () { const practice = yield (0, readPracticeDeclaration_1.readPracticeDeclaration)({ declaredPracticeDirectory: `${dirPath_1.testAssetsDirectoryPath}/example-best-practices-repo/src/practices/directory-structure-src`, }); expect(practice.bestPractice).not.toEqual(null); expect(practice.badPractices.length).toEqual(2); expect(practice).toMatchSnapshot(); })); it('should still have the fix functions defined on the file checks', () => __awaiter(void 0, void 0, void 0, function* () { var _a, _b; const practice = yield (0, readPracticeDeclaration_1.readPracticeDeclaration)({ declaredPracticeDirectory: `${dirPath_1.testAssetsDirectoryPath}/example-best-practices-repo/src/practices/prettier`, }); expect((_a = practice.bestPractice) === null || _a === void 0 ? void 0 : _a.checks[0].fix).toBeDefined(); expect((_b = practice.bestPractice) === null || _b === void 0 ? void 0 : _b.checks[0].fix).not.toEqual(null); expect(practice.bestPractice).not.toEqual(null); expect(practice.badPractices.length).toEqual(0); expect(practice).toMatchSnapshot(); })); }); //# sourceMappingURL=readPracticeDeclaration.integration.test.js.map