UNPKG

@patchworkdev/common

Version:

Patchwork Development Kit

39 lines (38 loc) 2.8 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const fs_1 = __importDefault(require("fs")); const path_1 = __importDefault(require("path")); const project_config_1 = __importDefault(require("../codegen/test_data/project_configs/project-config")); const project_config_contract_config_1 = __importDefault(require("../codegen/test_data/project_configs/project-config-contract-config")); const tsProjectConfigGen_1 = require("./tsProjectConfigGen"); describe("TypeScriptProjectConfigGen", () => { it("should generate a project config matching project-config.ts plus default plugins", async () => { // Generate the TypeScript code const genString = new tsProjectConfigGen_1.TSProjectConfigGen().gen(project_config_1.default); // Read the content of the actual project-config.ts file const projectConfigPath = path_1.default.join(__dirname, '../codegen/test_data/project_configs/project-config.ts'); const actualFileContent = fs_1.default.readFileSync(projectConfigPath, 'utf-8'); // Create expected content by adding plugins section const expectedContent = actualFileContent .replace('contracts: {\n "Contract1": "config1.json",\n "Contract2": "config2.json"\n }', 'contracts: {\n "Contract1": "config1.json",\n "Contract2": "config2.json"\n },\n plugins: [\n { name: \'ponder\' },\n { name: \'react\' }\n ]'); // Normalize both strings by removing all whitespace for comparison const normalizedGenString = genString.replace(/\s/g, ''); const normalizedExpectedContent = expectedContent.replace(/\s/g, ''); expect(normalizedGenString).toEqual(normalizedExpectedContent); }); it("should generate a project config matching project-config-contract-config.ts", async () => { // Generate the TypeScript code const genString = new tsProjectConfigGen_1.TSProjectConfigGen().gen(project_config_contract_config_1.default); // Read the content of the actual project-config-contract-config.ts file const projectConfigPath = path_1.default.join(__dirname, '../codegen/test_data/project_configs/project-config-contract-config.ts'); const actualFileContent = fs_1.default.readFileSync(projectConfigPath, 'utf-8'); // Normalize both strings by removing all whitespace const normalizedGenString = genString.replace(/\s/g, ''); const normalizedFileContent = actualFileContent.replace(/\s/g, ''); // Compare the normalized strings expect(normalizedGenString).toEqual(normalizedFileContent); }); });