diff options
| author | Akshay Nair <phenax5@gmail.com> | 2023-08-13 18:46:16 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2023-08-13 18:56:10 +0530 |
| commit | 78550c0d1c7037b17bdaa9413351b759b20772c0 (patch) | |
| tree | 2fbef895d94698ec3ec20fe961493748c1a6f1c0 /tests/eval.spec.ts | |
| parent | 2f3de513168ac8a912e4b6540907492437a5f834 (diff) | |
| download | css-everything-78550c0d1c7037b17bdaa9413351b759b20772c0.tar.gz css-everything-78550c0d1c7037b17bdaa9413351b759b20772c0.zip | |
feat: adds conditionals
Diffstat (limited to '')
| -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({ |
