mapcomplete/test/CreateNoteImportLayer.spec.ts

36 lines
1.9 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 LayerConfig from "../Models/ThemeConfig/LayerConfig";
import {PrepareLayer} from "../Models/ThemeConfig/Conversion/PrepareLayer";
2022-01-26 21:28:22 +01:00
import TagRenderingConfigJsonJSC from "../Docs/Schemas/TagRenderingConfigJsonJSC";
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>()
}
const layerPrepare = new PrepareLayer()
const layer =layerPrepare.convertStrict(desugaringState, bookcases, "ImportLayerGeneratorTest:Parse bookcases")
2022-01-14 13:58:15 +01:00
const generator = new CreateNoteImportLayer()
2022-01-26 21:28:22 +01:00
const generatedLayer : LayerConfigJson = generator.convertStrict(desugaringState, layer, "ImportLayerGeneratorTest: convert")
T.equals("_tags~(^|.*;)amenity=public_bookcase($|;.*)", generatedLayer.isShown.mappings[1].if["and"][1].or[0].and[0])
let renderings = Utils.NoNull(Utils.NoNull(generatedLayer.tagRenderings
.map(tr => (<TagRenderingConfigJson> tr).render))
.map(render => render["en"]))
T.equals(true, renderings.some(r => r.indexOf("import_button") > 0))
2022-01-14 13:58:15 +01:00
}]
]);
}
}