Skip to content

Commit

Permalink
Add test for mimeTypes option
Browse files Browse the repository at this point in the history
  • Loading branch information
dmohns committed Mar 10, 2019
1 parent 4958bdb commit c780289
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions test/MimeTypes.test.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
'use strict';

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

describe('MimeTypes', () => {
describe('MimeTypes configuration', () => {
afterEach(helper.close);

it('remapping mime type without force should throw an error', () => {
expect(() => {
helper.start(config, {
mimeTypes: { 'text/html': ['js'] },
mimeTypes: { 'application/octet-stream': ['js'] },
});
}).toThrow(/Attempt to change mapping for/);
});
Expand All @@ -19,11 +20,39 @@ describe('MimeTypes', () => {
config,
{
mimeTypes: {
typeMap: { 'text/html': ['js'] },
typeMap: { 'application/octet-stream': ['js'] },
force: true,
},
},
done
);
});
});

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

beforeAll((done) => {
server = helper.start(
config,
{
mimeTypes: {
typeMap: { 'application/octet-stream': ['js'] },
force: true,
},
},
done
);
req = request(server.app);
});

afterAll(helper.close);

it('request to bundle file with modified mime type', (done) => {
req
.get('/main.js')
.expect('Content-Type', /application\/octet-stream/)
.expect(200, done);
});
});

0 comments on commit c780289

Please sign in to comment.