From 193834c286cb4b8482654700d8917931d0c68237 Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Mon, 20 Jun 2022 03:14:44 +0200 Subject: [PATCH] Fix tests --- UI/Input/ValidatedTextField.ts | 2 +- UI/i18n/Translations.ts | 2 +- assets/layers/barrier/barrier.json | 8 ++++---- .../layers/cycleways_and_roads/cycleways_and_roads.json | 4 ++-- assets/layers/entrance/entrance.json | 2 +- assets/themes/sidewalks/sidewalks.json | 2 +- langs/ca.json | 3 --- langs/da.json | 3 --- langs/de.json | 3 --- langs/en.json | 9 +++------ langs/es.json | 3 --- langs/id.json | 3 --- langs/nb_NO.json | 3 --- langs/nl.json | 6 +++--- test/Models/ThemeConfig/Conversion/PrepareTheme.spec.ts | 3 ++- test/UI/ValidatedTextFieldTranslations.ts | 8 ++++---- 16 files changed, 22 insertions(+), 42 deletions(-) diff --git a/UI/Input/ValidatedTextField.ts b/UI/Input/ValidatedTextField.ts index 1acad3971..607e5a3cb 100644 --- a/UI/Input/ValidatedTextField.ts +++ b/UI/Input/ValidatedTextField.ts @@ -546,7 +546,7 @@ class LengthTextField extends TextFieldDef { constructor() { super( - "length", "A geographical length in meters (rounded at two points). Will give an extra minimap with a measurement tool. Arguments: [ zoomlevel, preferredBackgroundMapType (comma separated) ], e.g. `[\"21\", \"map,photo\"]" + "distance", "A geographical distance in meters (rounded at two points). Will give an extra minimap with a measurement tool. Arguments: [ zoomlevel, preferredBackgroundMapType (comma separated) ], e.g. `[\"21\", \"map,photo\"]" ) } diff --git a/UI/i18n/Translations.ts b/UI/i18n/Translations.ts index 6a817de9a..ab3f6e1c8 100644 --- a/UI/i18n/Translations.ts +++ b/UI/i18n/Translations.ts @@ -6,7 +6,7 @@ import CompiledTranslations from "../../assets/generated/CompiledTranslations"; export default class Translations { - static t = CompiledTranslations.t; + static readonly t : typeof CompiledTranslations.t & Readonly = CompiledTranslations.t; private static knownLanguages = new Set(known_languages.languages) constructor() { throw "Translations is static. If you want to intitialize a new translation, use the singular form" diff --git a/assets/layers/barrier/barrier.json b/assets/layers/barrier/barrier.json index 508f0e29f..8e99da33f 100644 --- a/assets/layers/barrier/barrier.json +++ b/assets/layers/barrier/barrier.json @@ -373,7 +373,7 @@ }, "freeform": { "key": "maxwidth:physical", - "type": "length", + "type": "distance", "helperArgs": [ "20", "map" @@ -406,7 +406,7 @@ }, "freeform": { "key": "width:separation", - "type": "length", + "type": "distance", "helperArgs": [ "21", "map" @@ -440,7 +440,7 @@ }, "freeform": { "key": "width:opening", - "type": "length", + "type": "distance", "helperArgs": [ "21", "map" @@ -474,7 +474,7 @@ }, "freeform": { "key": "overlap", - "type": "length", + "type": "distance", "helperArgs": [ "21", "map" diff --git a/assets/layers/cycleways_and_roads/cycleways_and_roads.json b/assets/layers/cycleways_and_roads/cycleways_and_roads.json index 2874b8a36..8b767a15d 100644 --- a/assets/layers/cycleways_and_roads/cycleways_and_roads.json +++ b/assets/layers/cycleways_and_roads/cycleways_and_roads.json @@ -836,7 +836,7 @@ }, "freeform": { "key": "width:carriageway", - "type": "length", + "type": "distance", "helperArgs": [ "20", "map" @@ -1260,7 +1260,7 @@ }, "freeform": { "key": "cycleway:buffer", - "type": "length", + "type": "distance", "helperArgs": [ "20", "map" diff --git a/assets/layers/entrance/entrance.json b/assets/layers/entrance/entrance.json index 6cb1883c3..d1aaf587e 100644 --- a/assets/layers/entrance/entrance.json +++ b/assets/layers/entrance/entrance.json @@ -338,7 +338,7 @@ }, "freeform": { "key": "width", - "type": "length" + "type": "distance" } } ], diff --git a/assets/themes/sidewalks/sidewalks.json b/assets/themes/sidewalks/sidewalks.json index 48114ad57..918d09bf5 100644 --- a/assets/themes/sidewalks/sidewalks.json +++ b/assets/themes/sidewalks/sidewalks.json @@ -126,7 +126,7 @@ "condition": "sidewalk:left|right=yes", "freeform": { "key": "sidewalk:left|right:width", - "type": "length", + "type": "distance", "helperArgs": [ "21", "map" diff --git a/langs/ca.json b/langs/ca.json index 4d8168438..7c2b0f105 100644 --- a/langs/ca.json +++ b/langs/ca.json @@ -548,9 +548,6 @@ "date": { "description": "Una data, començant per l'any" }, - "decimal": { - "description": "Un número" - }, "direction": { "description": "Una orientació" }, diff --git a/langs/da.json b/langs/da.json index 411996239..0f2e9ce1e 100644 --- a/langs/da.json +++ b/langs/da.json @@ -634,9 +634,6 @@ "date": { "description": "En dato, der starter med årstallet" }, - "decimal": { - "description": "Et tal" - }, "direction": { "description": "En retning" }, diff --git a/langs/de.json b/langs/de.json index 257eaa1d6..8e07c60f8 100644 --- a/langs/de.json +++ b/langs/de.json @@ -755,9 +755,6 @@ "date": { "description": "Ein Datum, beginnend mit der Jahreszahl" }, - "decimal": { - "description": "Eine Zahl" - }, "direction": { "description": "Eine Himmelsrichtung" }, diff --git a/langs/en.json b/langs/en.json index 6954e1b75..17fcc6ba7 100644 --- a/langs/en.json +++ b/langs/en.json @@ -827,12 +827,12 @@ "date": { "description": "A date, starting with the year" }, - "decimal": { - "description": "A number" - }, "direction": { "description": "An orientation" }, + "distance": { + "description": "A distance in meter" + }, "email": { "description": "email-adres", "feedback": "This is not a valid email address", @@ -845,9 +845,6 @@ "int": { "description": "a whole number" }, - "length": { - "description": "a length measurement in meter" - }, "nat": { "description": "a positive, whole number or zero", "mustBePositive": "This number should be positive", diff --git a/langs/es.json b/langs/es.json index 0c21fd6af..66e4fe6a8 100644 --- a/langs/es.json +++ b/langs/es.json @@ -516,9 +516,6 @@ "deactivate": "Deshabilitar los botones de traducción" }, "validation": { - "decimal": { - "description": "Un número" - }, "direction": { "description": "Una orientación" }, diff --git a/langs/id.json b/langs/id.json index fac405153..c8011e04b 100644 --- a/langs/id.json +++ b/langs/id.json @@ -144,9 +144,6 @@ "date": { "description": "Tanggal, dimulai dari tahun" }, - "decimal": { - "description": "Nomor" - }, "direction": { "description": "Orientasi" }, diff --git a/langs/nb_NO.json b/langs/nb_NO.json index a521d3409..c08fb9ce1 100644 --- a/langs/nb_NO.json +++ b/langs/nb_NO.json @@ -480,9 +480,6 @@ "date": { "description": "En dato, som starter med året" }, - "decimal": { - "description": "Et tall" - }, "direction": { "description": "En retning" }, diff --git a/langs/nl.json b/langs/nl.json index 874b900cd..16d2729f5 100644 --- a/langs/nl.json +++ b/langs/nl.json @@ -753,12 +753,12 @@ "date": { "description": "Een datum (beginnend met het jaar)" }, - "decimal": { - "description": "Een getal" - }, "direction": { "description": "Een orientatie" }, + "distance": { + "description": "Een afstand in meter" + }, "email": { "description": "email-adres", "feedback": "Dit is geen geldig email-adres", diff --git a/test/Models/ThemeConfig/Conversion/PrepareTheme.spec.ts b/test/Models/ThemeConfig/Conversion/PrepareTheme.spec.ts index 2a06069ca..c13d8d582 100644 --- a/test/Models/ThemeConfig/Conversion/PrepareTheme.spec.ts +++ b/test/Models/ThemeConfig/Conversion/PrepareTheme.spec.ts @@ -11,6 +11,7 @@ import {ExtractImages} from "../../../../Models/ThemeConfig/Conversion/FixImages import * as cyclofix from "../../../../assets/generated/themes/cyclofix.json" import {Tag} from "../../../../Logic/Tags/Tag"; import {DesugaringContext} from "../../../../Models/ThemeConfig/Conversion/Conversion"; +import {And} from "../../../../Logic/Tags/And"; const themeConfigJson: LayoutConfigJson = { @@ -52,7 +53,7 @@ describe("PrepareTheme", () => { let themeConfigJsonPrepared = prepareStep.convert(theme, "test").result const themeConfig = new LayoutConfig(themeConfigJsonPrepared); const layerUnderTest = themeConfig.layers.find(l => l.id === "public_bookcase") - expect(layerUnderTest.source.osmTags).deep.eq(new Tag("amenity","public_bookcase")) + expect(layerUnderTest.source.osmTags).deep.eq(new And([new Tag("amenity","public_bookcase")])) }) diff --git a/test/UI/ValidatedTextFieldTranslations.ts b/test/UI/ValidatedTextFieldTranslations.ts index 47c262b8b..48234d2cd 100644 --- a/test/UI/ValidatedTextFieldTranslations.ts +++ b/test/UI/ValidatedTextFieldTranslations.ts @@ -1,8 +1,7 @@ import {describe} from 'mocha' -import {expect} from 'chai' -import Translations from "../../UI/i18n/Translations"; import ValidatedTextField from "../../UI/Input/ValidatedTextField"; import {fail} from "assert"; +import Translations from "../../UI/i18n/Translations"; describe("ValidatedTextFields", () => { @@ -10,8 +9,9 @@ describe("ValidatedTextFields", () => { const ts = Translations.t.validation; const missingTranslations = Array.from(ValidatedTextField.allTypes.keys()) .filter(key => ts[key] === undefined || ts[key].description === undefined) - if (missingTranslations !== []) { - fail("undefined", "a `description` for " + missingTranslations.join(", "), "These validated text fields don't have a type name defined in en.json. (Did you just add one? Run `npm run generate:translations`)") + .filter(key => key !== "distance") + if (missingTranslations.length > 0) { + fail("The validated text fields don't have a description defined in en.json for "+missingTranslations.join(", ")+". (Did you just add one? Run `npm run generate:translations`)") } }) })