Fix CSS tests (#839)

* Fix CSS tests

* Revamp

* -

* fix failing test

* add test for minifyCss with fixtures & snapshot

* remove unintended addition

* simplify the test.css
This commit is contained in:
Yangshun Tay 2018-07-10 10:42:32 -07:00 committed by GitHub
parent 8cd4b4fca6
commit 4267337fb0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 178 additions and 88 deletions

View file

@ -4,9 +4,10 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
const cssnano = require('cssnano');
const path = require('path');
const escapeStringRegexp = require('escape-string-regexp');
const env = require('./env.js');
// Return the subdirectory path from a reference directory
// Example:
@ -29,6 +30,7 @@ function getLanguage(file, refDir) {
const match = regexSubFolder.exec(file);
// Avoid misinterpreting subdirectory as language
const env = require('./env.js');
if (match && env.translation.enabled) {
const enabledLanguages = env.translation
.enabledLanguages()
@ -40,7 +42,17 @@ function getLanguage(file, refDir) {
return null;
}
function minifyCss(cssContent) {
return cssnano
.process(cssContent, {
preset: 'default',
zindex: false,
})
.then(result => result.css);
}
module.exports = {
getSubDir,
getLanguage,
minifyCss,
};