From 54a150f1abb81b56fe90f6033a0a36cc32182fb1 Mon Sep 17 00:00:00 2001 From: Jasper De Moor Date: Tue, 29 Jan 2019 08:56:41 +0100 Subject: [PATCH 1/3] refactor htmlnano tests to use filesize instead of linebreaks --- packages/core/integration-tests/test/html.js | 42 ++++++++++++-------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/packages/core/integration-tests/test/html.js b/packages/core/integration-tests/test/html.js index ed3962951e4..7c86437d559 100644 --- a/packages/core/integration-tests/test/html.js +++ b/packages/core/integration-tests/test/html.js @@ -3,7 +3,7 @@ const fs = require('@parcel/fs'); const {bundle, assertBundleTree} = require('./utils'); const path = require('path'); -describe('html', function() { +describe.only('html', function() { it('should support bundling HTML', async function() { let b = await bundle(path.join(__dirname, '/integration/html/index.html')); @@ -280,16 +280,20 @@ describe('html', function() { }); it('should minify HTML in production mode', async function() { - await bundle(path.join(__dirname, '/integration/htmlnano/index.html'), { + let inputFile = path.join(__dirname, '/integration/htmlnano/index.html'); + await bundle(inputFile, { production: true }); - let html = await fs.readFile( - path.join(__dirname, '/dist/index.html'), - 'utf8' - ); + let inputSize = (await fs.stat(inputFile)).size; + + let outputFile = path.join(__dirname, '/dist/index.html'); + let outputSize = (await fs.stat(outputFile)).size; + + assert(inputSize > outputSize); + + let html = await fs.readFile(outputFile, 'utf8'); assert(html.includes('Other page')); - assert(!html.includes('\n')); }); it('should read .htmlnanorc and minify HTML in production mode', async function() { @@ -326,19 +330,23 @@ describe('html', function() { }); it('should not minify default values inside HTML in production mode', async function() { - await bundle( - path.join(__dirname, '/integration/htmlnano-defaults-form/index.html'), - { - production: true - } + let inputFile = path.join( + __dirname, + '/integration/htmlnano-defaults-form/index.html' ); + await bundle(inputFile, { + production: true + }); - let html = await fs.readFile( - path.join(__dirname, '/dist/index.html'), - 'utf8' - ); + let inputSize = (await fs.stat(inputFile)).size; + + let outputFile = path.join(__dirname, '/dist/index.html'); + let outputSize = (await fs.stat(outputFile)).size; + + assert(inputSize > outputSize); + + let html = await fs.readFile(outputFile, 'utf8'); assert(html.includes('')); - assert(!html.includes('\n')); }); it('should not prepend the public path to assets with remote URLs', async function() { From a2dde19409c64d2cab86adc43ab900dbba8d2fa5 Mon Sep 17 00:00:00 2001 From: Jasper De Moor Date: Tue, 29 Jan 2019 18:14:49 +0100 Subject: [PATCH 2/3] remove .only --- packages/core/integration-tests/test/html.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/integration-tests/test/html.js b/packages/core/integration-tests/test/html.js index 7c86437d559..c498e84fc41 100644 --- a/packages/core/integration-tests/test/html.js +++ b/packages/core/integration-tests/test/html.js @@ -3,7 +3,7 @@ const fs = require('@parcel/fs'); const {bundle, assertBundleTree} = require('./utils'); const path = require('path'); -describe.only('html', function() { +describe('html', function() { it('should support bundling HTML', async function() { let b = await bundle(path.join(__dirname, '/integration/html/index.html')); From 9a88f0b54dfb603ba0a0579039a6c14e963129c0 Mon Sep 17 00:00:00 2001 From: Jasper De Moor Date: Tue, 29 Jan 2019 20:38:09 +0100 Subject: [PATCH 3/3] not sure why this happened but fix linting issue --- packages/core/parcel-bundler/test/sourcemaps.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/core/parcel-bundler/test/sourcemaps.js b/packages/core/parcel-bundler/test/sourcemaps.js index 8e6b41cbea4..075a63415c5 100644 --- a/packages/core/parcel-bundler/test/sourcemaps.js +++ b/packages/core/parcel-bundler/test/sourcemaps.js @@ -1,5 +1,4 @@ const assert = require('assert'); -const fs = require('@parcel/fs'); const SourceMap = require('../src/SourceMap'); describe('sourcemaps', function() {