Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e78de99

Browse filesBrowse files
edsadrItalo A. Casas
authored andcommitted
test: improve test-http-chunked-304
* change the nested functions call to run tests in parallel * use const and let instead of var * use common.mustCall to control functions execution * use assert.strictEqual instead of assert.equal * use arrow functions PR-URL: #10462 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Italo A. Casas <me@italoacasas.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent ff23d81 commit e78de99
Copy full SHA for e78de99

File tree

Expand file treeCollapse file tree

1 file changed

+24
-21
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+24
-21
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-http-chunked-304.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-http-chunked-304.js
+24-21Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,35 @@ var net = require('net');
1212
// Likewise for 304 responses. Verify that no empty chunk is sent when
1313
// the user explicitly sets a Transfer-Encoding header.
1414

15-
test(204, function() {
16-
test(304);
17-
});
15+
test(204);
16+
test(304);
1817

19-
function test(statusCode, next) {
20-
var server = http.createServer(function(req, res) {
18+
function test(statusCode) {
19+
const server = http.createServer(common.mustCall((req, res) => {
2120
res.writeHead(statusCode, { 'Transfer-Encoding': 'chunked' });
2221
res.end();
2322
server.close();
24-
});
23+
}));
2524

26-
server.listen(0, function() {
27-
var conn = net.createConnection(this.address().port, function() {
28-
conn.write('GET / HTTP/1.1\r\n\r\n');
25+
server.listen(0, common.mustCall(() => {
26+
const conn = net.createConnection(
27+
server.address().port,
28+
common.mustCall(() => {
29+
conn.write('GET / HTTP/1.1\r\n\r\n');
2930

30-
var resp = '';
31-
conn.setEncoding('utf8');
32-
conn.on('data', function(data) {
33-
resp += data;
34-
});
31+
let resp = '';
32+
conn.setEncoding('utf8');
33+
conn.on('data', common.mustCall((data) => {
34+
resp += data;
35+
}));
3536

36-
conn.on('end', common.mustCall(function() {
37-
assert.equal(/^Connection: close\r\n$/m.test(resp), true);
38-
assert.equal(/^0\r\n$/m.test(resp), false);
39-
if (next) process.nextTick(next);
40-
}));
41-
});
42-
});
37+
conn.on('end', common.mustCall(() => {
38+
// Connection: close should be in the response
39+
assert.strictEqual(/^Connection: close\r\n$/m.test(resp), true);
40+
// Make sure this doesn't end with 0\r\n\r\n
41+
assert.strictEqual(/^0\r\n$/m.test(resp), false);
42+
}));
43+
})
44+
);
45+
}));
4346
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.