diff --git a/tests/operations/index.mjs b/tests/operations/index.mjs index c12c2710..ed6a2616 100644 --- a/tests/operations/index.mjs +++ b/tests/operations/index.mjs @@ -159,6 +159,7 @@ import "./tests/SeqUtils.mjs"; import "./tests/SetDifference.mjs"; import "./tests/SetIntersection.mjs"; import "./tests/SetUnion.mjs"; +import "./tests/ShowOnMap.mjs"; import "./tests/Shuffle.mjs"; import "./tests/SIGABA.mjs"; import "./tests/SM2.mjs"; diff --git a/tests/operations/tests/ShowOnMap.mjs b/tests/operations/tests/ShowOnMap.mjs new file mode 100644 index 00000000..f9af64ef --- /dev/null +++ b/tests/operations/tests/ShowOnMap.mjs @@ -0,0 +1,39 @@ +/** + * Show on map tests + * + * @author Leon Zandman [leon@wirwar.com] + * + * @copyright Crown Copyright 2026 + * @license Apache-2.0 + */ +import TestRegister from "../../lib/TestRegister.mjs"; + +TestRegister.addTests([ + { + name: "Show on map: valid co-ordinate pair", + input: "51.5007, -0.1246", + // The presented output is the Leaflet map HTML; just check the co-ordinates made it through. + expectedMatch: /51\.5007,-0\.1246/, + recipeConfig: [ + { + op: "Show on map", + args: [13, "Auto", "Auto"] + }, + ], + }, + { + // Regression test: a comma-separated input with the delimiter set to "\n" used to be + // mis-detected as a single Degrees Decimal Minutes value (1° 24' = 1.4°), producing a single + // co-ordinate. That single value was then passed to Leaflet's setView([1.4], ...), throwing + // an uncaught "Cannot read properties of null (reading 'lat')" TypeError in the browser. + name: "Show on map: single value is rejected with a helpful error", + input: "1, 24", + expectedOutput: "Could not show co-ordinates '1.4' on the map. Expected a latitude and longitude pair - check that the input format and delimiter are correct.", + recipeConfig: [ + { + op: "Show on map", + args: [13, "Auto", "\\n"] + }, + ], + }, +]);