|
7 | 7 |
|
8 | 8 | const request = require('supertest'); |
9 | 9 | const helper = require('./helper'); |
10 | | -const config = require('./fixtures/simple-config/webpack.config'); |
| 10 | +const config = require('./fixtures/simple-config-other/webpack.config'); |
11 | 11 |
|
12 | 12 | describe('Compress', () => { |
13 | 13 | let server; |
14 | 14 | let req; |
15 | 15 |
|
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 | + }); |
25 | 34 | }); |
26 | 35 |
|
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); |
28 | 71 |
|
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 | + }); |
34 | 82 | }); |
35 | 83 | }); |
0 commit comments