summaryrefslogtreecommitdiff
path: root/tests/parse-expr.spec.ts
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2023-08-10 22:04:02 +0530
committerAkshay Nair <phenax5@gmail.com>2023-08-10 22:04:02 +0530
commit2102e7608b1b3634a651cb40508d2f560f3eeb05 (patch)
tree30016c790dbebc130842f967ddcda477cda468d4 /tests/parse-expr.spec.ts
parent3854a42db888a58f0452bfb23b6e17df5bf8ad39 (diff)
downloadcss-everything-2102e7608b1b3634a651cb40508d2f560f3eeb05.tar.gz
css-everything-2102e7608b1b3634a651cb40508d2f560f3eeb05.zip
feat: adds string literal and css variable identifier parsers
Diffstat (limited to 'tests/parse-expr.spec.ts')
-rw-r--r--tests/parse-expr.spec.ts31
1 files changed, 31 insertions, 0 deletions
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')],
+ }),
+ ],
+ }),
+ ])
+ })
})