node/test/parallel/test-http-set-cookies.js
Gibson Fahnestock 3d2aef3979 test: s/assert.equal/assert.strictEqual/
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>
2017-01-11 14:19:26 +00:00

65 lines
1.6 KiB
JavaScript

'use strict';
require('../common');
const assert = require('assert');
const http = require('http');
let nresponses = 0;
const server = http.createServer(function(req, res) {
if (req.url === '/one') {
res.writeHead(200, [['set-cookie', 'A'],
['content-type', 'text/plain']]);
res.end('one\n');
} else {
res.writeHead(200, [['set-cookie', 'A'],
['set-cookie', 'B'],
['content-type', 'text/plain']]);
res.end('two\n');
}
});
server.listen(0);
server.on('listening', function() {
//
// one set-cookie header
//
http.get({ port: this.address().port, path: '/one' }, function(res) {
// set-cookie headers are always return in an array.
// even if there is only one.
assert.deepStrictEqual(['A'], res.headers['set-cookie']);
assert.strictEqual('text/plain', res.headers['content-type']);
res.on('data', function(chunk) {
console.log(chunk.toString());
});
res.on('end', function() {
if (++nresponses === 2) {
server.close();
}
});
});
// two set-cookie headers
http.get({ port: this.address().port, path: '/two' }, function(res) {
assert.deepStrictEqual(['A', 'B'], res.headers['set-cookie']);
assert.strictEqual('text/plain', res.headers['content-type']);
res.on('data', function(chunk) {
console.log(chunk.toString());
});
res.on('end', function() {
if (++nresponses === 2) {
server.close();
}
});
});
});
process.on('exit', function() {
assert.strictEqual(2, nresponses);
});