summaryrefslogtreecommitdiff
path: root/tests/eval.spec.ts
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2023-08-13 18:46:16 +0530
committerAkshay Nair <phenax5@gmail.com>2023-08-13 18:56:10 +0530
commit78550c0d1c7037b17bdaa9413351b759b20772c0 (patch)
tree2fbef895d94698ec3ec20fe961493748c1a6f1c0 /tests/eval.spec.ts
parent2f3de513168ac8a912e4b6540907492437a5f834 (diff)
downloadcss-everything-78550c0d1c7037b17bdaa9413351b759b20772c0.tar.gz
css-everything-78550c0d1c7037b17bdaa9413351b759b20772c0.zip
feat: adds conditionals
Diffstat (limited to 'tests/eval.spec.ts')
-rw-r--r--tests/eval.spec.ts44
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({