Skip to content

Commit

Permalink
test: compress option (#1766)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi authored and hiroppy committed Apr 6, 2019
1 parent 919ff77 commit f61dfd4
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 16 deletions.
80 changes: 64 additions & 16 deletions test/Compress.test.js
Expand Up @@ -7,29 +7,77 @@

const request = require('supertest');
const helper = require('./helper');
const config = require('./fixtures/simple-config/webpack.config');
const config = require('./fixtures/simple-config-other/webpack.config');

describe('Compress', () => {
let server;
let req;

beforeAll((done) => {
server = helper.start(
config,
{
compress: true,
},
done
);
req = request(server.app);
describe('undefined', () => {
beforeAll((done) => {
server = helper.start(config, {}, done);
req = request(server.app);
});

afterAll(helper.close);

it('request to bundle file', (done) => {
req
.get('/main.js')
.expect((res) => {
if (res.header['content-encoding']) {
throw new Error('Expected `content-encoding` header is undefined.');
}
})
.expect(200, done);
});
});

afterAll(helper.close);
describe('true', () => {
beforeAll((done) => {
server = helper.start(
config,
{
compress: true,
},
done
);
req = request(server.app);
});

afterAll(helper.close);

it('request to bundle file', (done) => {
req
.get('/main.js')
.expect('Content-Encoding', 'gzip')
.expect(200, done);
});
});

describe('false', () => {
beforeAll((done) => {
server = helper.start(
config,
{
compress: false,
},
done
);
req = request(server.app);
});

afterAll(helper.close);

it.skip('request to bundle file', (done) => {
req
.get('/bundle.js')
.expect('Content-Encoding', 'gzip')
.expect(200, done);
it('request to bundle file', (done) => {
req
.get('/main.js')
.expect((res) => {
if (res.header['content-encoding']) {
throw new Error('Expected `content-encoding` header is undefined.');
}
})
.expect(200, done);
});
});
});
5 changes: 5 additions & 0 deletions test/fixtures/simple-config-other/foo.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions test/fixtures/simple-config-other/webpack.config.js
@@ -0,0 +1,11 @@
'use strict';

module.exports = {
mode: 'development',
context: __dirname,
entry: './foo.js',
output: {
path: '/',
},
node: false,
};

0 comments on commit f61dfd4

Please sign in to comment.