@@ -607,36 +607,48 @@ describe('Value Node Types', () => {
607607 } )
608608
609609 describe ( 'OPERATOR' , ( ) => {
610- it ( 'should parse comma operator' , ( ) => {
611- const root = parse ( 'body { font-family: Arial, sans-serif; }' )
612- const decl = root . first_child ?. first_child ?. next_sibling ?. first_child
613-
614- expect ( decl ?. first_child ! . children [ 1 ] . type ) . toBe ( OPERATOR )
615- expect ( decl ?. first_child ! . children [ 1 ] . text ) . toBe ( ',' )
616- } )
610+ it ( 'should parse comma operator' , ( ) => {
611+ const root = parse ( 'body { font-family: Arial, sans-serif; }' )
612+ const decl = root . first_child ?. first_child ?. next_sibling ?. first_child
617613
618- it ( 'should parse calc operators' , ( ) => {
619- const root = parse ( 'body { width: calc(100% - 20px); }' )
620- const decl = root . first_child ?. first_child ?. next_sibling ?. first_child
621- const func = decl ?. first_child ! . children [ 0 ]
614+ expect ( decl ?. first_child ! . children [ 1 ] . type ) . toBe ( OPERATOR )
615+ expect ( decl ?. first_child ! . children [ 1 ] . text ) . toBe ( ',' )
616+ expect ( decl ?. first_child ! . children [ 1 ] . name ) . toBe ( undefined )
617+ expect ( decl ?. first_child ! . children [ 1 ] . value ) . toBe ( ',' )
618+ } )
622619
623- expect ( func ?. children [ 1 ] . type ) . toBe ( OPERATOR )
624- expect ( func ?. children [ 1 ] . text ) . toBe ( '-' )
625- } )
620+ it ( 'should parse calc operators' , ( ) => {
621+ const root = parse ( 'body { width: calc(100% - 20px); }' )
622+ const decl = root . first_child ?. first_child ?. next_sibling ?. first_child
623+ const func = decl ?. first_child ! . children [ 0 ]
626624
627- it ( 'should parse all calc operators' , ( ) => {
628- const root = parse ( 'body { width: calc(1px + 2px * 3px / 4px - 5px); }' )
629- const decl = root . first_child ?. first_child ?. next_sibling ?. first_child
630- const func = decl ?. first_child ! . children [ 0 ]
625+ expect ( func ?. children [ 1 ] . type ) . toBe ( OPERATOR )
626+ expect ( func ?. children [ 1 ] . text ) . toBe ( '-' )
627+ expect ( func ?. children [ 1 ] . name ) . toBe ( undefined )
628+ expect ( func ?. children [ 1 ] . value ) . toBe ( '-' )
629+ } )
631630
632- const operators = func ?. children . filter ( ( n ) => n . type === OPERATOR )
633- expect ( operators ) . toHaveLength ( 4 )
634- expect ( operators ?. [ 0 ] . text ) . toBe ( '+' )
635- expect ( operators ?. [ 1 ] . text ) . toBe ( '*' )
636- expect ( operators ?. [ 2 ] . text ) . toBe ( '/' )
637- expect ( operators ?. [ 3 ] . text ) . toBe ( '-' )
638- } )
631+ it ( 'should parse all calc operators' , ( ) => {
632+ const root = parse ( 'body { width: calc(1px + 2px * 3px / 4px - 5px); }' )
633+ const decl = root . first_child ?. first_child ?. next_sibling ?. first_child
634+ const func = decl ?. first_child ! . children [ 0 ]
635+
636+ const operators = func ?. children . filter ( ( n ) => n . type === OPERATOR )
637+ expect ( operators ) . toHaveLength ( 4 )
638+ expect ( operators ?. [ 0 ] . text ) . toBe ( '+' )
639+ expect ( operators ?. [ 0 ] . name ) . toBe ( undefined )
640+ expect ( operators ?. [ 0 ] . value ) . toBe ( '+' )
641+ expect ( operators ?. [ 1 ] . text ) . toBe ( '*' )
642+ expect ( operators ?. [ 1 ] . name ) . toBe ( undefined )
643+ expect ( operators ?. [ 1 ] . value ) . toBe ( '*' )
644+ expect ( operators ?. [ 2 ] . text ) . toBe ( '/' )
645+ expect ( operators ?. [ 2 ] . name ) . toBe ( undefined )
646+ expect ( operators ?. [ 2 ] . value ) . toBe ( '/' )
647+ expect ( operators ?. [ 3 ] . text ) . toBe ( '-' )
648+ expect ( operators ?. [ 3 ] . name ) . toBe ( undefined )
649+ expect ( operators ?. [ 3 ] . value ) . toBe ( '-' )
639650 } )
651+ } )
640652
641653 describe ( 'PARENTHESIS' , ( ) => {
642654 it ( 'should parse parenthesized expressions in calc()' , ( ) => {
0 commit comments