2020-08-22 12:44:11 +02:00
|
|
|
import {equal} from "assert";
|
|
|
|
import {UIElement} from "../UI/UIElement";
|
2020-08-22 17:33:08 +02:00
|
|
|
|
2020-08-22 12:44:11 +02:00
|
|
|
UIElement.runningFromConsole = true;
|
|
|
|
import {CustomLayoutFromJSON} from "../Customizations/JSON/CustomLayoutFromJSON";
|
|
|
|
import {And} from "../Logic/TagsFilter";
|
2020-08-22 17:33:08 +02:00
|
|
|
import Translation from "../UI/i18n/Translation";
|
|
|
|
import T from "./TestHelper";
|
2020-08-23 02:26:17 +02:00
|
|
|
import {Artwork} from "../Customizations/Layers/Artwork";
|
2020-08-22 12:44:11 +02:00
|
|
|
|
|
|
|
|
2020-08-22 17:33:08 +02:00
|
|
|
new T([
|
|
|
|
["Parse and match advanced tagging", () => {
|
|
|
|
const tags = CustomLayoutFromJSON.TagsFromJson("indoor=yes&access!=private");
|
|
|
|
const m0 = new And(tags).matches([{k: "indoor", v: "yes"}, {k: "access", v: "yes"}]);
|
|
|
|
equal(m0, true);
|
|
|
|
const m1 = new And(tags).matches([{k: "indoor", v: "yes"}, {k: "access", v: "private"}]);
|
|
|
|
equal(m1, false);
|
2020-08-22 12:44:11 +02:00
|
|
|
}
|
2020-08-22 17:33:08 +02:00
|
|
|
],
|
2020-08-23 01:49:19 +02:00
|
|
|
["Parse tagging with regex", () => {
|
|
|
|
const tags = CustomLayoutFromJSON.TagsFromJson("highway~=residential|tertiary");
|
|
|
|
equal(""+tags[0].value, ""+/residential|tertiary/);
|
|
|
|
console.log(tags[0].asOverpass());
|
2020-08-23 02:26:17 +02:00
|
|
|
|
2020-08-23 01:49:19 +02:00
|
|
|
}
|
|
|
|
],
|
2020-08-22 17:33:08 +02:00
|
|
|
["Tag replacement works in translation", () => {
|
|
|
|
const tr = new Translation({
|
|
|
|
"en": "Test {key} abc"
|
|
|
|
}).replace("{key}", "value");
|
|
|
|
equal(tr.txt, "Test value abc");
|
2020-08-22 12:44:11 +02:00
|
|
|
|
2020-08-23 02:26:17 +02:00
|
|
|
}],
|
|
|
|
["JSONify artwork layer", () => {
|
|
|
|
const a = new Artwork();
|
|
|
|
console.log(a.ToJson())
|
2020-08-22 17:33:08 +02:00
|
|
|
}]
|
|
|
|
]);
|