From c3859d56c6e9185d4de22d8b12450f17a917ea51 Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Wed, 6 Apr 2022 03:06:28 +0200 Subject: [PATCH] Rename tests to test; add a few tests --- {tests => test}/Chai.spec.ts | 0 {tests => test}/CodeQuality.spec.ts | 2 +- {tests => test}/Logic/Actors/Actors.spec.ts | 0 ...teMultiPolygonWithPointReuseAction.spec.ts | 0 .../TileFreshnessCalculator.spec.ts | 0 {tests => test}/Logic/GeoOperations.spec.ts | 0 .../ImageProviders/ImageProviders.spec.ts | 0 .../OSM/Actions/RelationSplitHandler.spec.ts | 0 .../OSM/Actions/ReplaceGeometryAction.spec.ts | 0 .../Logic/OSM/Actions/SplitAction.spec.ts | 0 {tests => test}/Logic/OSM/Changes.spec.ts | 0 .../Logic/OSM/ChangesetHandler.spec.ts | 0 {tests => test}/Logic/OSM/OsmObject.spec.ts | 0 .../Logic/Tags/LazyMatching.spec.ts | 0 .../Logic/Tags/OptimzeTags.spec.ts | 0 {tests => test}/Logic/Tags/TagUtils.spec.ts | 0 {tests => test}/Logic/Web/Wikidata.spec.ts | 0 .../Conversion/CreateNoteImportLayer.spec.ts | 0 .../Conversion/FixLegacyTheme.spec.ts | 0 .../Conversion/PrepareLayer.spec.ts | 3 -- .../Conversion/PrepareTheme.spec.ts | 33 ++++++++++++++++++- .../ThemeConfig/TagRenderingConfig.spec.ts | 0 {tests => test}/Models/Units.spec.ts | 0 .../UI/SpecialVisualisations.spec.ts | 0 .../UI/ValidatedTextFieldTranslations.ts | 0 {tests => test}/Utils.MinifyJson.spec.ts | 0 {tests => test}/scripts/GenerateCache.spec.ts | 0 {tests => test}/testhooks.ts | 0 28 files changed, 33 insertions(+), 5 deletions(-) rename {tests => test}/Chai.spec.ts (100%) rename {tests => test}/CodeQuality.spec.ts (94%) rename {tests => test}/Logic/Actors/Actors.spec.ts (100%) rename {tests => test}/Logic/Actors/CreateMultiPolygonWithPointReuseAction.spec.ts (100%) rename {tests => test}/Logic/FeatureSource/TileFreshnessCalculator.spec.ts (100%) rename {tests => test}/Logic/GeoOperations.spec.ts (100%) rename {tests => test}/Logic/ImageProviders/ImageProviders.spec.ts (100%) rename {tests => test}/Logic/OSM/Actions/RelationSplitHandler.spec.ts (100%) rename {tests => test}/Logic/OSM/Actions/ReplaceGeometryAction.spec.ts (100%) rename {tests => test}/Logic/OSM/Actions/SplitAction.spec.ts (100%) rename {tests => test}/Logic/OSM/Changes.spec.ts (100%) rename {tests => test}/Logic/OSM/ChangesetHandler.spec.ts (100%) rename {tests => test}/Logic/OSM/OsmObject.spec.ts (100%) rename {tests => test}/Logic/Tags/LazyMatching.spec.ts (100%) rename {tests => test}/Logic/Tags/OptimzeTags.spec.ts (100%) rename {tests => test}/Logic/Tags/TagUtils.spec.ts (100%) rename {tests => test}/Logic/Web/Wikidata.spec.ts (100%) rename {tests => test}/Models/ThemeConfig/Conversion/CreateNoteImportLayer.spec.ts (100%) rename {tests => test}/Models/ThemeConfig/Conversion/FixLegacyTheme.spec.ts (100%) rename {tests => test}/Models/ThemeConfig/Conversion/PrepareLayer.spec.ts (98%) rename {tests => test}/Models/ThemeConfig/Conversion/PrepareTheme.spec.ts (65%) rename {tests => test}/Models/ThemeConfig/TagRenderingConfig.spec.ts (100%) rename {tests => test}/Models/Units.spec.ts (100%) rename {tests => test}/UI/SpecialVisualisations.spec.ts (100%) rename {tests => test}/UI/ValidatedTextFieldTranslations.ts (100%) rename {tests => test}/Utils.MinifyJson.spec.ts (100%) rename {tests => test}/scripts/GenerateCache.spec.ts (100%) rename {tests => test}/testhooks.ts (100%) diff --git a/tests/Chai.spec.ts b/test/Chai.spec.ts similarity index 100% rename from tests/Chai.spec.ts rename to test/Chai.spec.ts diff --git a/tests/CodeQuality.spec.ts b/test/CodeQuality.spec.ts similarity index 94% rename from tests/CodeQuality.spec.ts rename to test/CodeQuality.spec.ts index a3db97b4e..33fffcb54 100644 --- a/tests/CodeQuality.spec.ts +++ b/test/CodeQuality.spec.ts @@ -24,7 +24,7 @@ function detectInCode(forbidden: string, reason: string) { throw stderr } - const found = stdout.split("\n").filter(s => s !== "").filter(s => !s.startsWith("./tests/") && !s.startsWith("./testLegacy/")); + const found = stdout.split("\n").filter(s => s !== "").filter(s => !s.startsWith("./test/")); if (found.length > 0) { throw `Found a '${forbidden}' at \n ${found.join("\n ")}.\n ${reason}` } diff --git a/tests/Logic/Actors/Actors.spec.ts b/test/Logic/Actors/Actors.spec.ts similarity index 100% rename from tests/Logic/Actors/Actors.spec.ts rename to test/Logic/Actors/Actors.spec.ts diff --git a/tests/Logic/Actors/CreateMultiPolygonWithPointReuseAction.spec.ts b/test/Logic/Actors/CreateMultiPolygonWithPointReuseAction.spec.ts similarity index 100% rename from tests/Logic/Actors/CreateMultiPolygonWithPointReuseAction.spec.ts rename to test/Logic/Actors/CreateMultiPolygonWithPointReuseAction.spec.ts diff --git a/tests/Logic/FeatureSource/TileFreshnessCalculator.spec.ts b/test/Logic/FeatureSource/TileFreshnessCalculator.spec.ts similarity index 100% rename from tests/Logic/FeatureSource/TileFreshnessCalculator.spec.ts rename to test/Logic/FeatureSource/TileFreshnessCalculator.spec.ts diff --git a/tests/Logic/GeoOperations.spec.ts b/test/Logic/GeoOperations.spec.ts similarity index 100% rename from tests/Logic/GeoOperations.spec.ts rename to test/Logic/GeoOperations.spec.ts diff --git a/tests/Logic/ImageProviders/ImageProviders.spec.ts b/test/Logic/ImageProviders/ImageProviders.spec.ts similarity index 100% rename from tests/Logic/ImageProviders/ImageProviders.spec.ts rename to test/Logic/ImageProviders/ImageProviders.spec.ts diff --git a/tests/Logic/OSM/Actions/RelationSplitHandler.spec.ts b/test/Logic/OSM/Actions/RelationSplitHandler.spec.ts similarity index 100% rename from tests/Logic/OSM/Actions/RelationSplitHandler.spec.ts rename to test/Logic/OSM/Actions/RelationSplitHandler.spec.ts diff --git a/tests/Logic/OSM/Actions/ReplaceGeometryAction.spec.ts b/test/Logic/OSM/Actions/ReplaceGeometryAction.spec.ts similarity index 100% rename from tests/Logic/OSM/Actions/ReplaceGeometryAction.spec.ts rename to test/Logic/OSM/Actions/ReplaceGeometryAction.spec.ts diff --git a/tests/Logic/OSM/Actions/SplitAction.spec.ts b/test/Logic/OSM/Actions/SplitAction.spec.ts similarity index 100% rename from tests/Logic/OSM/Actions/SplitAction.spec.ts rename to test/Logic/OSM/Actions/SplitAction.spec.ts diff --git a/tests/Logic/OSM/Changes.spec.ts b/test/Logic/OSM/Changes.spec.ts similarity index 100% rename from tests/Logic/OSM/Changes.spec.ts rename to test/Logic/OSM/Changes.spec.ts diff --git a/tests/Logic/OSM/ChangesetHandler.spec.ts b/test/Logic/OSM/ChangesetHandler.spec.ts similarity index 100% rename from tests/Logic/OSM/ChangesetHandler.spec.ts rename to test/Logic/OSM/ChangesetHandler.spec.ts diff --git a/tests/Logic/OSM/OsmObject.spec.ts b/test/Logic/OSM/OsmObject.spec.ts similarity index 100% rename from tests/Logic/OSM/OsmObject.spec.ts rename to test/Logic/OSM/OsmObject.spec.ts diff --git a/tests/Logic/Tags/LazyMatching.spec.ts b/test/Logic/Tags/LazyMatching.spec.ts similarity index 100% rename from tests/Logic/Tags/LazyMatching.spec.ts rename to test/Logic/Tags/LazyMatching.spec.ts diff --git a/tests/Logic/Tags/OptimzeTags.spec.ts b/test/Logic/Tags/OptimzeTags.spec.ts similarity index 100% rename from tests/Logic/Tags/OptimzeTags.spec.ts rename to test/Logic/Tags/OptimzeTags.spec.ts diff --git a/tests/Logic/Tags/TagUtils.spec.ts b/test/Logic/Tags/TagUtils.spec.ts similarity index 100% rename from tests/Logic/Tags/TagUtils.spec.ts rename to test/Logic/Tags/TagUtils.spec.ts diff --git a/tests/Logic/Web/Wikidata.spec.ts b/test/Logic/Web/Wikidata.spec.ts similarity index 100% rename from tests/Logic/Web/Wikidata.spec.ts rename to test/Logic/Web/Wikidata.spec.ts diff --git a/tests/Models/ThemeConfig/Conversion/CreateNoteImportLayer.spec.ts b/test/Models/ThemeConfig/Conversion/CreateNoteImportLayer.spec.ts similarity index 100% rename from tests/Models/ThemeConfig/Conversion/CreateNoteImportLayer.spec.ts rename to test/Models/ThemeConfig/Conversion/CreateNoteImportLayer.spec.ts diff --git a/tests/Models/ThemeConfig/Conversion/FixLegacyTheme.spec.ts b/test/Models/ThemeConfig/Conversion/FixLegacyTheme.spec.ts similarity index 100% rename from tests/Models/ThemeConfig/Conversion/FixLegacyTheme.spec.ts rename to test/Models/ThemeConfig/Conversion/FixLegacyTheme.spec.ts diff --git a/tests/Models/ThemeConfig/Conversion/PrepareLayer.spec.ts b/test/Models/ThemeConfig/Conversion/PrepareLayer.spec.ts similarity index 98% rename from tests/Models/ThemeConfig/Conversion/PrepareLayer.spec.ts rename to test/Models/ThemeConfig/Conversion/PrepareLayer.spec.ts index 042c9166f..d395401be 100644 --- a/tests/Models/ThemeConfig/Conversion/PrepareLayer.spec.ts +++ b/test/Models/ThemeConfig/Conversion/PrepareLayer.spec.ts @@ -12,9 +12,6 @@ import RewritableConfigJson from "../../../../Models/ThemeConfig/Json/Rewritable describe("ExpandRewrite", () => { - it("should do simple substitution", () => { - - }) it("should not allow overlapping keys", () => { const spec = >{ rewrite: { diff --git a/tests/Models/ThemeConfig/Conversion/PrepareTheme.spec.ts b/test/Models/ThemeConfig/Conversion/PrepareTheme.spec.ts similarity index 65% rename from tests/Models/ThemeConfig/Conversion/PrepareTheme.spec.ts rename to test/Models/ThemeConfig/Conversion/PrepareTheme.spec.ts index 6b6043491..b18863ce7 100644 --- a/tests/Models/ThemeConfig/Conversion/PrepareTheme.spec.ts +++ b/test/Models/ThemeConfig/Conversion/PrepareTheme.spec.ts @@ -9,6 +9,7 @@ import * as bookcaseLayer from "../../../../assets/generated/layers/public_bookc import LayerConfig from "../../../../Models/ThemeConfig/LayerConfig"; import {ExtractImages} from "../../../../Models/ThemeConfig/Conversion/FixImages"; import * as cyclofix from "../../../../assets/generated/themes/cyclofix.json" +import {Tag} from "../../../../Logic/Tags/Tag"; const themeConfigJson: LayoutConfigJson = { @@ -37,8 +38,24 @@ const themeConfigJson: LayoutConfigJson = { } describe("PrepareTheme", () => { + + it("should substitute layers", () => { + + const sharedLayers = new Map() + sharedLayers.set("public_bookcase", bookcaseLayer["default"]) + const theme ={...themeConfigJson, layers: ["public_bookcase"]} + const prepareStep = new PrepareTheme({ + tagRenderings: new Map(), + sharedLayers: sharedLayers + }) + 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")) + + }) - it("should apply overrideAll", () => { + it("should apply override", () => { const sharedLayers = new Map() sharedLayers.set("public_bookcase", bookcaseLayer["default"]) @@ -51,6 +68,20 @@ describe("PrepareTheme", () => { expect(layerUnderTest.source.geojsonSource).eq("xyz") }) + + + it("should apply override", () => { + + const sharedLayers = new Map() + sharedLayers.set("public_bookcase", bookcaseLayer["default"]) + let themeConfigJsonPrepared = new PrepareTheme({ + tagRenderings: new Map(), + sharedLayers: sharedLayers + }).convert({...themeConfigJson, overrideAll: {source: {geoJson: "https://example.com/data.geojson"}}}, "test").result + const themeConfig = new LayoutConfig(themeConfigJsonPrepared); + const layerUnderTest = themeConfig.layers.find(l => l.id === "public_bookcase") + expect(layerUnderTest.source.geojsonSource).eq("https://example.com/data.geojson") + }) }) diff --git a/tests/Models/ThemeConfig/TagRenderingConfig.spec.ts b/test/Models/ThemeConfig/TagRenderingConfig.spec.ts similarity index 100% rename from tests/Models/ThemeConfig/TagRenderingConfig.spec.ts rename to test/Models/ThemeConfig/TagRenderingConfig.spec.ts diff --git a/tests/Models/Units.spec.ts b/test/Models/Units.spec.ts similarity index 100% rename from tests/Models/Units.spec.ts rename to test/Models/Units.spec.ts diff --git a/tests/UI/SpecialVisualisations.spec.ts b/test/UI/SpecialVisualisations.spec.ts similarity index 100% rename from tests/UI/SpecialVisualisations.spec.ts rename to test/UI/SpecialVisualisations.spec.ts diff --git a/tests/UI/ValidatedTextFieldTranslations.ts b/test/UI/ValidatedTextFieldTranslations.ts similarity index 100% rename from tests/UI/ValidatedTextFieldTranslations.ts rename to test/UI/ValidatedTextFieldTranslations.ts diff --git a/tests/Utils.MinifyJson.spec.ts b/test/Utils.MinifyJson.spec.ts similarity index 100% rename from tests/Utils.MinifyJson.spec.ts rename to test/Utils.MinifyJson.spec.ts diff --git a/tests/scripts/GenerateCache.spec.ts b/test/scripts/GenerateCache.spec.ts similarity index 100% rename from tests/scripts/GenerateCache.spec.ts rename to test/scripts/GenerateCache.spec.ts diff --git a/tests/testhooks.ts b/test/testhooks.ts similarity index 100% rename from tests/testhooks.ts rename to test/testhooks.ts