@@ -2,11 +2,67 @@ const util = require('./test-util');
22
33const assertSuccess = util . assertSuccess ;
44const assertSingleFailure = util . assertSingleFailure ;
5+ const assertFailure = util . assertFailure ;
56const fixture = util . fixture ;
67
78describe ( 'property validation' , ( ) => {
89 it ( 'accepts custom properties that begin with the component name' , ( ) => {
910 assertSuccess ( fixture ( 'properties-valid' ) ) ;
11+ assertSuccess ( fixture ( 'properties-bem-valid' ) , { preset : 'bem' } ) ;
12+ } ) ;
13+
14+ it ( 'accepts custom properties that implicitly begin with the component name' , ( ) => {
15+ const filenameBlock = `${ process . cwd ( ) } /component-name.css` ;
16+ assertSuccess (
17+ fixture ( 'implicit-component-properties-valid' ) ,
18+ { preset : 'bem' , implicitComponents : true } ,
19+ null ,
20+ filenameBlock
21+ ) ;
22+ } ) ;
23+
24+ it ( 'accepts custom properties that implicitly begin with the component name in bem files' , ( ) => {
25+ const filenameMod = `${ process . cwd ( ) } /component-name_mod.css` ;
26+ assertSuccess (
27+ fixture ( 'implicit-component-mod-properties-valid' ) ,
28+ { preset : 'bem' , implicitComponents : true } ,
29+ null ,
30+ filenameMod
31+ ) ;
32+
33+ const filenameElement = `${ process . cwd ( ) } /component-name__element.css` ;
34+ assertSuccess (
35+ fixture ( 'implicit-component-element-properties-valid' ) ,
36+ { preset : 'bem' , implicitComponents : true } ,
37+ null ,
38+ filenameElement
39+ ) ;
40+ } ) ;
41+
42+ it ( 'rejects custom properties that do not begin with the implicit component name in bem files' , ( ) => {
43+ const filenameBlock = `${ process . cwd ( ) } /component-name-invalid.css` ;
44+ assertFailure (
45+ fixture ( 'implicit-component-properties-valid' ) ,
46+ { preset : 'bem' , implicitComponents : true } ,
47+ null ,
48+ filenameBlock
49+ ) ;
50+
51+ const filenameMod = `${ process . cwd ( ) } /component-name-invalid_mod.css` ;
52+ assertFailure (
53+ fixture ( 'implicit-component-mod-properties-valid' ) ,
54+ { preset : 'bem' , implicitComponents : true } ,
55+ null ,
56+ filenameMod
57+ ) ;
58+
59+ const filenameElement = `${ process . cwd ( ) } /component-name-invalid__element.css` ;
60+ assertFailure (
61+ fixture ( 'implicit-component-element-properties-valid' ) ,
62+ { preset : 'bem' , implicitComponents : true } ,
63+ null ,
64+ filenameElement
65+ ) ;
1066 } ) ;
1167
1268 const invDef = '/** @define InvalidRootVars */' ;
0 commit comments