test:replace anonymous closure for test-http-expect-handling.js

PR-URL: https://github.com/nodejs/node/pull/24423
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
Jayasankar 2018-11-17 17:36:44 +05:30 committed by Rich Trott
parent f25123822e
commit 1dadaf90f6

View File

@ -9,7 +9,7 @@ const tests = [417, 417];
let testsComplete = 0; let testsComplete = 0;
let testIdx = 0; let testIdx = 0;
const s = http.createServer(function(req, res) { const s = http.createServer((req, res) => {
throw new Error('this should never be executed'); throw new Error('this should never be executed');
}); });
@ -34,13 +34,13 @@ function nextTest() {
})); }));
} }
http.get(options, function(response) { http.get(options, (response) => {
console.log(`client: expected status: ${test}`); console.log(`client: expected status: ${test}`);
console.log(`client: statusCode: ${response.statusCode}`); console.log(`client: statusCode: ${response.statusCode}`);
assert.strictEqual(response.statusCode, test); assert.strictEqual(response.statusCode, test);
assert.strictEqual(response.statusMessage, 'Expectation Failed'); assert.strictEqual(response.statusMessage, 'Expectation Failed');
response.on('end', function() { response.on('end', () => {
testsComplete++; testsComplete++;
testIdx++; testIdx++;
nextTest(); nextTest();
@ -50,6 +50,6 @@ function nextTest() {
} }
process.on('exit', function() { process.on('exit', () => {
assert.strictEqual(testsComplete, 2); assert.strictEqual(testsComplete, 2);
}); });