1
1
// chai uses expressions for validation
2
2
/* eslint no-unused-expressions: 0 */
3
3
4
+ import * as fs from 'fs' ;
5
+ import * as path from 'path' ;
4
6
import { expect } from 'chai' ;
5
7
import parse from '../../lib/less-parse' ;
6
8
@@ -13,37 +15,48 @@ describe('Parser', () => {
13
15
expect ( root . first . value ) . to . eql ( '1' ) ;
14
16
} ) ;
15
17
16
- it ( 'parses variables with whitespaces between name and ":"' , ( ) => {
17
- let root = parse ( '@onespace : 42;' ) ;
18
-
19
- expect ( root . first . prop ) . to . eql ( '@onespace' ) ;
20
- expect ( root . first . value ) . to . eql ( '42' ) ;
21
- } ) ;
22
-
23
- it ( 'parses variables with no whitespace between ":" and value' , ( ) => {
24
- const root = parse ( '@var :42;' ) ;
25
-
26
- expect ( root . first . prop ) . to . eql ( '@var' ) ;
27
- expect ( root . first . value ) . to . eql ( '42' ) ;
28
- } ) ;
29
-
30
- it ( 'parses mutliple variables with whitespaces between name and ":"' , ( ) => {
31
- const root = parse ( '@foo : 42; @bar : 35;' ) ;
18
+ // sanity check from issue #99
19
+ it ( 'should not fail wikimedia sanity check' , ( ) => {
20
+ const code = fs . readFileSync ( path . join ( __dirname , '../../../test/integration/ext.cx.dashboard.less' ) , 'utf-8' ) ;
21
+ const root = parse ( code ) ;
32
22
33
- expect ( root . first . prop ) . to . eql ( '@foo' ) ;
34
- expect ( root . first . value ) . to . eql ( '42' ) ;
35
- expect ( root . nodes [ 1 ] . prop ) . to . eql ( '@bar' ) ;
36
- expect ( root . nodes [ 1 ] . value ) . to . eql ( '35' ) ;
23
+ expect ( root . first . type ) . to . eql ( 'import' ) ;
37
24
} ) ;
38
25
39
- it ( 'parses multiple variables with no whitespace between ":" and value' , ( ) => {
40
- const root = parse ( '@foo :42; @bar :35' ) ;
41
-
42
- expect ( root . first . prop ) . to . eql ( '@foo' ) ;
43
- expect ( root . first . value ) . to . eql ( '42' ) ;
44
- expect ( root . nodes [ 1 ] . prop ) . to . eql ( '@bar' ) ;
45
- expect ( root . nodes [ 1 ] . value ) . to . eql ( '35' ) ;
46
- } ) ;
26
+ // #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
+ // });
33
+
34
+ // #98 was merged to resolve this but broke other scenarios
35
+ // 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
+ // });
47
60
48
61
it ( 'parses string variables' , ( ) => {
49
62
const root = parse ( '@var: "test";' ) ;
0 commit comments