More tests

This commit is contained in:
Pieter Vander Vennet 2022-03-15 13:40:23 +01:00
parent 50d383279d
commit 074782c1e0
6 changed files with 52 additions and 56 deletions

View file

@ -31,6 +31,15 @@ export default class ComparingTag implements TagsFilter {
return false;
}
/**
* Checks if the properties match
*
* const t = new ComparingTag("key", (x => Number(x) < 42))
* t.matchesProperties({key: 42}) // => false
* t.matchesProperties({key: 41}) // => true
* t.matchesProperties({key: 0}) // => true
* t.matchesProperties({differentKey: 42}) // => false
*/
matchesProperties(properties: any): boolean {
return this._predicate(properties[this._key]);
}

View file

@ -35,6 +35,8 @@ export class Tag extends TagsFilter {
* isEmpty.matchesProperties({"key": ""}) // => true
* isEmpty.matchesProperties({"other_key": ""}) // => true
* isEmpty.matchesProperties({"other_key": "value"}) // => true
* isEmpty.matchesProperties({"key": undefined}) // => true
*
*/
matchesProperties(properties: any): boolean {
const foundValue = properties[this.key]