aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tests/eval.spec.ts34
-rw-r--r--tests/parser.spec.ts5
2 files changed, 34 insertions, 5 deletions
diff --git a/tests/eval.spec.ts b/tests/eval.spec.ts
index 9bf3000..dada762 100644
--- a/tests/eval.spec.ts
+++ b/tests/eval.spec.ts
@@ -10,14 +10,14 @@ describe('Eval', () => {
const liexp: ListExpr = [
none,
- [ Expr.AnyNumber(null), Expr.Truthy(null) ],
+ [Expr.AnyNumber(null), Expr.Truthy(null)],
none,
]
expect(find(liexp, list)).toEqual([1, 3, 5])
const liexp2: ListExpr = [
none,
- [ Expr.Falsey(null), Expr.Truthy(null) ],
+ [Expr.Falsey(null), Expr.Truthy(null)],
none,
]
expect(find(liexp2, list)).toEqual([])
@@ -28,10 +28,36 @@ describe('Eval', () => {
const liexp: ListExpr = [
none,
- [ Expr.AnyItem(null), Expr.Group({ exprs: [ Expr.AnyNumber(null), Expr.Truthy(null)] }) ],
+ [
+ Expr.AnyItem(null),
+ Expr.Group({ exprs: [Expr.AnyNumber(null), Expr.Truthy(null)] }),
+ ],
none,
]
expect(find(liexp, list)).toEqual([1, 3, 5])
})
-})
+ it('object property', () => {
+ const list = [
+ { name: 20, age: 'hello' },
+ { name: 'gello', age: 20 },
+ { name: '', age: 20 },
+ { name: 'Wow' },
+ { age: 20 },
+ ]
+
+ const liexp: ListExpr = [
+ none,
+ [
+ Expr.PropertyMatch({
+ name: 'name',
+ exprs: [Expr.AnyString(null), Expr.Truthy(null)],
+ }),
+ Expr.PropertyMatch({ name: 'age', exprs: [Expr.AnyNumber(null)] }),
+ ],
+ none,
+ ]
+
+ expect(find(liexp, list)).toEqual([{ name: 'gello', age: 20 }])
+ })
+})
diff --git a/tests/parser.spec.ts b/tests/parser.spec.ts
index 1ebd290..4db0894 100644
--- a/tests/parser.spec.ts
+++ b/tests/parser.spec.ts
@@ -91,7 +91,10 @@ describe('Foobar', () => {
[
none,
[
- Expr.PropertyMatch({ name: 'name', exprs: [Expr.AnyString(null), Expr.Truthy(null)] }),
+ Expr.PropertyMatch({
+ name: 'name',
+ exprs: [Expr.AnyString(null), Expr.Truthy(null)],
+ }),
Expr.PropertyMatch({ name: 'age', exprs: [Expr.AnyNumber(null)] }),
],
none,