test: change callback function to arrow function

PR-URL: https://github.com/nodejs/node/pull/17697
Reviewed-By: Yosuke Furukawa <yosuke.furukawa@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
routerman 2017-12-15 20:59:40 +09:00 committed by Ruben Bridgewater
parent 4fd70ceeac
commit 604578f47e
No known key found for this signature in database
GPG Key ID: F07496B3EB3C1762

View File

@ -27,11 +27,11 @@ const http = require('http');
const expected = 'This is a unicode text: سلام';
let result = '';
const server = http.Server(function(req, res) {
const server = http.Server((req, res) => {
req.setEncoding('utf8');
req.on('data', function(chunk) {
req.on('data', (chunk) => {
result += chunk;
}).on('end', function() {
}).on('end', () => {
server.close();
res.writeHead(200);
res.end('hello world\n');
@ -44,15 +44,15 @@ server.listen(0, function() {
port: this.address().port,
path: '/',
method: 'POST'
}, function(res) {
}, (res) => {
console.log(res.statusCode);
res.resume();
}).on('error', function(e) {
}).on('error', (e) => {
console.log(e.message);
process.exit(1);
}).end(expected);
});
process.on('exit', function() {
process.on('exit', () => {
assert.strictEqual(expected, result);
});