Skip to content

Commit

Permalink
add timing information to css test
Browse files Browse the repository at this point in the history
  • Loading branch information
mreishus committed Jan 23, 2025
1 parent 2d7a184 commit 000f69a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tests/file-css.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ describe( 'file (css): Minify CSS files', () => {
const target_url = 'tests/files/bootstrap.css';
const originalContent = await fs.readFile( target_url, 'utf8' );

const startTime = process.hrtime();
const resp = await request
.get( `/file?path=${ target_url }` )
.expect( 200 )
.expect( 'Content-Type', /text\/css/ )
.expect( 'x-minify', 't' );
const [ seconds, nanoseconds ] = process.hrtime( startTime );
const milliseconds = seconds * 1000 + nanoseconds / 1000000;

const minifiedText = resp.text;

Expand All @@ -26,19 +29,22 @@ describe( 'file (css): Minify CSS files', () => {
console.info(
`Minimized CSS ${ target_url } to ${ ( ( minifiedSize / originalSize ) * 100 ).toFixed(
2,
) }% of original size`,
) }% of original size in ${ milliseconds.toFixed( 2 ) }ms`,
);
} );

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 startTime = process.hrtime();
const resp = await request
.get( `/file?path=${ target_url }` )
.expect( 200 )
.expect( 'Content-Type', /text\/css/ )
.expect( 'x-minify', 't' );
const [ seconds, nanoseconds ] = process.hrtime( startTime );
const milliseconds = seconds * 1000 + nanoseconds / 1000000;

const minifiedText = resp.text;

Expand All @@ -51,7 +57,7 @@ describe( 'file (css): Minify CSS files', () => {
`Minimized CSS ${ target_url } to ${ (
( minifiedText.length / originalContent.length ) *
100
).toFixed( 2 ) }% of original size`,
).toFixed( 2 ) }% of original size in ${ milliseconds.toFixed( 2 ) }ms`,
);
} );
} );

0 comments on commit 000f69a

Please sign in to comment.