From 2102e7608b1b3634a651cb40508d2f560f3eeb05 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Thu, 10 Aug 2023 22:04:02 +0530 Subject: feat: adds string literal and css variable identifier parsers --- tests/parse-expr.spec.ts | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'tests/parse-expr.spec.ts') diff --git a/tests/parse-expr.spec.ts b/tests/parse-expr.spec.ts index 875af63..f873464 100644 --- a/tests/parse-expr.spec.ts +++ b/tests/parse-expr.spec.ts @@ -42,4 +42,35 @@ describe('parser', () => { }), ]) }) + + it('should parse string literal', () => { + expect(parse(`"hello world toodles \' nice single quote there"`)).toEqual([ + Expr.LiteralString(`hello world toodles \' nice single quote there`), + ]) + + expect(parse(` 'hello world toodles \" nice double quote there' `)).toEqual( + [Expr.LiteralString(`hello world toodles \" nice double quote there`)] + ) + }) + + it('should parse var identifiers', () => { + expect(parse(`var(--hello, 'default')`)).toEqual([ + Expr.Call({ + name: 'var', + args: [Expr.VarIdentifier('--hello'), Expr.LiteralString(`default`)], + }), + ]) + + expect(parse(`calc(var(--hello))`)).toEqual([ + Expr.Call({ + name: 'calc', + args: [ + Expr.Call({ + name: 'var', + args: [Expr.VarIdentifier('--hello')], + }), + ], + }), + ]) + }) }) -- cgit v1.3.1