mapcomplete/test/CreateNoteImportLayer.spec.ts

35 lines
1.8 KiB
TypeScript
Raw Normal View History

2022-01-14 13:58:15 +01:00
import T from "./TestHelper";
import CreateNoteImportLayer from "../Models/ThemeConfig/Conversion/CreateNoteImportLayer";
import * as bookcases from "../assets/layers/public_bookcase/public_bookcase.json"
import {DesugaringContext} from "../Models/ThemeConfig/Conversion/Conversion";
2022-01-14 13:58:15 +01:00
import {LayerConfigJson} from "../Models/ThemeConfig/Json/LayerConfigJson";
import {TagRenderingConfigJson} from "../Models/ThemeConfig/Json/TagRenderingConfigJson";
import {PrepareLayer} from "../Models/ThemeConfig/Conversion/PrepareLayer";
2022-01-26 21:28:22 +01:00
import {Utils} from "../Utils";
2022-01-14 13:58:15 +01:00
export default class CreateNoteImportLayerSpec extends T {
constructor() {
super([
["Bookcase", () => {
const desugaringState: DesugaringContext = {
sharedLayers: new Map<string, LayerConfigJson>(),
tagRenderings: new Map<string, TagRenderingConfigJson>()
}
2022-02-04 01:09:21 +01:00
const layerPrepare = new PrepareLayer(desugaringState)
const layer = layerPrepare.convertStrict(bookcases, "ImportLayerGeneratorTest:Parse bookcases")
2022-01-14 13:58:15 +01:00
const generator = new CreateNoteImportLayer()
2022-02-04 01:09:21 +01:00
const generatedLayer: LayerConfigJson = generator.convertStrict(layer, "ImportLayerGeneratorTest: convert")
2022-01-26 21:28:22 +01:00
T.equals("_tags~(^|.*;)amenity=public_bookcase($|;.*)", generatedLayer.isShown.mappings[1].if["and"][1].or[0].and[0])
2022-01-27 00:22:37 +01:00
T.isTrue(generatedLayer.minzoom <= layer.minzoom, "Zoomlevel is to high")
2022-01-26 21:28:22 +01:00
let renderings = Utils.NoNull(Utils.NoNull(generatedLayer.tagRenderings
2022-01-26 21:40:38 +01:00
.map(tr => (<TagRenderingConfigJson>tr).render))
2022-01-26 21:28:22 +01:00
.map(render => render["en"]))
2022-01-27 00:22:37 +01:00
T.isTrue(renderings.some(r => r.indexOf("import_button") > 0), "no import button found")
2022-01-14 13:58:15 +01:00
}]
]);
}
}