Fix: tests

This commit is contained in:
Pieter Vander Vennet 2025-03-15 00:45:00 +01:00
parent 584dc6b5e6
commit e24b465783
2 changed files with 14 additions and 12 deletions

View file

@ -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. * 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 * @see MatchesMultiAnswer to do the reverse
* *
@ -369,10 +370,10 @@ export class TagUtils {
* and: ["x=b", "y=2"] * 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","y"), new Tag("a","b")])) // => [new Tag("x","y"), new Tag("a","b")]
* TagUtils.FlattenMultiAnswer(([new Tag("x","")])) // => new And([new Tag("x","")]) * TagUtils.FlattenMultiAnswer(([new Tag("x","")])) // => [new Tag("x","")]
*/ */
static FlattenMultiAnswer(tagsFilters: UploadableTag[]): UploadableTag[] { static FlattenMultiAnswer(tagsFilters: UploadableTag[]): UploadableTag[] {
if (tagsFilters === undefined) { if (tagsFilters === undefined) {

View file

@ -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}" }, * 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?"}, * "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"}, * "mappings":[{"if":"books=children","then":"Mostly children books"},
* {"if":"books=adults","then": "Mostly books for adults"}]} * {"if":"books=adults","then": "Mostly books for adults"}]}
* , "testcase") * , "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"} }) * const config = new TagRenderingConfig({"id":"capacity", "render": "Fits {capcity} books",freeform: {"key":"capacity",type:"pnat"} })
* config.constructChangeSpecification("", undefined, undefined, {}) // => undefined * 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"}]}) * 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", 1, undefined, {}).asHumanString(false, false, {}) // => [new Tag("shop","freeform",new Tag("fixme","freeform shop type used")]
* config.constructChangeSpecification("freeform", undefined, undefined, {}).asHumanString(false, false, {}) // => "shop=freeform & 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, {}).asHumanString(false, false, {}) // => "shop=second_hand" * 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"}, * 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}] } * "hideInAnswer": true}] }
* const tags = config.constructChangeSpecification("Tu-Fr 05:30-09:30", undefined, undefined, { }} * 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 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"}) * 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 * @param freeformValue The freeform value which will be applied as 'freeform.key'. Ignored if 'freeform.key' is not set