UNPKG

declapract

Version:

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

41 lines 2.55 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 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', () => __awaiter(void 0, void 0, void 0, function* () { 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 = yield (0, listFilesInDirectory_1.listFilesInDirectory)({ directory: targetDir, }); yield Promise.all(filesInDirectory .filter((path) => !expectedFilesInDirectory.includes(path)) .map((path) => (0, removeFileAsync_1.removeFileAsync)({ path: `${targetDir}/${path}` }))); const filesInDirectoryNow = yield (0, listFilesInDirectory_1.listFilesInDirectory)({ directory: targetDir, }); expect(filesInDirectoryNow).toEqual(expectedFilesInDirectory); // fail if the test environment is not correct // now apply yield (0, apply_1.apply)({ usePracticesConfigPath: `${targetDir}/declapract.use.yml`, }); expect(logSpy.mock.calls).toMatchSnapshot(); })); }); //# sourceMappingURL=apply.integration.test.js.map