declapract
Version:
A tool to declaratively define best practices, maintainable evolve them, and scalably enforce them.
40 lines • 2.55 kB
JavaScript
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 removeDirectoryAsync_1 = require("../../utils/fileio/removeDirectoryAsync");
const listFilesInDirectory_1 = require("../../utils/filepaths/listFilesInDirectory");
const logger_1 = require("../../utils/logger");
const dirPath_1 = require("../__test_assets__/dirPath");
const compile_1 = require("./compile");
const logSpy = jest.spyOn(console, 'log').mockImplementation(() => logger_1.log.debug); // swap to log debug so its not displaying during tests by default
describe('compile', () => {
it("should be able to correctly compile declarations, with '*' substitution", () => __awaiter(void 0, void 0, void 0, function* () {
const srcDir = `${dirPath_1.testAssetsDirectoryPath}/example-best-practices-compile-for-package-repo/src`;
const distDir = `${dirPath_1.testAssetsDirectoryPath}/example-best-practices-compile-for-package-repo/dist`;
// clean up the test env
yield (0, removeDirectoryAsync_1.removeDirectoryAsync)({
directory: distDir,
});
// compile
yield (0, compile_1.compile)({
sourceDirectory: srcDir,
distributionDirectory: distDir,
});
// and check that the files are correctly defined
const filesInDistDir = yield (0, listFilesInDirectory_1.listFilesInDirectory)({ directory: distDir });
expect(filesInDistDir).toContain('practices/directory-structure-src/best-practice/src/logic/<star><star>/<star>.ts.declapract.ts');
expect(filesInDistDir).not.toContain('practices/prettier/best-practice/package.json.declapract.test.ts');
expect(filesInDistDir.sort()).toMatchSnapshot();
// and check display output
expect(logSpy.mock.calls).toMatchSnapshot();
}));
});
//# sourceMappingURL=compile.integration.test.js.map
;