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