@@ -7,17 +7,36 @@ function fixture(...relativePathSegments: Array<string>): string {
7
7
return path . resolve ( __dirname , ".." , ".." , "test" , "fixtures" , ...relativePathSegments ) ;
8
8
}
9
9
10
- describe ( "CLI" , ( ) => {
10
+ function distFile ( ...relativePathSegments : Array < string > ) : string {
11
+ return path . resolve ( __dirname , ".." , ...relativePathSegments ) ;
12
+ }
13
+
14
+ describe ( "validate" , ( ) => {
15
+ it ( "can check syntax for a valid block file" , async ( ) => {
16
+ let cli = new CLI ( ) ;
17
+ await cli . run ( [ "validate" , fixture ( "basic/simple.block.css" ) ] ) ;
18
+ assert . equal ( cli . output , `ok\t${ fixture ( "basic/simple.block.css" ) } \n` ) ;
19
+ assert . equal ( cli . exitCode , 0 ) ;
20
+ } ) ;
21
+ it ( "can check syntax for a bad block file" , async ( ) => {
22
+ let cli = new CLI ( ) ;
23
+ await cli . run ( [ "validate" , fixture ( "basic/error.block.css" ) ] ) ;
24
+ assert . equal ( cli . output , `error\t${ fixture ( "basic/error.block.css" ) } :1:5 Two distinct classes cannot be selected on the same element: .foo.bar\n` ) ;
25
+ assert . equal ( cli . exitCode , 1 ) ;
26
+ } ) ;
27
+ } ) ;
28
+
29
+ describe ( "validate with preprocessors" , ( ) => {
11
30
it ( "can check syntax for a valid block file" , async ( ) => {
12
31
let cli = new CLI ( ) ;
13
- await cli . run ( [ "validate" , fixture ( "simple.block.css " ) ] ) ;
14
- assert . equal ( cli . output , `ok\t${ fixture ( "simple.block.css " ) } \n` ) ;
32
+ await cli . run ( [ "validate" , "--preprocessors" , distFile ( "test/preprocessors" ) , fixture ( "scss/ simple.block.scss " ) ] ) ;
33
+ assert . equal ( cli . output , `ok\t${ fixture ( "scss/ simple.block.scss " ) } \n` ) ;
15
34
assert . equal ( cli . exitCode , 0 ) ;
16
35
} ) ;
17
36
it ( "can check syntax for a bad block file" , async ( ) => {
18
37
let cli = new CLI ( ) ;
19
- await cli . run ( [ "validate" , fixture ( "error.block.css " ) ] ) ;
20
- assert . equal ( cli . output , `error\t${ fixture ( "error.block.css " ) } :1 :5 Two distinct classes cannot be selected on the same element: .foo.bar\n` ) ;
38
+ await cli . run ( [ "validate" , "--preprocessors" , distFile ( "test/preprocessors" ) , fixture ( "scss/ error.block.scss " ) ] ) ;
39
+ assert . equal ( cli . output , `error\t${ fixture ( "scss/ error.block.scss " ) } :5 :5 Two distinct classes cannot be selected on the same element: .foo.bar\n` ) ;
21
40
assert . equal ( cli . exitCode , 1 ) ;
22
41
} ) ;
23
42
} ) ;
0 commit comments