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:
parent
4fd70ceeac
commit
604578f47e
@ -27,11 +27,11 @@ const http = require('http');
|
|||||||
const expected = 'This is a unicode text: سلام';
|
const expected = 'This is a unicode text: سلام';
|
||||||
let result = '';
|
let result = '';
|
||||||
|
|
||||||
const server = http.Server(function(req, res) {
|
const server = http.Server((req, res) => {
|
||||||
req.setEncoding('utf8');
|
req.setEncoding('utf8');
|
||||||
req.on('data', function(chunk) {
|
req.on('data', (chunk) => {
|
||||||
result += chunk;
|
result += chunk;
|
||||||
}).on('end', function() {
|
}).on('end', () => {
|
||||||
server.close();
|
server.close();
|
||||||
res.writeHead(200);
|
res.writeHead(200);
|
||||||
res.end('hello world\n');
|
res.end('hello world\n');
|
||||||
@ -44,15 +44,15 @@ server.listen(0, function() {
|
|||||||
port: this.address().port,
|
port: this.address().port,
|
||||||
path: '/',
|
path: '/',
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
}, function(res) {
|
}, (res) => {
|
||||||
console.log(res.statusCode);
|
console.log(res.statusCode);
|
||||||
res.resume();
|
res.resume();
|
||||||
}).on('error', function(e) {
|
}).on('error', (e) => {
|
||||||
console.log(e.message);
|
console.log(e.message);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}).end(expected);
|
}).end(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
process.on('exit', function() {
|
process.on('exit', () => {
|
||||||
assert.strictEqual(expected, result);
|
assert.strictEqual(expected, result);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user