Files
osmWorkflow/scripts/test-road-workbench.js

54 lines
2.8 KiB
JavaScript

#!/usr/bin/env node
"use strict";
const assert = require("assert");
const fs = require("fs");
const path = require("path");
const html = fs.readFileSync(path.join(__dirname, "workbench", "index.html"), "utf8");
assert.match(html, /id="width" type="number" min="1" step="0\.01"/);
assert.match(html, /data-layer="sidewalks" type="checkbox" checked> 路缘与步行带/);
assert.match(html, /id="scene-preview" type="checkbox"/);
assert.match(html, /id="selected-junction" hidden/);
const app = fs.readFileSync(path.join(__dirname, "workbench", "app.js"), "utf8");
assert.match(app, /async function saveStagedChanges\(\)/);
assert.match(app, /if \(!await saveStagedChanges\(\)\) return;/);
assert.match(app, /function stageRoadOverride\(road, changes\)/);
assert.match(app, /road\.segmentId === selectedRoad\.segmentId/);
assert.match(app, /sidewalkLeft: rightInput\.checked, sidewalkRight: leftInput\.checked/);
assert.match(app, /function nativeSurfaceStyle\(feature\)/);
assert.match(app, /reference: new VectorLayer\(\{ source: source\(\), visible: false/);
assert.match(app, /scene mode must render fills only/);
assert.match(app, /scenePreviewToggle\.onchange/);
assert.match(app, /layers\.sidewalks\.setVisible\(document\.querySelector\('\[data-layer="sidewalks"\]'\)\.checked\)/);
assert.match(app, /function selectJunction\(feature\)/);
assert.match(app, /candidate\.get\("native_id"\) === item\.subjectId/);
assert.match(app, /外缘扩张倍率/);
assert.match(app, /最大外缘扩张/);
assert.match(app, /道路方向箭头/);
assert.match(app, /native-road-direction-arrow\/v1/);
assert.match(app, /data-layer="centerLines" type="checkbox" checked> 道路中心线/);
assert.match(app, /centerLines: new VectorLayer/);
assert.match(app, /state\.layers\.centerLines/);
assert.match(app, /native-road-center-line\/v1/);
assert.match(app, /lane-separator-style/);
assert.match(app, /车道分隔线/);
assert.match(app, /center-line-style/);
assert.match(app, /centerLineStyleInput\.onchange = stageSelectedCenterLineStyle/);
assert.match(html, /道路中心线样式/);
assert.match(html, /white-solid/);
assert.match(app, /double-yellow-solid/);
assert.match(app, /const double = parts\[0\] === "double"/);
assert.match(app, /function selectEdgeLine\(feature\)/);
assert.match(app, /edge-line-style/);
assert.match(app, /道路外缘线样式/);
assert.match(html, /id="marking-style-heading"/);
assert.match(app, /data-layer="controls" type="checkbox" checked> 斑马线与停止线/);
assert.match(app, /controls: new VectorLayer/);
assert.match(app, /state\.layers\.crosswalks/);
assert.match(app, /state\.layers\.vehicleStopLines/);
assert.match(app, /native-road-crosswalk\/v1/);
assert.match(app, /native-road-stop-line\/v1/);
assert.match(app, /term\.textContent = label; detail\.textContent = value; summary\.append\(term, detail\)/);
console.log("road workbench tests passed");