From b3452765cc66e0d00c3f9f6d1051165a2071fddb Mon Sep 17 00:00:00 2001 From: Vsevolod Strukchinsky Date: Thu, 25 Jun 2015 11:54:14 +0300 Subject: [PATCH] Add test on pathname in arguments Test-case for #72 --- test/test-arguments.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/test/test-arguments.js b/test/test-arguments.js index d4d9486..209a669 100644 --- a/test/test-arguments.js +++ b/test/test-arguments.js @@ -4,6 +4,11 @@ var got = require('../'); var server = require('./server.js'); var s = server.createServer(); +s.on('/', function (req, res) { + res.statusCode = 404; + res.end(); +}); + s.on('/test', function (req, res) { res.end(req.url); }); @@ -26,7 +31,7 @@ test('url argument is required', function (t) { }); test('accepts url.parse object as first argument', function (t) { - got({host: s.host, port: s.port, path: '/test'}, function (err, data) { + got({hostname: s.host, port: s.port, path: '/test'}, function (err, data) { t.error(err); t.equal(data, '/test'); t.end(); @@ -41,6 +46,14 @@ test('overrides querystring from opts', function (t) { }); }); +// Error says http://localhost:6767/test, but request was to http://localhost:6767/ +test('pathname confusion', function (t) { + got({protocol: 'http:', hostname: s.host, port: s.port, pathname: '/test'}, function (err) { + t.ok(/http:\/\/localhost:6767\/ response code/.test(err)); + t.end(); + }); +}); + test('cleanup', function (t) { s.close(); t.end();