Skip to content

Commit f61dfd4

Browse files
evilebottnawihiroppy
authored andcommitted
test: compress option (#1766)
1 parent 919ff77 commit f61dfd4

File tree

3 files changed

+80
-16
lines changed

3 files changed

+80
-16
lines changed

test/Compress.test.js

+64-16
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,77 @@
77

88
const request = require('supertest');
99
const helper = require('./helper');
10-
const config = require('./fixtures/simple-config/webpack.config');
10+
const config = require('./fixtures/simple-config-other/webpack.config');
1111

1212
describe('Compress', () => {
1313
let server;
1414
let req;
1515

16-
beforeAll((done) => {
17-
server = helper.start(
18-
config,
19-
{
20-
compress: true,
21-
},
22-
done
23-
);
24-
req = request(server.app);
16+
describe('undefined', () => {
17+
beforeAll((done) => {
18+
server = helper.start(config, {}, done);
19+
req = request(server.app);
20+
});
21+
22+
afterAll(helper.close);
23+
24+
it('request to bundle file', (done) => {
25+
req
26+
.get('/main.js')
27+
.expect((res) => {
28+
if (res.header['content-encoding']) {
29+
throw new Error('Expected `content-encoding` header is undefined.');
30+
}
31+
})
32+
.expect(200, done);
33+
});
2534
});
2635

27-
afterAll(helper.close);
36+
describe('true', () => {
37+
beforeAll((done) => {
38+
server = helper.start(
39+
config,
40+
{
41+
compress: true,
42+
},
43+
done
44+
);
45+
req = request(server.app);
46+
});
47+
48+
afterAll(helper.close);
49+
50+
it('request to bundle file', (done) => {
51+
req
52+
.get('/main.js')
53+
.expect('Content-Encoding', 'gzip')
54+
.expect(200, done);
55+
});
56+
});
57+
58+
describe('false', () => {
59+
beforeAll((done) => {
60+
server = helper.start(
61+
config,
62+
{
63+
compress: false,
64+
},
65+
done
66+
);
67+
req = request(server.app);
68+
});
69+
70+
afterAll(helper.close);
2871

29-
it.skip('request to bundle file', (done) => {
30-
req
31-
.get('/bundle.js')
32-
.expect('Content-Encoding', 'gzip')
33-
.expect(200, done);
72+
it('request to bundle file', (done) => {
73+
req
74+
.get('/main.js')
75+
.expect((res) => {
76+
if (res.header['content-encoding']) {
77+
throw new Error('Expected `content-encoding` header is undefined.');
78+
}
79+
})
80+
.expect(200, done);
81+
});
3482
});
3583
});

test/fixtures/simple-config-other/foo.js

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
'use strict';
2+
3+
module.exports = {
4+
mode: 'development',
5+
context: __dirname,
6+
entry: './foo.js',
7+
output: {
8+
path: '/',
9+
},
10+
node: false,
11+
};

0 commit comments

Comments
 (0)