UNPKG

declapract

Version:

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

41 lines 2.45 kB
"use strict"; 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', async () => { const project = await (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', async () => { const project = await (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', async () => { const project = await (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', async () => { const project = await (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