@@ -33,4 +33,89 @@ describe('cli', function () {
33
33
} ) ;
34
34
35
35
} ) ;
36
+
37
+ // Test custom config path
38
+
39
+ it ( 'should return JSON from a custom config' , function ( done ) {
40
+ var command = 'sass-lint -c tests/yml/.json-lint.yml tests/sass/cli.scss --verbose' ;
41
+
42
+ childProcess . exec ( command , function ( err , stdout ) {
43
+
44
+ if ( err ) {
45
+ return done ( err ) ;
46
+ }
47
+ else {
48
+ try {
49
+ JSON . parse ( stdout ) ;
50
+ return done ( ) ;
51
+ }
52
+ catch ( e ) {
53
+ return done ( new Error ( 'Not JSON' ) ) ;
54
+ }
55
+ }
56
+ } ) ;
57
+ } ) ;
58
+
59
+ // Test 0 errors/warnings when rules set to 0 in config
60
+
61
+ it ( 'should return no errors/warnings' , function ( done ) {
62
+ var command = 'sass-lint -c tests/yml/.json-lint.yml tests/sass/cli.scss --verbose' ;
63
+
64
+ childProcess . exec ( command , function ( err , stdout ) {
65
+
66
+ var result = '' ;
67
+
68
+ if ( err ) {
69
+ return done ( err ) ;
70
+ }
71
+
72
+ else {
73
+ try {
74
+ result = JSON . parse ( stdout ) ;
75
+ }
76
+ catch ( e ) {
77
+ return done ( new Error ( 'Not JSON' ) ) ;
78
+ }
79
+
80
+ if ( result [ 0 ] . warningCount === 0 && result [ 0 ] . errorCount === 0 ) {
81
+ return done ( ) ;
82
+ }
83
+ else {
84
+ return done ( new Error ( 'warnings/errors were returned' ) ) ;
85
+ }
86
+
87
+ }
88
+ } ) ;
89
+ } ) ;
90
+
91
+ // Test 1 warning when rules set to 0 in config
92
+
93
+ it ( 'should return a warning' , function ( done ) {
94
+ var command = 'sass-lint -c tests/yml/.color-keyword-errors.yml tests/sass/cli.scss --verbose' ;
95
+
96
+ childProcess . exec ( command , function ( err , stdout ) {
97
+
98
+ var result = '' ;
99
+
100
+ if ( err ) {
101
+ return done ( err ) ;
102
+ }
103
+
104
+ else {
105
+ try {
106
+ result = JSON . parse ( stdout ) ;
107
+ }
108
+ catch ( e ) {
109
+ return done ( new Error ( 'Not JSON' ) ) ;
110
+ }
111
+
112
+ if ( result [ 0 ] . warningCount === 1 && result [ 0 ] . errorCount === 0 ) {
113
+ return done ( ) ;
114
+ }
115
+ else {
116
+ return done ( new Error ( 'warnings/errors were expected to be returned but weren\'t' ) ) ;
117
+ }
118
+ }
119
+ } ) ;
120
+ } ) ;
36
121
} ) ;
0 commit comments