mapcomplete/test/Tag.spec.ts

29 lines
958 B
TypeScript
Raw Normal View History

2020-08-22 12:44:11 +02:00
import {equal} from "assert";
import {UIElement} from "../UI/UIElement";
2020-08-22 12:44:11 +02:00
UIElement.runningFromConsole = true;
import {CustomLayoutFromJSON} from "../Customizations/JSON/CustomLayoutFromJSON";
import {And} from "../Logic/TagsFilter";
import Translation from "../UI/i18n/Translation";
import T from "./TestHelper";
2020-08-22 12:44:11 +02:00
new T([
["Parse and match advanced tagging", () => {
const tags = CustomLayoutFromJSON.TagsFromJson("indoor=yes&access!=private");
console.log(tags);
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
}
],
["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
}]
]);