Skip to content

Commit

Permalink
Refactor htmlnano tests to test for filesize (#2591)
Browse files Browse the repository at this point in the history
  • Loading branch information
DeMoorJasper authored and devongovett committed Jan 30, 2019
1 parent bdc044a commit 9abe11e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
40 changes: 24 additions & 16 deletions packages/core/integration-tests/test/html.js
Expand Up @@ -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() {
Expand Down Expand Up @@ -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('<input type="text">'));
assert(!html.includes('\n'));
});

it('should not prepend the public path to assets with remote URLs', async function() {
Expand Down
1 change: 0 additions & 1 deletion 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() {
Expand Down

0 comments on commit 9abe11e

Please sign in to comment.