@@ -34,12 +34,56 @@ describe('mapping/generateMappingSync', () => {
34
34
fs . removeSync ( testCwd ) ;
35
35
} ) ;
36
36
37
- it ( 'should create the normal mapping file synchornously ' , ( ) => {
37
+ it ( 'should create the normal mapping file synchronously ' , ( ) => {
38
38
generateMappingSync ( testCwd ) ;
39
39
40
40
const cssMapping = json . readToObjSync ( testCwd + '/renaming_map.json' , 'utf8' ) ;
41
41
42
42
expect ( cssMapping [ '.jp-block' ] ) . to . equal ( 'a' ) ;
43
43
expect ( cssMapping [ '.jp-block__element' ] ) . to . equal ( 'b' ) ;
44
44
} ) ;
45
+
46
+ it ( 'should create the minified mapping file synchronously' , ( ) => {
47
+ generateMappingSync ( testCwd , {
48
+ cssMapping : false ,
49
+ cssMappingMin : true
50
+ } ) ;
51
+
52
+ const cssMappingMin = json . readToObjSync ( testCwd + '/renaming_map_min.json' , 'utf8' ) ;
53
+
54
+ expect ( cssMappingMin [ '.a' ] ) . to . equal ( 'jp-block' ) ;
55
+ expect ( cssMappingMin [ '.b' ] ) . to . equal ( 'jp-block__element' ) ;
56
+ } ) ;
57
+
58
+ it ( 'should create the custom names minified mapping file synchronously' , ( ) => {
59
+ generateMappingSync ( testCwd , {
60
+ cssMapping : 'custom-name'
61
+ } ) ;
62
+
63
+ const cssMapping = json . readToObjSync ( testCwd + '/custom-name.json' , 'utf8' ) ;
64
+
65
+ expect ( cssMapping [ '.jp-block' ] ) . to . equal ( 'a' ) ;
66
+ expect ( cssMapping [ '.jp-block__element' ] ) . to . equal ( 'b' ) ;
67
+ } ) ;
68
+
69
+ it ( 'should create the minified mapping file with a custom name synchronously' , ( ) => {
70
+ generateMappingSync ( testCwd , {
71
+ cssMappingMin : 'custom-name'
72
+ } ) ;
73
+
74
+ const cssMappingMin = json . readToObjSync ( testCwd + '/custom-name.json' , 'utf8' ) ;
75
+
76
+ expect ( cssMappingMin [ '.a' ] ) . to . equal ( 'jp-block' ) ;
77
+ expect ( cssMappingMin [ '.b' ] ) . to . equal ( 'jp-block__element' ) ;
78
+ } ) ;
79
+
80
+ it ( 'should create the minified mapping js file synchronously' , ( ) => {
81
+ generateMappingSync ( testCwd , {
82
+ json : false
83
+ } ) ;
84
+
85
+ const cssMapping = fs . readFileSync ( testCwd + '/renaming_map.js' , 'utf8' ) ;
86
+
87
+ expect ( cssMapping ) . to . match ( / v a r C S S _ N A M E _ M A P P I N G = { / ) ;
88
+ } ) ;
45
89
} ) ;
0 commit comments