From 867eb2945fae60011194670d81f7ade532fe444f Mon Sep 17 00:00:00 2001 From: Kai Volland Date: Thu, 12 Sep 2024 16:53:59 +0200 Subject: [PATCH] test: update tests --- .gitignore | 4 +--- src/index.ts | 6 ++++++ test.js | 8 ++++---- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index a3e7371..d334dda 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,4 @@ dist binaries output-bulk -output.map -output.qml -output.sld +TEST_OUTPUT.* diff --git a/src/index.ts b/src/index.ts index 3a2f3c9..09650e6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -215,6 +215,12 @@ async function writeFile( console.log(writeUnsupportedProperties); } output = writeOutput; + if (targetParser instanceof OpenLayersParser) { + output = JSON.stringify(readOutput, undefined, 2); + if (!output) { + throw new Error('OpenLayers style could not be converted to JSON.'); + } + } } else { output = JSON.stringify(readOutput, undefined, 2); } diff --git a/test.js b/test.js index 0e0013a..0d3aef6 100644 --- a/test.js +++ b/test.js @@ -26,7 +26,7 @@ function runAllTests() { let success = true; // test sld to qgis - let outputFile = 'output.qml'; + let outputFile = 'TEST_OUTPUT.qml'; let args = ['start', '--', '-s', 'sld', '-t', 'qgis', '-o', outputFile, 'testdata/sld/point_simplepoint.sld']; runTest(args, outputFile); @@ -35,7 +35,7 @@ function runAllTests() { } // test qgis to sld - outputFile = 'output.sld'; + outputFile = 'TEST_OUTPUT.sld'; args = ['start', '--', '-s', 'qgis', '-t', 'sld', '-o', outputFile, 'testdata/point_simple.qml']; runTest(args, outputFile); @@ -43,8 +43,8 @@ function runAllTests() { success = false; } - // test mapfile to geostyler - outputFile = 'output.map'; + // test mapfile to openlayers + outputFile = 'TEST_OUTPUT.ol'; args = ['start', '--', '-s', 'mapfile', '-o', outputFile, 'testdata/point_simplepoint.map']; runTest(args, outputFile);