diff --git a/test/Actors.spec.ts b/test/Actors.spec.ts index e0540a04a..bf30297d4 100644 --- a/test/Actors.spec.ts +++ b/test/Actors.spec.ts @@ -49,7 +49,7 @@ export default class ActorsSpec extends T { } ) - super("Actors", [ + super([ [ "download latest version", () => { diff --git a/test/CreateNoteImportLayer.spec.ts b/test/CreateNoteImportLayer.spec.ts new file mode 100644 index 000000000..9624637b5 --- /dev/null +++ b/test/CreateNoteImportLayer.spec.ts @@ -0,0 +1,31 @@ +import T from "./TestHelper"; +import CreateNoteImportLayer from "../Models/ThemeConfig/Conversion/CreateNoteImportLayer"; +import * as bookcases from "../assets/layers/public_bookcase/public_bookcase.json" +import {DesugaringContext, PrepareLayer} from "../Models/ThemeConfig/Conversion/LegacyJsonConvert"; +import {LayerConfigJson} from "../Models/ThemeConfig/Json/LayerConfigJson"; +import {TagRenderingConfigJson} from "../Models/ThemeConfig/Json/TagRenderingConfigJson"; +import LayerConfig from "../Models/ThemeConfig/LayerConfig"; +import * as fs from "fs"; + +export default class CreateNoteImportLayerSpec extends T { + + constructor() { + super([ + ["Bookcase", () => { + const desugaringState: DesugaringContext = { + sharedLayers: new Map(), + tagRenderings: new Map() + + } + const layerPrepare = new PrepareLayer() + const layer = new LayerConfig(layerPrepare.convertStrict(desugaringState, bookcases, "ImportLayerGeneratorTest:Parse bookcases"), "ImportLayerGeneratorTest: init bookcases-layer") + const generator = new CreateNoteImportLayer() + const generatedLayer = generator.convertStrict(desugaringState, layer, "ImportLayerGeneratorTest: convert") + fs.writeFileSync("bookcases-import-layer.generated.json", JSON.stringify(generatedLayer, null, " "), "utf8") +console.log(JSON.stringify(generatedLayer, null, " ")) + }] + ]); + } + + +} \ No newline at end of file diff --git a/test/GeoOperations.spec.ts b/test/GeoOperations.spec.ts index a8df76883..b7e3c2f6f 100644 --- a/test/GeoOperations.spec.ts +++ b/test/GeoOperations.spec.ts @@ -89,8 +89,7 @@ export default class GeoOperationsSpec extends T { private static outsidePolygon = [4.02099609375, 47.81315451752768] constructor() { - super( - "GeoOperationsSpec", [ + super([ ["Point out of polygon", () => { GeoOperationsSpec.isFalse(GeoOperations.inside([ 3.779296875, diff --git a/test/ImageAttribution.spec.ts b/test/ImageAttribution.spec.ts index eb31fb28b..e89812017 100644 --- a/test/ImageAttribution.spec.ts +++ b/test/ImageAttribution.spec.ts @@ -6,8 +6,7 @@ import LayerConfig from "../Models/ThemeConfig/LayerConfig"; export default class ImageAttributionSpec extends T { constructor() { - super( - "imageattribution", [ + super([ [ "Should find all the images", () => { diff --git a/test/ImageProvider.spec.ts b/test/ImageProvider.spec.ts index e00311986..1020a4732 100644 --- a/test/ImageProvider.spec.ts +++ b/test/ImageProvider.spec.ts @@ -6,7 +6,7 @@ import {Utils} from "../Utils"; export default class ImageProviderSpec extends T { constructor() { - super("ImageProvider", [ + super([ ["Search images", () => { let i = 0 diff --git a/test/LegacyThemeLoader.spec.ts b/test/LegacyThemeLoader.spec.ts index c57ceb7d4..31b746939 100644 --- a/test/LegacyThemeLoader.spec.ts +++ b/test/LegacyThemeLoader.spec.ts @@ -141,9 +141,7 @@ export default class LegacyThemeLoaderSpec extends T { } constructor() { - super("LegacyThemeLoader", - - [ + super([ ["Walking_node_theme", () => { const config = LegacyThemeLoaderSpec.walking_node_theme diff --git a/test/OsmConnection.spec.ts b/test/OsmConnection.spec.ts index 3bd69ac9b..d21d44e64 100644 --- a/test/OsmConnection.spec.ts +++ b/test/OsmConnection.spec.ts @@ -14,7 +14,7 @@ export default class OsmConnectionSpec extends T { private static _osm_token = "LJFmv2nUicSNmBNsFeyCHx5KKx6Aiesx8pXPbX4n" constructor() { - super("osmconnection", [ + super([ ["login on dev", () => { const osmConn = new OsmConnection({ diff --git a/test/OsmObject.spec.ts b/test/OsmObject.spec.ts index 9cf60e354..03d35e473 100644 --- a/test/OsmObject.spec.ts +++ b/test/OsmObject.spec.ts @@ -3,7 +3,7 @@ import {OsmObject} from "../Logic/Osm/OsmObject"; export default class OsmObjectSpec extends T { constructor() { - super("osmobject", [ + super( [ [ "Download referencing ways", () => { diff --git a/test/RelationSplitHandler.spec.ts b/test/RelationSplitHandler.spec.ts index 76c605a78..0920a915b 100644 --- a/test/RelationSplitHandler.spec.ts +++ b/test/RelationSplitHandler.spec.ts @@ -548,7 +548,7 @@ export default class RelationSplitHandlerSpec extends T { ) - super("relationsplithandler", [ + super( [ ["split 295132739", async () => { // Lets mimick a split action of https://www.openstreetmap.org/way/295132739 diff --git a/test/ReplaceGeometry.spec.ts b/test/ReplaceGeometry.spec.ts index 0e3caece9..a6e552437 100644 --- a/test/ReplaceGeometry.spec.ts +++ b/test/ReplaceGeometry.spec.ts @@ -324,7 +324,7 @@ export default class ReplaceGeometrySpec extends T { constructor() { - super("ReplaceGeometry", [ + super( [ ["House replacement with connected node", async () => { Minimap.createMiniMap = () => undefined; diff --git a/test/SplitAction.spec.ts b/test/SplitAction.spec.ts index c476207a4..4e9187f77 100644 --- a/test/SplitAction.spec.ts +++ b/test/SplitAction.spec.ts @@ -8,7 +8,7 @@ export default class SplitActionSpec extends T { constructor() { - super("splitaction", [ + super([ ["split 295132739", () => SplitActionSpec.split().then(_ => console.log("OK"))], ["split 295132739 on already existing node", diff --git a/test/Tag.spec.ts b/test/Tag.spec.ts index 028ba169d..47994bfca 100644 --- a/test/Tag.spec.ts +++ b/test/Tag.spec.ts @@ -13,7 +13,7 @@ import TagRenderingConfig from "../Models/ThemeConfig/TagRenderingConfig"; export default class TagSpec extends T { constructor() { - super("tag", [ + super( [ ["Tag replacement works in translation", () => { const tr = new Translation({ "en": "Test {key} abc" diff --git a/test/TestAll.ts b/test/TestAll.ts index dabfc8e68..65050367e 100644 --- a/test/TestAll.ts +++ b/test/TestAll.ts @@ -15,12 +15,14 @@ import ImageProviderSpec from "./ImageProvider.spec"; import ActorsSpec from "./Actors.spec"; import ReplaceGeometrySpec from "./ReplaceGeometry.spec"; import LegacyThemeLoaderSpec from "./LegacyThemeLoader.spec"; +import T from "./TestHelper"; +import CreateNoteImportLayerSpec from "./CreateNoteImportLayer.spec"; async function main() { ScriptUtils.fixUtils() - const allTests = [ + const allTests : T[] = [ new OsmObjectSpec(), new TagSpec(), new ImageAttributionSpec(), @@ -35,7 +37,8 @@ async function main() { new ImageProviderSpec(), new ActorsSpec(), new ReplaceGeometrySpec(), - new LegacyThemeLoaderSpec() + new LegacyThemeLoaderSpec(), + new CreateNoteImportLayerSpec() ] Utils.externalDownloadFunction = async (url) => { @@ -54,12 +57,20 @@ async function main() { const allFailures: { testsuite: string, name: string, msg: string } [] = [] let testsToRun = allTests if (args.length > 0) { - args = args.map(a => a.toLowerCase()) + args = args.map(a => a.toLowerCase()).map(a => { + if(!a.endsWith("spec")){ + return a + "spec" + }else{ + return a; + } + }) testsToRun = allTests.filter(t => args.indexOf(t.name.toLowerCase()) >= 0) } if (testsToRun.length == 0) { - throw "No tests found. Try one of " + allTests.map(t => t.name).join(", ") + const available = allTests.map(t => t.name) + available.sort() + throw "No tests found. Try one of " + available.join(", ") } for (let i = 0; i < testsToRun.length; i++) { diff --git a/test/TestHelper.ts b/test/TestHelper.ts index 924c00cd1..9da668f32 100644 --- a/test/TestHelper.ts +++ b/test/TestHelper.ts @@ -3,8 +3,8 @@ export default class T { public readonly name: string; private readonly _tests: [string, (() => (void | Promise))][]; - constructor(testsuite: string, tests: [string, () => (Promise | void)][]) { - this.name = testsuite + constructor(tests: [string, () => (Promise | void)][]) { + this.name = this.constructor.name; this._tests = tests; } diff --git a/test/Theme.spec.ts b/test/Theme.spec.ts index 76a17c6c6..39f0dfa47 100644 --- a/test/Theme.spec.ts +++ b/test/Theme.spec.ts @@ -10,8 +10,7 @@ import Constants from "../Models/Constants"; export default class ThemeSpec extends T { constructor() { - super("theme", - [ + super( [ ["Nested overrides work", () => { let themeConfigJson: LayoutConfigJson = { diff --git a/test/TileFreshnessCalculator.spec.ts b/test/TileFreshnessCalculator.spec.ts index 7f5540d15..b431788bb 100644 --- a/test/TileFreshnessCalculator.spec.ts +++ b/test/TileFreshnessCalculator.spec.ts @@ -6,7 +6,7 @@ import {equal} from "assert"; export default class TileFreshnessCalculatorSpec extends T { constructor() { - super("TileFreshnessCalculatorSpec", [ + super( [ [ "TileFresnessTests", () => { diff --git a/test/Units.spec.ts b/test/Units.spec.ts index e0ffdee10..c93d57f84 100644 --- a/test/Units.spec.ts +++ b/test/Units.spec.ts @@ -6,7 +6,7 @@ import {Denomination} from "../Models/Denomination"; export default class UnitsSpec extends T { constructor() { - super("units", [ + super( [ ["Simple canonicalize", () => { const unit = new Denomination({ diff --git a/test/Utils.spec.ts b/test/Utils.spec.ts index 4a592bf3c..99559a534 100644 --- a/test/Utils.spec.ts +++ b/test/Utils.spec.ts @@ -39,7 +39,7 @@ export default class UtilsSpec extends T { } constructor() { - super("utils", [ + super( [ ["Sort object keys", () => { const o = { x: 'x', diff --git a/test/Wikidata.spec.test.ts b/test/Wikidata.spec.test.ts index cf636ffc2..47acd1a75 100644 --- a/test/Wikidata.spec.test.ts +++ b/test/Wikidata.spec.test.ts @@ -7255,8 +7255,7 @@ export default class WikidataSpecTest extends T { } constructor() { - super("Wikidata", - [ + super( [ ["Download Lion", async () => { Utils.injectJsonDownloadForTests(