Fix tests

This commit is contained in:
Pieter Vander Vennet 2022-01-26 21:21:12 +01:00
parent 50ae3bf5ba
commit 148e056f96

View file

@ -179,7 +179,7 @@ class AddImportLayers extends DesugaringStep<LayoutConfigJson> {
} }
class AddMiniMap extends DesugaringStep<LayerConfigJson> { export class AddMiniMap extends DesugaringStep<LayerConfigJson> {
constructor() { constructor() {
super("Adds a default 'minimap'-element to the tagrenderings if none of the elements define such a minimap", ["tagRenderings"]); super("Adds a default 'minimap'-element to the tagrenderings if none of the elements define such a minimap", ["tagRenderings"]);
} }
@ -188,14 +188,18 @@ class AddMiniMap extends DesugaringStep<LayerConfigJson> {
* Returns true if this tag rendering has a minimap in some language. * Returns true if this tag rendering has a minimap in some language.
* Note: this minimap can be hidden by conditions * Note: this minimap can be hidden by conditions
*/ */
private static hasMinimap(renderingConfig: TagRenderingConfigJson): boolean { static hasMinimap(renderingConfig: TagRenderingConfigJson): boolean {
const translations: Translation[] = Utils.NoNull([renderingConfig.render, ...(renderingConfig.mappings ?? []).map(m => m.then)]); const translations: any[] = Utils.NoNull([renderingConfig.render, ...(renderingConfig.mappings ?? []).map(m => m.then)]);
for (const translation of translations) { for (let translation of translations) {
for (const key in translation.translations) { if(typeof translation == "string"){
if (!translation.translations.hasOwnProperty(key)) { translation = {"*": translation}
}
for (const key in translation) {
if (!translation.hasOwnProperty(key)) {
continue continue
} }
const template = translation.translations[key] const template = translation[key]
const parts = SubstitutedTranslation.ExtractSpecialComponents(template) const parts = SubstitutedTranslation.ExtractSpecialComponents(template)
const hasMiniMap = parts.filter(part => part.special !== undefined).some(special => special.special.func.funcName === "minimap") const hasMiniMap = parts.filter(part => part.special !== undefined).some(special => special.special.func.funcName === "minimap")
if (hasMiniMap) { if (hasMiniMap) {