diff options
| author | Akshay Nair <phenax5@gmail.com> | 2023-08-11 17:13:33 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2023-08-11 17:13:33 +0530 |
| commit | 67748db74f73343b054ee0af1763e376a5470416 (patch) | |
| tree | 39b8df64ea1d657ef107fcdfed2da8ce66063589 /tests/eval.spec.ts | |
| parent | dfd4da6ca2d06c9d05d5c7e297304316da211dd4 (diff) | |
| download | css-everything-67748db74f73343b054ee0af1763e376a5470416.tar.gz css-everything-67748db74f73343b054ee0af1763e376a5470416.zip | |
feat: adds more functions for eval
Diffstat (limited to 'tests/eval.spec.ts')
| -rw-r--r-- | tests/eval.spec.ts | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/tests/eval.spec.ts b/tests/eval.spec.ts index 63062e3..8b7424f 100644 --- a/tests/eval.spec.ts +++ b/tests/eval.spec.ts @@ -1,10 +1,15 @@ -import { Dependencies, evalExpr } from '../src/eval' +import { EvalActions, evalExpr } from '../src/eval' import { Expr } from '../src/parser' describe('eval', () => { - const deps: Dependencies = { + const deps: EvalActions = { addClass: jest.fn(), removeClass: jest.fn(), + delay: jest.fn(), + jsEval: jest.fn(), + loadCssx: jest.fn(), + getVariable: jest.fn(), + updateVariable: jest.fn(), } it('should add classes', async () => { @@ -17,7 +22,7 @@ describe('eval', () => { expect(deps.addClass).toHaveBeenCalledWith('element-id', 'class-name') }) - it('should add classes', async () => { + it('should remove classes', async () => { await evalExpr(Expr.Call({ name: 'remove-class', args: [ Expr.Identifier('element-id'), Expr.LiteralString('class-name') ], @@ -26,4 +31,24 @@ describe('eval', () => { expect(deps.removeClass).toHaveBeenCalledTimes(1) expect(deps.removeClass).toHaveBeenCalledWith('element-id', 'class-name') }) + + it('should add a delay', async () => { + await evalExpr(Expr.Call({ + name: 'delay', + args: [ Expr.LiteralString('200') ], + }), deps) + + expect(deps.delay).toHaveBeenCalledTimes(1) + expect(deps.delay).toHaveBeenCalledWith(200) + }) + + it('should get variable', async () => { + await evalExpr(Expr.Call({ + name: 'var', + args: [ Expr.LiteralString('--my-var'), Expr.LiteralString('def value') ], + }), deps) + + expect(deps.getVariable).toHaveBeenCalledTimes(1) + expect(deps.getVariable).toHaveBeenCalledWith('--my-var') + }) }) |
