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

Upgrade tap #745

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5,531 changes: 3,881 additions & 1,650 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -19,8 +19,8 @@
],
"scripts": {
"start": "node ./bin/http-server",
"test": "tap --reporter=spec test/*.test.js",
"test-watch": "tap --reporter=spec --watch test/*.test.js"
"test": "tap --reporter=spec test/*.test.js --no-check-coverage",
"test-watch": "tap --reporter=spec --watch test/*.test.js --no-check-coverage"
},
"files": [
"lib",
Expand Down Expand Up @@ -104,7 +104,7 @@
"eslint-config-populist": "^4.2.0",
"express": "^4.17.1",
"request": "^2.88.2",
"tap": "^14.11.0"
"tap": "^15.0.10"
},
"bugs": {
"url": "https://github.com/http-party/http-server/issues"
Expand Down
4 changes: 2 additions & 2 deletions test/accept-encoding.test.js
Expand Up @@ -26,7 +26,7 @@ test('properly handles whitespace in accept-encoding', (t) => {
};

request.get(options, (err, res) => {
t.ifError(err);
t.error(err);
t.equal(res.statusCode, 200);
t.equal(res.headers['content-encoding'], 'gzip');
});
Expand Down Expand Up @@ -55,7 +55,7 @@ test('properly handles single accept-encoding entry', (t) => {
};

request.get(options, (err, res) => {
t.ifError(err);
t.error(err);
t.equal(res.statusCode, 200);
t.equal(res.headers['content-encoding'], 'gzip');
});
Expand Down
12 changes: 6 additions & 6 deletions test/cache.test.js
Expand Up @@ -22,7 +22,7 @@ test('custom cache option number', (t) => {
server.listen(0, () => {
const port = server.address().port;
request.get(`http://localhost:${port}/a.txt`, (err, res) => {
t.ifError(err);
t.error(err);
t.equal(res.statusCode, 200, 'a.txt should be found');
t.equal(res.headers['cache-control'], 'max-age=3600');
server.close(() => { t.end(); });
Expand All @@ -47,7 +47,7 @@ test('custom cache option string', (t) => {
server.listen(0, () => {
const port = server.address().port;
request.get(`http://localhost:${port}/a.txt`, (err, res) => {
t.ifError(err);
t.error(err);
t.equal(res.statusCode, 200, 'a.txt should be found');
t.equal(res.headers['cache-control'], 'max-whatever=3600');
server.close(() => { t.end(); });
Expand Down Expand Up @@ -76,12 +76,12 @@ test('custom cache option function returning a number', (t) => {
server.listen(0, () => {
const port = server.address().port;
request.get(`http://localhost:${port}/a.txt`, (err, res) => {
t.ifError(err);
t.error(err);
t.equal(res.statusCode, 200, 'a.txt should be found');
t.equal(res.headers['cache-control'], 'max-age=1');

request.get(`http://localhost:${port}/a.txt`, (err2, res2) => {
t.ifError(err2);
t.error(err2);
t.equal(res2.statusCode, 200, 'a.txt should be found');
t.equal(res2.headers['cache-control'], 'max-age=2');
server.close(() => { t.end(); });
Expand Down Expand Up @@ -111,12 +111,12 @@ test('custom cache option function returning a string', (t) => {
server.listen(0, () => {
const port = server.address().port;
request.get(`http://localhost:${port}/a.txt`, (err, res) => {
t.ifError(err);
t.error(err);
t.equal(res.statusCode, 200, 'a.txt should be found');
t.equal(res.headers['cache-control'], 'max-meh=1');

request.get(`http://localhost:${port}/a.txt`, (err2, res2) => {
t.ifError(err2);
t.error(err2);
t.equal(res2.statusCode, 200, 'a.txt should be found');
t.equal(res2.headers['cache-control'], 'max-meh=2');
server.close(() => { t.end(); });
Expand Down
2 changes: 1 addition & 1 deletion test/check-headers.js
Expand Up @@ -6,7 +6,7 @@ module.exports = (t, server, path, check) => {
const uri = `http://localhost:${port}/${path}`;

request.get({ uri }, (err, res) => {
t.ifError(err);
t.error(err);
t.equal(res.statusCode, 200);
check(t, res.headers);
});
Expand Down
2 changes: 1 addition & 1 deletion test/cli.test.js
Expand Up @@ -34,7 +34,7 @@ function checkServerIsRunning(url, msg, t, _cb) {
}

function tearDown(ps, t) {
t.tearDown(() => {
t.teardown(() => {
ps.kill('SIGTERM');
});
}
Expand Down
12 changes: 6 additions & 6 deletions test/compression.test.js
Expand Up @@ -26,7 +26,7 @@ test('serves brotli-encoded file when available', (t) => {
};

request.get(options, (err, res) => {
t.ifError(err);
t.error(err);
t.equal(res.statusCode, 200);
t.equal(res.headers['content-encoding'], 'br');
});
Expand Down Expand Up @@ -56,7 +56,7 @@ test('serves gzip-encoded file when brotli not available', (t) => {
};

request.get(options, (err, res) => {
t.ifError(err);
t.error(err);
t.equal(res.statusCode, 200);
t.equal(res.headers['content-encoding'], 'gzip');
});
Expand Down Expand Up @@ -86,7 +86,7 @@ test('serves gzip-encoded file when brotli not accepted', (t) => {
};

request.get(options, (err, res) => {
t.ifError(err);
t.error(err);
t.equal(res.statusCode, 200);
t.equal(res.headers['content-encoding'], 'gzip');
});
Expand Down Expand Up @@ -116,7 +116,7 @@ test('serves gzip-encoded file when brotli not enabled', (t) => {
};

request.get(options, (err, res) => {
t.ifError(err);
t.error(err);
t.equal(res.statusCode, 200);
t.equal(res.headers['content-encoding'], 'gzip');
});
Expand Down Expand Up @@ -146,7 +146,7 @@ test('serves unencoded file when compression not accepted', (t) => {
};

request.get(options, (err, res) => {
t.ifError(err);
t.error(err);
t.equal(res.statusCode, 200);
t.equal(res.headers['content-encoding'], undefined);
});
Expand Down Expand Up @@ -176,7 +176,7 @@ test('serves unencoded file when compression not enabled', (t) => {
};

request.get(options, (err, res) => {
t.ifError(err);
t.error(err);
t.equal(res.statusCode, 200);
t.equal(res.headers['content-encoding'], undefined);
});
Expand Down
2 changes: 1 addition & 1 deletion test/custom-content-type-file-secret.test.js
Expand Up @@ -22,7 +22,7 @@ test('custom contentType via .types file', (t) => {
server.listen(0, () => {
const port = server.address().port;
request.get(`http://localhost:${port}/custom_mime_type.opml`, (err, res) => {
t.ifError(err);
t.error(err);
t.equal(res.statusCode, 200, 'custom_mime_type.opml should be found');
t.equal(res.headers['content-type'], 'application/secret');
server.close(() => { t.end(); });
Expand Down
2 changes: 1 addition & 1 deletion test/custom-content-type-file.test.js
Expand Up @@ -38,7 +38,7 @@ test('custom contentType via .types file', (t) => {
const port = server.address().port;

request.get(`http://localhost:${port}/custom_mime_type.opml`, (err, res) => {
t.ifError(err);
t.error(err);
t.equal(res.statusCode, 200, 'custom_mime_type.opml should be found');
t.equal(res.headers['content-type'], 'application/foo');
server.close(() => { t.end(); });
Expand Down
2 changes: 1 addition & 1 deletion test/custom-content-type.test.js
Expand Up @@ -24,7 +24,7 @@ test('custom contentType', (t) => {
server.listen(0, () => {
const port = server.address().port;
request.get(`http://localhost:${port}/custom_mime_type.opml`, (err, res) => {
t.ifError(err);
t.error(err);
t.equal(res.statusCode, 200, 'custom_mime_type.opml should be found');
t.equal(res.headers['content-type'], 'application/jon');
server.close(() => { t.end(); });
Expand Down
2 changes: 1 addition & 1 deletion test/default-default-ext.test.js
Expand Up @@ -13,7 +13,7 @@ test('default defaultExt', (t) => {
server.listen(0, () => {
const port = server.address().port;
request.get(`http://localhost:${port}`, (err, res, body) => {
t.ifError(err);
t.error(err);
t.equal(res.statusCode, 200);
t.equal(eol.lf(body), 'index!!!\n');
server.close(() => { t.end(); });
Expand Down
2 changes: 1 addition & 1 deletion test/enotdir.test.js
Expand Up @@ -12,7 +12,7 @@ test('should handle ENOTDIR as 404', (t) => {
server.listen(0, () => {
const port = server.address().port;
request.get(`http://localhost:${port}/index.html/hello`, (err, res, body) => {
t.ifError(err);
t.error(err);
t.equal(res.statusCode, 404);
t.equal(body, 'File not found. :(');
});
Expand Down
2 changes: 1 addition & 1 deletion test/escaping.test.js
Expand Up @@ -12,7 +12,7 @@ test('escaping special characters', (t) => {
server.listen(0, () => {
const port = server.address().port;
request.get(`http://localhost:${port}/curimit%40gmail.com%20(40%25)`, (err, res, body) => {
t.ifError(err);
t.error(err);
t.equal(res.statusCode, 200);
t.equal(eol.lf(body), 'index!!!\n');
server.close(() => { t.end(); });
Expand Down
2 changes: 1 addition & 1 deletion test/illegal-access-date.test.js
Expand Up @@ -18,7 +18,7 @@ test('if-modified-since illegal access date', (t) => {
headers: { 'if-modified-since': '275760-09-24' },
};
request.get(opts, (err, res) => {
t.ifError(err);
t.error(err);
t.equal(res.statusCode, 200);
server.close(() => { t.end(); });
});
Expand Down
4 changes: 2 additions & 2 deletions test/main.test.js
Expand Up @@ -57,8 +57,8 @@ test('http-server main', (t) => {
requestAsync("http://localhost:8080/").then(res => {
t.ok(res);
t.equal(res.statusCode, 200);
t.includes(res.body, './file');
t.includes(res.body, './canYouSeeMe');
t.match(res.body, './file');
t.match(res.body, './canYouSeeMe');

// Custom headers
t.equal(res.headers['access-control-allow-origin'], '*');
Expand Down
2 changes: 1 addition & 1 deletion test/malformed-dir.test.js
Expand Up @@ -12,7 +12,7 @@ test('malformed showdir uri', (t) => {

server.listen(0, () => {
request.get(`http://localhost:${server.address().port}/?%`, (err, res) => {
t.ifError(err);
t.error(err);
t.equal(res.statusCode, 400);
server.close(() => { t.end(); });
});
Expand Down
2 changes: 1 addition & 1 deletion test/malformed.test.js
Expand Up @@ -12,7 +12,7 @@ test('malformed uri', (t) => {

server.listen(0, () => {
request.get(`http://localhost:${server.address().port}/%`, (err, res) => {
t.ifError(err);
t.error(err);
t.equal(res.statusCode, 400);
server.close(() => { t.end(); });
});
Expand Down
2 changes: 1 addition & 1 deletion test/process-env-port.test.js
Expand Up @@ -40,7 +40,7 @@ function startServer(url, port, t) {
});
} else {
ecstatic.on('exit', (evt) => {
t.notEqual(evt.code, 0, 'err:Running on invalid port not allowed');
t.not(evt.code, 0, 'err:Running on invalid port not allowed');
});
}
}
Expand Down
12 changes: 6 additions & 6 deletions test/range.test.js
Expand Up @@ -18,7 +18,7 @@ test('range', (t) => {
headers: { range: '3-5' },
};
request.get(opts, (err, res, body) => {
t.ifError(err);
t.error(err);
t.equal(res.statusCode, 206, 'partial content status code');
t.equal(body, 'e!!');
t.equal(parseInt(res.headers['content-length'], 10), body.length);
Expand All @@ -38,7 +38,7 @@ test('range past the end', (t) => {
headers: { range: '3-500' },
};
request.get(opts, (err, res, body) => {
t.ifError(err);
t.error(err);
t.equal(res.statusCode, 206, 'partial content status code');
t.equal(eol.lf(body), 'e!!</b>\n');
t.equal(parseInt(res.headers['content-length'], 10), body.length);
Expand All @@ -58,7 +58,7 @@ test('NaN range', (t) => {
headers: { range: 'abc-def' },
};
request.get(opts, (err, res, body) => {
t.ifError(err);
t.error(err);
t.equal(res.statusCode, 416, 'range error status code');
t.equal(body, 'Requested range not satisfiable');
});
Expand All @@ -77,7 +77,7 @@ test('flipped range', (t) => {
headers: { range: '333-222' },
};
request.get(opts, (err, res, body) => {
t.ifError(err);
t.error(err);
t.equal(res.statusCode, 416, 'range error status code');
t.equal(body, 'Requested range not satisfiable');
});
Expand All @@ -97,7 +97,7 @@ test('partial range', (t) => {
headers: { range: '3-' },
};
request.get(opts, (err, res, body) => {
t.ifError(err);
t.error(err);
t.equal(res.statusCode, 206, 'partial content status code');
t.equal(eol.lf(body), 'e!!</b>\n');
t.equal(parseInt(res.headers['content-length'], 10), body.length);
Expand All @@ -122,7 +122,7 @@ test('include last-modified, etag and cache-control headers', (t) => {
headers: { range: '3-5' },
};
request.get(opts, (err, res) => {
t.ifError(err);
t.error(err);
t.ok(res.headers['cache-control']);
t.ok(res.headers['last-modified']);
t.ok(res.headers.etag);
Expand Down
2 changes: 1 addition & 1 deletion test/trailing-slash.test.js
Expand Up @@ -18,7 +18,7 @@ test('should not add trailing slash when showDir and autoIndex are off', (t) =>
server.listen(0, () => {
const port = server.address().port;
request.get(`http://localhost:${port}/subdir`, (err, res) => {
t.ifError(err);
t.error(err);
t.equal(res.statusCode, 404);
t.equal(res.body, 'File not found. :(');
});
Expand Down