UNPKG

@patchworkdev/common

Version:

Patchwork Development Kit

38 lines (37 loc) 2.2 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 jsonProjectConfigGen_1 = require("./jsonProjectConfigGen"); describe("JSONProjectConfigGen", () => { it("should generate a project config matching project-config.json", async () => { const projectConfigPath = path_1.default.join(__dirname, '../codegen/test_data/project_configs/project-config.json'); const projectJson = fs_1.default.readFileSync(projectConfigPath, 'utf-8'); const expected = JSON.parse(projectJson); // Add default plugins if they are not provided in the file. if (!expected.plugins) { expected.plugins = [ { name: 'ponder' }, { name: 'react' } ]; } // Generate the JSON string const genString = new jsonProjectConfigGen_1.JSONProjectConfigGen().gen(project_config_1.default); // Compare the parsed objects expect(JSON.parse(genString)).toEqual(expected); }); it("should generate a project config with contract configs matching project-config-contract-config.json", async () => { // Read the content of the actual project-config-contract-config.json file const projectConfigPath = path_1.default.join(__dirname, '../codegen/test_data/project_configs/project-config-contract-config.json'); const projectJson = fs_1.default.readFileSync(projectConfigPath, 'utf-8'); // Generate the JSON string const genString = new jsonProjectConfigGen_1.JSONProjectConfigGen().gen(project_config_contract_config_1.default); // Parse both JSONs for comparison expect(JSON.parse(genString)).toEqual(JSON.parse(projectJson)); }); });