Skip to content

Commit

Permalink
add test to verify unicode escapes are preserved
Browse files Browse the repository at this point in the history
  • Loading branch information
mreishus committed Jan 23, 2025
1 parent 0dd100f commit 2d7a184
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/file-css.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,29 @@ describe( 'file (css): Minify CSS files', () => {
) }% of original size`,
);
} );

test( 'GET `/file` -- CSS preserves Unicode escape sequences', async () => {
const target_url = 'tests/files/test-unicode.css';
const originalContent = await fs.readFile( target_url, 'utf8' );

const resp = await request
.get( `/file?path=${ target_url }` )
.expect( 200 )
.expect( 'Content-Type', /text\/css/ )
.expect( 'x-minify', 't' );

const minifiedText = resp.text;

// Verify Unicode escape sequence is preserved
expect( minifiedText ).toContain( '"\\f148"' );

// Also verify basic minification (whitespace removal etc)
expect( minifiedText.length ).toBeLessThan( originalContent.length );
console.info(
`Minimized CSS ${ target_url } to ${ (
( minifiedText.length / originalContent.length ) *
100
).toFixed( 2 ) }% of original size`,
);
} );
} );
4 changes: 4 additions & 0 deletions tests/files/test-unicode.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* test3.css */
.test:before {
content: "\f148";
}

0 comments on commit 2d7a184

Please sign in to comment.