@@ -130,6 +130,24 @@ describe('Value Node Types', () => {
130130 expect ( value ?. line ) . toBe ( 3 )
131131 expect ( value ?. column ) . toBe ( 10 )
132132 } )
133+
134+ it ( 'should have correct offset and length for var()' , ( ) => {
135+ const value = getValue ( 'div { color: var(--item); }' )
136+ expect ( value ?. start ) . toBe ( 13 )
137+ expect ( value ?. length ) . toBe ( 11 )
138+ expect ( value ?. end ) . toBe ( 24 )
139+ expect ( value ?. line ) . toBe ( 1 )
140+ expect ( value ?. column ) . toBe ( 14 )
141+ } )
142+
143+ it ( 'should have correct offset and length for var() with fallback' , ( ) => {
144+ const value = getValue ( 'div { color: var(--item1, var(--item2)); }' )
145+ expect ( value ?. start ) . toBe ( 13 )
146+ expect ( value ?. length ) . toBe ( 26 )
147+ expect ( value ?. end ) . toBe ( 39 )
148+ expect ( value ?. line ) . toBe ( 1 )
149+ expect ( value ?. column ) . toBe ( 14 )
150+ } )
133151 } )
134152
135153 describe ( 'OPERATOR' , ( ) => {
@@ -513,6 +531,18 @@ describe('Value Node Types', () => {
513531 expect ( func ?. has_children ) . toBe ( true )
514532 } )
515533
534+ it ( 'should provide node.value for var() function with fallback' , ( ) => {
535+ const root = parse ( 'body { color: var(--primary-color, 1); }' )
536+ const decl = root . first_child ?. first_child ?. next_sibling ?. first_child
537+ const func = decl ?. values [ 0 ]
538+
539+ expect ( func ?. type ) . toBe ( FUNCTION )
540+ expect ( func ?. name ) . toBe ( 'var' )
541+ expect ( func ?. text ) . toBe ( 'var(--primary-color, 1)' )
542+ expect ( func ?. value ) . toBe ( '--primary-color, 1' )
543+ expect ( func ?. has_children ) . toBe ( true )
544+ } )
545+
516546 it ( 'should parse transform value' , ( ) => {
517547 const root = parse ( 'body { transform: translateX(10px) rotate(45deg); }' )
518548 const decl = root . first_child ?. first_child ?. next_sibling ?. first_child
0 commit comments