Skip to content

Commit

Permalink
test: added tests for setEncoding error check
Browse files Browse the repository at this point in the history
added test to ensure setEncoding inside socket connection
would throw an error

Fixes: nodejs#18118
Ref: nodejs#18178
  • Loading branch information
iSkore committed Apr 3, 2018
1 parent a7e2aab commit 345ff3c
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/parallel/test-http-socket-encoding-error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict';

const common = require('../common');
const http = require('http');

const server = http.createServer().listen(0, connectToServer);

server.on('connection', (socket) => {
common.expectsError(() => socket.setEncoding(''),
{
code: 'ERR_METHOD_NOT_IMPLEMENTED',
type: Error
});

socket.end();
});

function connectToServer() {
const client = new http.Agent().createConnection(this.address().port, () => {
client.end();
})
.on('end', () => server.close());
}

0 comments on commit 345ff3c

Please sign in to comment.