@@ -24,39 +24,69 @@ describe('Parser', () => {
2424 } ) ;
2525
2626 // #98 was merged to resolve this but broke other scenarios
27- it ( 'parses variables with whitespaces between name and ":"' ) ; // , () => {
28- // let root = parse('@onespace : 42;');
29- //
30- // expect(root.first.prop).to.eql('@onespace');
31- // expect(root.first.value).to.eql('42');
32- // });
27+ it ( 'parses variables with whitespaces between name and ":"' , ( ) => {
28+ let root = parse ( '@onespace : 42;' ) ;
29+
30+ expect ( root . first . prop ) . to . eql ( '@onespace' ) ;
31+ expect ( root . first . value ) . to . eql ( '42' ) ;
32+ } ) ;
3333
3434 // #98 was merged to resolve this but broke other scenarios
3535 // these tests are commented out until that is resolved
36- it ( 'parses variables with no whitespace between ":" and value' ) ; //, () => {
37- // const root = parse('@var :42;');
38- //
39- // expect(root.first.prop).to.eql('@var');
40- // expect(root.first.value).to.eql('42');
41- // });
42- //
43- it ( 'parses mutliple variables with whitespaces between name and ":"' ) ; //, () => {
44- // const root = parse('@foo : 42; @bar : 35;');
45- //
46- // expect(root.first.prop).to.eql('@foo');
47- // expect(root.first.value).to.eql('42');
48- // expect(root.nodes[1].prop).to.eql('@bar');
49- // expect(root.nodes[1].value).to.eql('35');
50- // });
51- //
52- it ( 'parses multiple variables with no whitespace between ":" and value' ) ; //, () => {
53- // const root = parse('@foo :42; @bar :35');
54- //
55- // expect(root.first.prop).to.eql('@foo');
56- // expect(root.first.value).to.eql('42');
57- // expect(root.nodes[1].prop).to.eql('@bar');
58- // expect(root.nodes[1].value).to.eql('35');
59- // });
36+ it ( 'parses variables with no whitespace between ":" and value' , ( ) => {
37+ const root = parse ( '@var :42;' ) ;
38+
39+ expect ( root . first . prop ) . to . eql ( '@var' ) ;
40+ expect ( root . first . value ) . to . eql ( '42' ) ;
41+ } ) ;
42+
43+ it ( 'parses mutliple variables with whitespaces between name and ":"' , ( ) => {
44+ const root = parse ( '@foo : 42; @bar : 35;' ) ;
45+
46+ expect ( root . first . prop ) . to . eql ( '@foo' ) ;
47+ expect ( root . first . value ) . to . eql ( '42' ) ;
48+ expect ( root . nodes [ 1 ] . prop ) . to . eql ( '@bar' ) ;
49+ expect ( root . nodes [ 1 ] . value ) . to . eql ( '35' ) ;
50+ } ) ;
51+
52+ it ( 'parses multiple variables with no whitespace between ":" and value' , ( ) => {
53+ const root = parse ( '@foo :42; @bar :35' ) ;
54+
55+ expect ( root . first . prop ) . to . eql ( '@foo' ) ;
56+ expect ( root . first . value ) . to . eql ( '42' ) ;
57+ expect ( root . nodes [ 1 ] . prop ) . to . eql ( '@bar' ) ;
58+ expect ( root . nodes [ 1 ] . value ) . to . eql ( '35' ) ;
59+ } ) ;
60+
61+ it ( 'parses @pagexxx like variable but not @page selector' , ( ) => {
62+ const root = parse ( '@pageWidth: "test";' ) ;
63+
64+ expect ( root . first . prop ) . to . eql ( '@pageWidth' ) ;
65+ expect ( root . first . value ) . to . eql ( '"test"' ) ;
66+
67+ const root2 = parse ( '@page-width: "test";' ) ;
68+
69+ expect ( root2 . first . prop ) . to . eql ( '@page-width' ) ;
70+ expect ( root2 . first . value ) . to . eql ( '"test"' ) ;
71+ } ) ;
72+
73+ it ( 'parses @pagexxx like variable with whitespaces between name and ":"' , ( ) => {
74+ const root = parse ( '@pageWidth :"test";' ) ;
75+
76+ expect ( root . first . prop ) . to . eql ( '@pageWidth' ) ;
77+ expect ( root . first . value ) . to . eql ( '"test"' ) ;
78+
79+ const root2 = parse ( '@page-width :"test";' ) ;
80+
81+ expect ( root2 . first . prop ) . to . eql ( '@page-width' ) ;
82+ expect ( root2 . first . value ) . to . eql ( '"test"' ) ;
83+
84+ const root3 = parse ( '@page-width : "test";' ) ;
85+
86+ expect ( root3 . first . prop ) . to . eql ( '@page-width' ) ;
87+ expect ( root3 . first . value ) . to . eql ( '"test"' ) ;
88+ } ) ;
89+
6090
6191 it ( 'parses string variables' , ( ) => {
6292 const root = parse ( '@var: "test";' ) ;
0 commit comments