2019-07-10 06:50:00 +00:00
|
|
|
import request from 'supertest';
|
|
|
|
|
|
|
|
import createServer from '../createServer.js';
|
|
|
|
|
2019-07-25 00:55:13 +00:00
|
|
|
describe('A request to browse a file', () => {
|
2019-07-10 06:50:00 +00:00
|
|
|
let server;
|
|
|
|
beforeEach(() => {
|
|
|
|
server = createServer();
|
|
|
|
});
|
|
|
|
|
2019-07-25 00:55:13 +00:00
|
|
|
describe('when the file exists', () => {
|
2019-07-10 06:50:00 +00:00
|
|
|
it('returns an HTML page', done => {
|
|
|
|
request(server)
|
2019-07-25 00:55:13 +00:00
|
|
|
.get('/browse/react@16.8.0/umd/react.production.min.js')
|
2019-07-10 06:50:00 +00:00
|
|
|
.end((err, res) => {
|
|
|
|
expect(res.statusCode).toBe(200);
|
|
|
|
expect(res.headers['content-type']).toMatch(/\btext\/html\b/);
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-07-25 00:55:13 +00:00
|
|
|
describe('when the file does not exist', () => {
|
|
|
|
it('returns a 404 HTML page', done => {
|
2019-07-10 06:50:00 +00:00
|
|
|
request(server)
|
2019-07-25 00:55:13 +00:00
|
|
|
.get('/browse/react@16.8.0/not-here.js')
|
2019-07-10 06:50:00 +00:00
|
|
|
.end((err, res) => {
|
|
|
|
expect(res.statusCode).toBe(404);
|
2019-07-25 00:55:13 +00:00
|
|
|
expect(res.headers['content-type']).toMatch(/\btext\/html\b/);
|
2019-07-10 06:50:00 +00:00
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|