Skip to content

Commit 653307c

Browse files
committed
add tests
1 parent b9de1d8 commit 653307c

File tree

1 file changed

+45
-1
lines changed

1 file changed

+45
-1
lines changed

lib/mapping/tests/generateMappingSync.spec.js

+45-1
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,56 @@ describe('mapping/generateMappingSync', () => {
3434
fs.removeSync(testCwd);
3535
});
3636

37-
it('should create the normal mapping file synchornously', () => {
37+
it('should create the normal mapping file synchronously', () => {
3838
generateMappingSync(testCwd);
3939

4040
const cssMapping = json.readToObjSync(testCwd + '/renaming_map.json', 'utf8');
4141

4242
expect(cssMapping['.jp-block']).to.equal('a');
4343
expect(cssMapping['.jp-block__element']).to.equal('b');
4444
});
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(/var CSS_NAME_MAPPING = {/);
88+
});
4589
});

0 commit comments

Comments
 (0)