"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.folderMatches = exports.ensureReportJsonMatchesScenario = void 0;
const StorageUtilities_1 = require("../storage/StorageUtilities");
const chai_1 = require("chai");
const volatileLineTokens = ['"uuid":', '"pack_id":', '"version":', "generator_version", "generatorVersion", "version:"];
async function ensureReportJsonMatchesScenario(scenariosFolder, resultsFolder, obj, scenarioName) {
    if (!scenariosFolder || !resultsFolder) {
        chai_1.assert.fail("Not properly initialized");
    }
    const dataObjectStr = JSON.stringify(obj, null, 2);
    const resultsOutFolder = resultsFolder.ensureFolder(scenarioName);
    await resultsOutFolder.ensureExists();
    const outFile = resultsOutFolder.ensureFile("report.json");
    outFile.setContent(dataObjectStr);
    await outFile.saveContent();
    const scenarioFile = scenariosFolder.ensureFolder(scenarioName).ensureFile("report.json");
    const exists = await scenarioFile.exists();
    (0, chai_1.assert)(exists, "report.json file for scenario '" + scenarioName + "' does not exist.");
    const isEqual = await StorageUtilities_1.default.fileContentsEqual(scenarioFile, outFile, true, volatileLineTokens);
    (0, chai_1.assert)(isEqual, "report.json file '" + scenarioFile.fullPath + "' does not match for scenario '" + scenarioName + "'");
}
exports.ensureReportJsonMatchesScenario = ensureReportJsonMatchesScenario;
async function folderMatches(scenariosFolder, resultsFolder, scenarioName, excludeList) {
    if (!scenariosFolder || !resultsFolder) {
        chai_1.assert.fail("Not properly initialized");
    }
    const resultOutFolder = resultsFolder.ensureFolder(scenarioName);
    await resultOutFolder.ensureExists();
    const scenarioCompareFolder = scenariosFolder.ensureFolder(scenarioName);
    const isEqual = await StorageUtilities_1.default.folderContentsEqual(scenarioCompareFolder, resultOutFolder, excludeList, true, volatileLineTokens);
    (0, chai_1.assert)(isEqual.result, "Folder '" +
        scenarioCompareFolder.fullPath +
        "' does not match for scenario '" +
        scenarioName +
        "'. " +
        isEqual.reason);
}
exports.folderMatches = folderMatches;

//# sourceMappingURL=../maps/test/TestUtilities.js.map
