UNPKG

declapract

Version:

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

32 lines 1.83 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const removeFileAsync_1 = require("../../utils/fileio/removeFileAsync"); const listFilesInDirectory_1 = require("../../utils/filepaths/listFilesInDirectory"); const logger_1 = require("../../utils/logger"); const dirPath_1 = require("../__test_assets__/dirPath"); const apply_1 = require("./apply"); const logSpy = jest.spyOn(console, 'log').mockImplementation(() => logger_1.log.debug); // swap to log debug so its not displaying during tests by default describe('apply', () => { beforeEach(() => jest.clearAllMocks()); it('should be able to apply for an example project', async () => { const targetDir = `${dirPath_1.testAssetsDirectoryPath}/example-project-fails-use-case-lambda-service-for-fixing`; // delete the generated files to get the testing environment to the expected state const expectedFilesInDirectory = ['.gitignore', 'declapract.use.yml']; const filesInDirectory = await (0, listFilesInDirectory_1.listFilesInDirectory)({ directory: targetDir, }); await Promise.all(filesInDirectory .filter((path) => !expectedFilesInDirectory.includes(path)) .map((path) => (0, removeFileAsync_1.removeFileAsync)({ path: `${targetDir}/${path}` }))); const filesInDirectoryNow = await (0, listFilesInDirectory_1.listFilesInDirectory)({ directory: targetDir, }); expect(filesInDirectoryNow).toEqual(expectedFilesInDirectory); // fail if the test environment is not correct // now apply await (0, apply_1.apply)({ usePracticesConfigPath: `${targetDir}/declapract.use.yml`, }); expect(logSpy.mock.calls).toMatchSnapshot(); }); }); //# sourceMappingURL=apply.integration.test.js.map