Skip to content

Commit

Permalink
feat: relax depth limit from chokidar for content base (#1697)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcofugaro authored and evilebottnawi committed Mar 21, 2019
1 parent 09de43e commit 7ea9ab9
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 2 deletions.
1 change: 0 additions & 1 deletion lib/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,6 @@ class Server {
ignoreInitial: true,
persistent: true,
followSymlinks: false,
depth: 0,
atomic: false,
alwaysStat: true,
ignorePermissionErrors: true,
Expand Down
63 changes: 62 additions & 1 deletion test/ContentBase.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const path = require('path');
const fs = require('fs');
const request = require('supertest');
const helper = require('./helper');
const config = require('./fixtures/contentbase-config/webpack.config');
Expand All @@ -17,27 +18,51 @@ const contentBaseOther = path.join(
describe('ContentBase', () => {
let server;
let req;
afterEach(helper.close);

describe('to directory', () => {
const nestedFile = path.join(contentBasePublic, 'assets/example.txt');

jest.setTimeout(30000);

beforeAll((done) => {
server = helper.start(
config,
{
contentBase: contentBasePublic,
watchContentBase: true,
},
done
);
req = request(server.app);
});

afterAll((done) => {
helper.close(() => {
done();
});
fs.truncateSync(nestedFile);
});

it('Request to index', (done) => {
req.get('/').expect(200, /Heyo/, done);
});

it('Request to other file', (done) => {
req.get('/other.html').expect(200, /Other html/, done);
});

it('Watches folder recursively', (done) => {
// chokidar emitted a change,
// meaning it watched the file correctly
server.contentBaseWatchers[0].on('change', () => {
done();
});

// change a file manually
setTimeout(() => {
fs.writeFileSync(nestedFile, 'Heyo', 'utf8');
}, 1000);
});
});

describe('to directories', () => {
Expand All @@ -52,6 +77,12 @@ describe('ContentBase', () => {
req = request(server.app);
});

afterAll((done) => {
helper.close(() => {
done();
});
});

it('Request to first directory', (done) => {
req.get('/').expect(200, /Heyo/, done);
});
Expand All @@ -73,6 +104,12 @@ describe('ContentBase', () => {
req = request(server.app);
});

afterAll((done) => {
helper.close(() => {
done();
});
});

it('Request to page', (done) => {
req
.get('/other.html')
Expand All @@ -93,6 +130,12 @@ describe('ContentBase', () => {
req = request(server.app);
});

afterAll((done) => {
helper.close(() => {
done();
});
});

it('Request to page', (done) => {
req
.get('/foo.html')
Expand All @@ -117,6 +160,12 @@ describe('ContentBase', () => {
req = request(server.app);
});

afterAll((done) => {
helper.close(() => {
done();
});
});

it('Request to page', (done) => {
req.get('/other.html').expect(200, done);
});
Expand All @@ -137,6 +186,12 @@ describe('ContentBase', () => {
req = request(server.app);
});

afterAll((done) => {
helper.close(() => {
done();
});
});

it('Request to page', (done) => {
req.get('/other.html').expect(404, done);
});
Expand All @@ -154,6 +209,12 @@ describe('ContentBase', () => {
req = request(server.app);
});

afterAll((done) => {
helper.close(() => {
done();
});
});

it('Request foo.wasm', (done) => {
req.get('/foo.wasm').expect('Content-Type', 'application/wasm', done);
});
Expand Down
Empty file.

0 comments on commit 7ea9ab9

Please # to comment.