@@ -5,6 +5,78 @@ var gulp = require('gulp'),
5
5
parser = require ( '../lib/modules/parser' ) ;
6
6
7
7
describe ( 'Parser' , function ( ) {
8
+ describe ( 'variable finding' , function ( ) {
9
+ describe ( 'SCSS syntax' , function ( ) {
10
+ it ( 'should return all used variables' , function ( ) {
11
+ var str = multiline ( function ( ) {
12
+ /*
13
+ color: $mycolor1;
14
+ .testStyle {
15
+ border: 1px solid $mycolor2;
16
+ }
17
+ .testStyle2 {
18
+ background-color: $mycolor3;
19
+ }
20
+ */
21
+ } ) ,
22
+ result = [
23
+ 'mycolor1' , 'mycolor2' , 'mycolor3'
24
+ ]
25
+ expect ( parser . findVariables ( str ) ) . eql ( result ) ;
26
+ } ) ;
27
+
28
+ it ( 'should not return new variable definitions' , function ( ) {
29
+ var str = multiline ( function ( ) {
30
+ /*
31
+ $mycolor: #00ff00;
32
+ .testStyle {
33
+ color: $mycolor2;
34
+ }
35
+ */
36
+ } ) ,
37
+ result = [
38
+ 'mycolor2'
39
+ ]
40
+ expect ( parser . findVariables ( str ) ) . eql ( result ) ;
41
+ } ) ;
42
+ } ) ;
43
+
44
+ describe ( 'LESS syntax' , function ( ) {
45
+ it ( 'should return all used variables' , function ( ) {
46
+ var str = multiline ( function ( ) {
47
+ /*
48
+ color: @mycolor1;
49
+ .testStyle {
50
+ border: 1px solid @mycolor 2;
51
+ }
52
+ .testStyle2 {
53
+ background-color: @mycolor 3;
54
+ }
55
+ */
56
+ } ) ,
57
+ result = [
58
+ 'mycolor1' , 'mycolor2' , 'mycolor3'
59
+ ]
60
+ expect ( parser . findVariables ( str , 'less' ) ) . eql ( result ) ;
61
+ } ) ;
62
+
63
+ it ( 'should not return new variable definitions' , function ( ) {
64
+ var str = multiline ( function ( ) {
65
+ /*
66
+ @mycolor : #00ff00;
67
+ .testStyle {
68
+ color: @mycolor 2;
69
+ }
70
+ */
71
+ } ) ,
72
+ result = [
73
+ 'mycolor2'
74
+ ]
75
+ expect ( parser . findVariables ( str , 'less' ) ) . eql ( result ) ;
76
+ } ) ;
77
+ } ) ;
78
+ } ) ;
79
+
8
80
describe ( 'variable parser' , function ( ) {
9
81
describe ( 'SCSS syntax' , function ( ) {
10
82
it ( 'should parse basic variables' , function ( ) {
0 commit comments