Merge branch 'release-3.0' into release-3.0-mongo-tests

This commit is contained in:
Edimar Cardoso
2023-01-17 14:47:41 -03:00
3 changed files with 21 additions and 16 deletions

View File

@@ -64,6 +64,9 @@
* `oauth2`:
- `OAuth._requestHandlers['2']` is now async.
* `minifier-css`:
- `minifyCss` is now async.
* `webapp`:
- `WebAppInternals.getBoilerplate` is now async.

View File

@@ -28,59 +28,61 @@ Tinytest.add(
}
);
Tinytest.add('minifier-css - simple CSS minification', (test) => {
const checkMinified = (css, expected, desc) => {
test.equal(CssTools.minifyCss(css)[0], expected, desc);
};
Tinytest.addAsync('minifier-css - simple CSS minification', async (test) => {
const checkMinified =
async (css, expected, desc) => {
const minified = await CssTools.minifyCss(css);
test.equal(minified[0], expected, desc);
};
checkMinified(
await checkMinified(
'a \t\n{ color: red } \n',
'a{color:red}',
'whitespace check',
);
checkMinified(
await checkMinified(
'a \t\n{ color: red; margin: 1; } \n',
'a{color:red;margin:1}',
'only last one loses semicolon',
);
checkMinified(
await checkMinified(
'a \t\n{ color: red;;; margin: 1;;; } \n',
'a{color:red;margin:1}',
'more semicolons than needed',
);
checkMinified(
await checkMinified(
'a , p \t\n{ color: red; } \n',
'a,p{color:red}',
'multiple selectors',
);
checkMinified(
await checkMinified(
'body {}',
'',
'removing empty rules',
);
checkMinified(
await checkMinified(
'*.my-class { color: #fff; }',
'.my-class{color:#fff}',
'removing universal selector',
);
checkMinified(
await checkMinified(
'p > *.my-class { color: #fff; }',
'p>.my-class{color:#fff}',
'removing optional whitespace around ">" in selector',
);
checkMinified(
await checkMinified(
'p + *.my-class { color: #fff; }',
'p+.my-class{color:#fff}',
'removing optional whitespace around "+" in selector',
);
checkMinified(
await checkMinified(
'a {\n\
font:12px \'Helvetica\',"Arial",\'Nautica\';\n\
background:url("/some/nice/picture.png");\n}',
'a{font:12px Helvetica,Arial,Nautica;background:url(/some/nice/picture.png)}',
'removing quotes in font and url (if possible)',
);
checkMinified(
await checkMinified(
'/* no comments */ a { color: red; }',
'a{color:red}',
'remove comments',

View File

@@ -61,10 +61,10 @@ const CssTools = {
* Minify the passed in CSS string.
*
* @param {string} cssText CSS string to minify.
* @return {String[]} Array containing the minified CSS.
* @return {Promise<String[]>} Array containing the minified CSS.
*/
minifyCss(cssText) {
return Promise.await(CssTools.minifyCssAsync(cssText));
return CssTools.minifyCssAsync(cssText);
},
/**