Various small fixes, add indication of which tags are added for power users

This commit is contained in:
Pieter Vander Vennet 2020-08-22 17:33:08 +02:00
parent a55767c1e9
commit 47d755e59f
9 changed files with 147 additions and 59 deletions

View file

@ -1,37 +1,28 @@
import {equal} from "assert";
import {UIElement} from "../UI/UIElement";
UIElement.runningFromConsole = true;
import {CustomLayoutFromJSON} from "../Customizations/JSON/CustomLayoutFromJSON";
import {And} from "../Logic/TagsFilter";
import Translation from "../UI/i18n/Translation";
import T from "./TestHelper";
let failures = 0;
function t(descripiton: string, f: () => void) {
try {
f();
} catch (e) {
failures++;
console.warn(e);
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);
}
}
],
["Tag replacement works in translation", () => {
const tr = new Translation({
"en": "Test {key} abc"
}).replace("{key}", "value");
equal(tr.txt, "Test value abc");
function done() {
if (failures == 0) {
console.log("All tests done!")
} else {
console.warn(failures, "tests failedd :(")
}
}
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);
});
done();
}]
]);