2022-03-23 19:48:06 +01:00
|
|
|
import { Utils } from "../../../../Utils"
|
|
|
|
import { DesugaringContext } from "../../../../Models/ThemeConfig/Conversion/Conversion"
|
|
|
|
import { LayerConfigJson } from "../../../../Models/ThemeConfig/Json/LayerConfigJson"
|
|
|
|
import { TagRenderingConfigJson } from "../../../../Models/ThemeConfig/Json/TagRenderingConfigJson"
|
|
|
|
import { PrepareLayer } from "../../../../Models/ThemeConfig/Conversion/PrepareLayer"
|
|
|
|
import * as bookcases from "../../../../assets/layers/public_bookcase/public_bookcase.json"
|
|
|
|
import CreateNoteImportLayer from "../../../../Models/ThemeConfig/Conversion/CreateNoteImportLayer"
|
2023-02-03 04:48:32 +01:00
|
|
|
import { describe, expect, it } from "vitest"
|
2022-03-23 19:48:06 +01:00
|
|
|
|
|
|
|
describe("CreateNoteImportLayer", () => {
|
|
|
|
it("should generate a layerconfig", () => {
|
|
|
|
const desugaringState: DesugaringContext = {
|
|
|
|
sharedLayers: new Map<string, LayerConfigJson>(),
|
|
|
|
tagRenderings: new Map<string, TagRenderingConfigJson>(),
|
|
|
|
}
|
|
|
|
const layerPrepare = new PrepareLayer(desugaringState)
|
|
|
|
const layer = layerPrepare.convertStrict(
|
|
|
|
bookcases,
|
|
|
|
"ImportLayerGeneratorTest:Parse bookcases"
|
|
|
|
)
|
|
|
|
const generator = new CreateNoteImportLayer()
|
|
|
|
const generatedLayer: LayerConfigJson = generator.convertStrict(
|
|
|
|
layer,
|
|
|
|
"ImportLayerGeneratorTest: convert"
|
|
|
|
)
|
2023-03-09 23:19:49 +01:00
|
|
|
expect(generatedLayer.isShown["and"][1].or[0].and[0]).toEqual(
|
|
|
|
"_tags~(^|.*;)amenity=public_bookcase($|;.*)"
|
|
|
|
)
|
2023-02-03 04:48:32 +01:00
|
|
|
// "Zoomlevel is to high"
|
|
|
|
expect(generatedLayer.minzoom <= layer.minzoom).toBe(true)
|
2022-03-23 19:48:06 +01:00
|
|
|
let renderings = Utils.NoNull(
|
|
|
|
Utils.NoNull(
|
|
|
|
generatedLayer.tagRenderings.map((tr) => (<TagRenderingConfigJson>tr).render)
|
|
|
|
).map((render) => render["en"])
|
2022-09-08 21:40:48 +02:00
|
|
|
)
|
2023-02-03 04:48:32 +01:00
|
|
|
// "no import button found"
|
|
|
|
expect(renderings.some((r) => r.indexOf("import_button") > 0)).toBe(true)
|
2022-03-23 19:48:06 +01:00
|
|
|
})
|
|
|
|
})
|