Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove depth limit from chokidar options #1697

Merged
merged 9 commits into from
Mar 21, 2019
Merged
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.