mirror of
https://github.com/nodejs/node.git
synced 2025-05-06 22:56:06 +00:00

Use assert.strictEqual instead of assert.equal in tests, manually convert types where necessary. PR-URL: https://github.com/nodejs/node/pull/10698 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
34 lines
832 B
JavaScript
34 lines
832 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
|
|
const http = require('http');
|
|
|
|
const server = http.createServer(function(request, response) {
|
|
console.log('responding to ' + request.url);
|
|
|
|
response.writeHead(200, {'Content-Type': 'text/plain'});
|
|
response.write('1\n');
|
|
response.write('');
|
|
response.write('2\n');
|
|
response.write('');
|
|
response.end('3\n');
|
|
|
|
this.close();
|
|
});
|
|
|
|
server.listen(0, common.mustCall(function() {
|
|
http.get({ port: this.address().port }, common.mustCall(function(res) {
|
|
let response = '';
|
|
|
|
assert.strictEqual(200, res.statusCode);
|
|
res.setEncoding('ascii');
|
|
res.on('data', function(chunk) {
|
|
response += chunk;
|
|
});
|
|
res.on('end', common.mustCall(function() {
|
|
assert.strictEqual('1\n2\n3\n', response);
|
|
}));
|
|
}));
|
|
}));
|