forked from MapComplete/MapComplete
Fix: fix tests
This commit is contained in:
parent
34cc65b240
commit
42f07bc1f3
1 changed files with 6 additions and 3 deletions
|
@ -1006,15 +1006,18 @@ export class TagUtils {
|
||||||
* Returns a similarly structured tag, but all tags with an empty value are removed.
|
* Returns a similarly structured tag, but all tags with an empty value are removed.
|
||||||
* Those are assumed to be all met (and thus true)
|
* Those are assumed to be all met (and thus true)
|
||||||
*
|
*
|
||||||
* new And([new Tag("a", "b"), new Tag("c", "")] // => new Tag("a","b")
|
* TagUtils.removeEmptyParts(new And([new Tag("a", "b"), new Tag("c", "")])) // => new Tag("a","b")
|
||||||
* new And([new Tag("c", "")] // => true
|
* TagUtils.removeEmptyParts(new And([new Tag("c", "")])) // => true
|
||||||
*/
|
*/
|
||||||
public static removeEmptyParts(tag: UploadableTag): UploadableTag | true {
|
public static removeEmptyParts(tag: UploadableTag): UploadableTag | true {
|
||||||
if (tag["and"]) {
|
if (tag["and"]) {
|
||||||
const tags = <UploadableTag[]>tag["and"]
|
const tags = <UploadableTag[]>tag["and"]
|
||||||
const cleaned = tags.map(t => TagUtils.removeEmptyParts(t))
|
const cleaned = tags.map(t => TagUtils.removeEmptyParts(t))
|
||||||
const filtered = <UploadableTag[]>cleaned.filter(t => t !== true)
|
const filtered = <UploadableTag[]>cleaned.filter(t => t !== true)
|
||||||
return new And(filtered)
|
if (filtered.length === 0) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return <true | UploadableTag>new And(filtered).optimize()
|
||||||
}
|
}
|
||||||
if (tag.isNegative()) {
|
if (tag.isNegative()) {
|
||||||
return true
|
return true
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue