From e24b465783fc933f908b3d01290dd5166abff746 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Sat, 15 Mar 2025 00:45:00 +0100 Subject: [PATCH] Fix: tests --- src/Logic/Tags/TagUtils.ts | 7 ++++--- src/Models/ThemeConfig/TagRenderingConfig.ts | 19 ++++++++++--------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/Logic/Tags/TagUtils.ts b/src/Logic/Tags/TagUtils.ts index aa92c24bd..2f5506b96 100644 --- a/src/Logic/Tags/TagUtils.ts +++ b/src/Logic/Tags/TagUtils.ts @@ -353,6 +353,7 @@ export class TagUtils { /** * Given multiple tagsfilters which can be used as answer, will take the tags with the same keys together as set. + * The result must be interpreted as 'and' * * @see MatchesMultiAnswer to do the reverse * @@ -369,10 +370,10 @@ export class TagUtils { * and: ["x=b", "y=2"] * } * ]}) - * TagUtils.FlattenMultiAnswer([tag]) // => TagUtils.Tag({and:["x=a;b", "y=0;1;2;3"] }) + * TagUtils.FlattenMultiAnswer([tag]) // => [new Tag("x","a;b"),new Tag("y","0;1;2;3")] * - * TagUtils.FlattenMultiAnswer(([new Tag("x","y"), new Tag("a","b")])) // => new And([new Tag("x","y"), new Tag("a","b")]) - * TagUtils.FlattenMultiAnswer(([new Tag("x","")])) // => new And([new Tag("x","")]) + * TagUtils.FlattenMultiAnswer(([new Tag("x","y"), new Tag("a","b")])) // => [new Tag("x","y"), new Tag("a","b")] + * TagUtils.FlattenMultiAnswer(([new Tag("x","")])) // => [new Tag("x","")] */ static FlattenMultiAnswer(tagsFilters: UploadableTag[]): UploadableTag[] { if (tagsFilters === undefined) { diff --git a/src/Models/ThemeConfig/TagRenderingConfig.ts b/src/Models/ThemeConfig/TagRenderingConfig.ts index 8751e7738..3d083299f 100644 --- a/src/Models/ThemeConfig/TagRenderingConfig.ts +++ b/src/Models/ThemeConfig/TagRenderingConfig.ts @@ -686,7 +686,8 @@ export default class TagRenderingConfig { } /** - * Given a value for the freeform key and an overview of the selected mappings, construct the correct tagsFilter to apply + * Given a value for the freeform key and an overview of the selected mappings, construct the correct tagsFilter to apply. + * Result should be interpreted as "and" * * const config = new TagRenderingConfig({"id":"bookcase-booktypes","render":{"en":"This place mostly serves {books}" }, * "question":{"en":"What kind of books can be found in this public bookcase?"}, @@ -696,17 +697,17 @@ export default class TagRenderingConfig { * "mappings":[{"if":"books=children","then":"Mostly children books"}, * {"if":"books=adults","then": "Mostly books for adults"}]} * , "testcase") - * config.constructChangeSpecification(undefined, undefined, [false, true, false], {amenity: "public_bookcase"}) // => new And([new Tag("books","adults")]) + * config.constructChangeSpecification(undefined, undefined, [false, true, false], {amenity: "public_bookcase"}) // => [new Tag("books","adults")] * * const config = new TagRenderingConfig({"id":"capacity", "render": "Fits {capcity} books",freeform: {"key":"capacity",type:"pnat"} }) * config.constructChangeSpecification("", undefined, undefined, {}) // => undefined - * config.constructChangeSpecification("5", undefined, undefined, {}).optimize() // => new Tag("capacity", "5") + * config.constructChangeSpecification("5", undefined, undefined, {}).optimize() // => [new Tag("capacity", "5")] * - * // Should pick a mapping, even if freeform is used + * // Should pick a mapping, even if freeform is usedconstructChange * const config = new TagRenderingConfig({"id": "shop-types", render: "Shop type is {shop}", freeform: {key: "shop", addExtraTags:["fixme=freeform shop type used"]}, mappings:[{if: "shop=second_hand", then: "Second hand shop"}]}) - * config.constructChangeSpecification("freeform", 1, undefined, {}).asHumanString(false, false, {}) // => "shop=freeform & fixme=freeform shop type used" - * config.constructChangeSpecification("freeform", undefined, undefined, {}).asHumanString(false, false, {}) // => "shop=freeform & fixme=freeform shop type used" - * config.constructChangeSpecification("second_hand", 1, undefined, {}).asHumanString(false, false, {}) // => "shop=second_hand" + * config.constructChangeSpecification("freeform", 1, undefined, {}).asHumanString(false, false, {}) // => [new Tag("shop","freeform",new Tag("fixme","freeform shop type used")] + * config.constructChangeSpecification("freeform", undefined, undefined, {}) // => [new Tag("shop","freeform), new Tag("fixme","freeform shop type used")] + * config.constructChangeSpecification("second_hand", 1, undefined, {}) // => [new Tag("shop","second_hand")] * * * const config = new TagRenderingConfig({id: "oh", render: "{opening_hours}", question: {"en":"When open?"}, freeform: {key: "opening_hours"}, @@ -716,11 +717,11 @@ export default class TagRenderingConfig { * }, * "hideInAnswer": true}] } * const tags = config.constructChangeSpecification("Tu-Fr 05:30-09:30", undefined, undefined, { }} - * tags // =>new And([ new Tag("opening_hours", "Tu-Fr 05:30-09:30")]) + * tags // => [ new Tag("opening_hours", "Tu-Fr 05:30-09:30")] * * const config = new TagRenderingConfig({"id": "charge", render: "One tube costs {charge}", freeform: {key: "charge", postfixDistinguished: "bicycle_tube"]}, }) * const tags = config.constructChangeSpecification("€5", undefined, undefined, {vending: "books;bicycle_tubes" charge: "€42/book"}) - * tags // =>new And([ new Tag("charge", "€5/bicycle_tube; €42/book")]) + * tags // => [ new Tag("charge", "€5/bicycle_tube; €42/book")] * * * @param freeformValue The freeform value which will be applied as 'freeform.key'. Ignored if 'freeform.key' is not set