Skip to content

Commit 1347c4b

Browse files
committed
improve coverage
1 parent c39eae2 commit 1347c4b

File tree

1 file changed

+65
-7
lines changed

1 file changed

+65
-7
lines changed

test/index.spec.js

Lines changed: 65 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,19 @@ describe('app.js', () => {
107107
});
108108
});
109109

110+
it('should process css files without options', done => {
111+
app.processCss(fixturesCwd + '/**/*.css', (err, data) => {
112+
let newFile = fs.readFileSync('./rcs/' + fixturesCwd + '/style.css', 'utf8');
113+
let expectedFile = fs.readFileSync(resultsCwd + '/style.css', 'utf8');
114+
115+
expect(err).to.not.exist;
116+
expect(newFile).to.equal(expectedFile);
117+
118+
fs.removeSync('./rcs');
119+
120+
done();
121+
});
122+
});
110123

111124
it('should process css files and flatten the directories', done => {
112125
app.process('**/*.css', {
@@ -194,7 +207,7 @@ describe('app.js', () => {
194207
});
195208
});
196209

197-
it('should create the normal library file', done => {
210+
it('should create the normal mapping file', done => {
198211
app.generateMapping(testCwd, (err, data) => {
199212
const cssMapping = json.readToObjSync(testCwd + '/renaming_map.json', 'utf8');
200213

@@ -207,23 +220,23 @@ describe('app.js', () => {
207220
});
208221
});
209222

210-
it('should create the minified library file', done => {
223+
it('should create the minified mapping file', done => {
211224
app.generateMapping(testCwd, {
212225
cssMapping: false,
213226
cssMappingMin: true
214227
}, (err, data) => {
215-
const cssMapping = json.readToObjSync(testCwd + '/renaming_map_min.json', 'utf8');
228+
const cssMappingMin = json.readToObjSync(testCwd + '/renaming_map_min.json', 'utf8');
216229

217230
expect(err).to.not.exist;
218-
expect(cssMapping['.a']).to.equal('jp-block');
219-
expect(cssMapping['.b']).to.equal('jp-block__element');
231+
expect(cssMappingMin['.a']).to.equal('jp-block');
232+
expect(cssMappingMin['.b']).to.equal('jp-block__element');
220233

221234
done();
222235

223236
});
224237
});
225238

226-
it('should create the extended normal library file', done => {
239+
it('should create the extended normal mapping file', done => {
227240
app.generateMapping(testCwd, {
228241
extended: true
229242
}, (err, data) => {
@@ -239,7 +252,7 @@ describe('app.js', () => {
239252
});
240253
});
241254

242-
it('should create the minified library file', done => {
255+
it('should create the minified mapping file', done => {
243256
app.generateMapping(testCwd, {
244257
cssMapping: false,
245258
cssMappingMin: true,
@@ -257,6 +270,51 @@ describe('app.js', () => {
257270
});
258271
});
259272

273+
it('should create the custom names minified mapping file', done => {
274+
app.generateMapping(testCwd, {
275+
cssMapping: 'custom-name'
276+
}, (err, data) => {
277+
const cssMapping = json.readToObjSync(testCwd + '/custom-name.json', 'utf8');
278+
279+
expect(err).to.not.exist;
280+
expect(cssMapping['.jp-block']).to.equal('a');
281+
expect(cssMapping['.jp-block__element']).to.equal('b');
282+
283+
done();
284+
285+
});
286+
});
287+
288+
it('should create the minified mapping file', done => {
289+
app.generateMapping(testCwd, {
290+
cssMappingMin: 'custom-name'
291+
}, (err, data) => {
292+
const cssMappingMin = json.readToObjSync(testCwd + '/custom-name.json', 'utf8');
293+
294+
expect(err).to.not.exist;
295+
expect(cssMappingMin['.a']).to.equal('jp-block');
296+
expect(cssMappingMin['.b']).to.equal('jp-block__element');
297+
298+
done();
299+
300+
});
301+
});
302+
303+
it('should create the minified mapping js file', done => {
304+
app.generateMapping(testCwd, {
305+
json: false
306+
}, (err, data) => {
307+
const cssMapping = fs.readFileSync(testCwd + '/renaming_map.js', 'utf8');
308+
309+
expect(err).to.not.exist;
310+
expect(cssMapping).to.match(/var CSS_NAME_MAPPING = {/);
311+
312+
done();
313+
314+
});
315+
});
316+
317+
260318
it('should overwrite mapping files', done => {
261319
app.generateMapping(testCwd, (err, data) => {
262320
app.generateMapping(testCwd, { overwrite: true }, (err2, data) => {

0 commit comments

Comments
 (0)