Skip to content

Commit

Permalink
test: add tests to assert if subdirectories with special characters a…
Browse files Browse the repository at this point in the history
…re served correctly (#365)
  • Loading branch information
sidharthachatterjee authored and evilebottnawi committed Jan 30, 2019
1 parent 71c3e20 commit c64a2c1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/tests/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ describe('Server', () => {
listen = listenShorthand(done);
// Hack to add a mock HMR json file to the in-memory filesystem.
instance.fileSystem.writeFileSync('/123a123412.hot-update.json', '["hi"]');

// Add a nested directory and index.html inside
instance.fileSystem.mkdirSync('/reference');
instance.fileSystem.mkdirSync('/reference/mono-v6.x.x');
instance.fileSystem.writeFileSync(
'/reference/mono-v6.x.x/index.html',
'My Index.'
);
});

after(close);
Expand Down Expand Up @@ -103,6 +111,14 @@ describe('Server', () => {
.expect(200, /My Index\./, done);
});

it('request to subdirectory without trailing slash', (done) => {
request(app)
.get('/public/reference/mono-v6.x.x')
.expect('Content-Type', 'text/html; charset=UTF-8')
.expect('Content-Length', '9')
.expect(200, /My Index\./, done);
});

it('invalid range header', (done) => {
request(app).get('/public/svg.svg')
.set('Range', 'bytes=6000-')
Expand Down
6 changes: 6 additions & 0 deletions test/tests/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,12 @@ describe('GetFilenameFromUrl', () => {
outputPath: '/test/#leadinghash',
publicPath: '/',
expected: '/test/#leadinghash/test/sample.txt'
},
{
url: '/folder-name-with-dots/mono-v6.x.x',
outputPath: '/',
publicPath: '/',
expected: '/folder-name-with-dots/mono-v6.x.x'
}
];

Expand Down

0 comments on commit c64a2c1

Please sign in to comment.