Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor htmlnano tests to test for filesize #2591

Merged
merged 4 commits into from Jan 30, 2019
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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