@@ -6,6 +6,9 @@ import { TestCLI as CLI } from "./TestCLI";
66function fixture ( ...relativePathSegments : Array < string > ) : string {
77 return path . resolve ( __dirname , ".." , ".." , "test" , "fixtures" , ...relativePathSegments ) ;
88}
9+ function relFixture ( ...relativePathSegments : Array < string > ) : string {
10+ return path . relative ( process . cwd ( ) , fixture ( ...relativePathSegments ) ) ;
11+ }
912
1013function distFile ( ...relativePathSegments : Array < string > ) : string {
1114 return path . resolve ( __dirname , ".." , ...relativePathSegments ) ;
@@ -15,13 +18,19 @@ describe("validate", () => {
1518 it ( "can check syntax for a valid block file" , async ( ) => {
1619 let cli = new CLI ( ) ;
1720 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` ) ;
1922 assert . equal ( cli . exitCode , 0 ) ;
2023 } ) ;
2124 it ( "can check syntax for a bad block file" , async ( ) => {
2225 let cli = new CLI ( ) ;
2326 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` ) ;
2534 assert . equal ( cli . exitCode , 1 ) ;
2635 } ) ;
2736} ) ;
@@ -30,13 +39,13 @@ describe("validate with preprocessors", () => {
3039 it ( "can check syntax for a valid block file" , async ( ) => {
3140 let cli = new CLI ( ) ;
3241 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` ) ;
3443 assert . equal ( cli . exitCode , 0 ) ;
3544 } ) ;
3645 it ( "can check syntax for a bad block file" , async ( ) => {
3746 let cli = new CLI ( ) ;
3847 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` ) ;
4049 assert . equal ( cli . exitCode , 1 ) ;
4150 } ) ;
4251} ) ;
0 commit comments