Skip to content

Commit 586a7dd

Browse files
committed
test: stream error
1 parent 2b0b3a5 commit 586a7dd

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

test/integration/node-static-test.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,27 @@ function startStaticServerWithCallback (port, callback) {
4343
}
4444

4545
describe('node-static', function () {
46+
47+
it('handles stream error', function (done) {
48+
let setError = null;
49+
const server = http.createServer(function (request, response) {
50+
fileServer.stream(
51+
undefined, ['bad-file.txt'], 0, 0, response, (err) => {
52+
if (err) {
53+
setError = err;
54+
}
55+
}
56+
);
57+
});
58+
server.listen('8081', async () => {
59+
const response = await fetch('http://localhost:8081');
60+
assert.equal(response.status, 200, 'should respond with 200');
61+
assert.equal(await response.text(), '', 'should respond with empty string');
62+
assert.equal(setError?.code, 'ENOENT');
63+
server.close();
64+
done();
65+
});
66+
});
4667
it('streaming a 404 page', async function () {
4768
testPort++;
4869
const getTestServer = () => {

0 commit comments

Comments
 (0)