diff options
Diffstat (limited to 'tests/eval.spec.ts')
| -rw-r--r-- | tests/eval.spec.ts | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/eval.spec.ts b/tests/eval.spec.ts index 2212ba4..1d8b161 100644 --- a/tests/eval.spec.ts +++ b/tests/eval.spec.ts @@ -26,6 +26,50 @@ describe('eval', () => { expect(deps.addClass).toHaveBeenCalledWith('element-id', 'class-name') }) + it('should allow conditionals classes', async () => { + expect( + await evalExpr( + Expr.Call({ + name: 'if', + args: [ + Expr.Identifier('true'), + Expr.Identifier('yes'), + Expr.Identifier('no'), + ], + }), + deps, + ), + ).toBe('yes') + + expect( + await evalExpr( + Expr.Call({ + name: 'if', + args: [ + Expr.Identifier('false'), + Expr.Identifier('yes'), + Expr.Identifier('no'), + ], + }), + deps, + ), + ).toBe('no') + + expect( + await evalExpr( + Expr.Call({ + name: 'if', + args: [ + Expr.Identifier('0'), + Expr.Identifier('yes'), + Expr.Identifier('no'), + ], + }), + deps, + ), + ).toBe('no') + }) + it('should remove classes', async () => { await evalExpr( Expr.Call({ |
