From 8ab263ef69078106f0860017a4581836306b205b Mon Sep 17 00:00:00 2001 From: Gabriel Grubba Date: Mon, 16 Jan 2023 20:14:57 -0300 Subject: [PATCH 1/3] docs: minifier-css, minifyCss is now async --- docs/history.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/history.md b/docs/history.md index ff70cad47b..37da9431df 100644 --- a/docs/history.md +++ b/docs/history.md @@ -64,6 +64,9 @@ * `oauth2`: - `OAuth._requestHandlers['2']` is now async. +* `minifier-css`: + - `minifyCss` is now async. + * `webapp`: - `WebAppInternals.getBoilerplate` is now async. From 0877d8113f066b318124e151aed02674127c7d93 Mon Sep 17 00:00:00 2001 From: Gabriel Grubba Date: Mon, 16 Jan 2023 20:15:19 -0300 Subject: [PATCH 2/3] chore: made minifyCss into async --- packages/minifier-css/minifier.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/minifier-css/minifier.js b/packages/minifier-css/minifier.js index a4c662e9e5..c5f3d2d97e 100644 --- a/packages/minifier-css/minifier.js +++ b/packages/minifier-css/minifier.js @@ -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} Array containing the minified CSS. */ minifyCss(cssText) { - return Promise.await(CssTools.minifyCssAsync(cssText)); + return CssTools.minifyCssAsync(cssText); }, /** From cd8f16591dae2e54f358b82beef920d272af687b Mon Sep 17 00:00:00 2001 From: Gabriel Grubba Date: Mon, 16 Jan 2023 20:15:37 -0300 Subject: [PATCH 3/3] tests: solved simple CSS minification --- packages/minifier-css/minifier-tests.js | 30 +++++++++++++------------ 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/packages/minifier-css/minifier-tests.js b/packages/minifier-css/minifier-tests.js index 2901ab9020..94254010f0 100644 --- a/packages/minifier-css/minifier-tests.js +++ b/packages/minifier-css/minifier-tests.js @@ -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',