From 9fa2c951510befc0b4a7060bc2160241a95f73bd Mon Sep 17 00:00:00 2001 From: Vsevolod Strukchinsky Date: Fri, 3 Apr 2015 22:06:30 +0500 Subject: [PATCH] Add test on GET with bodies Ensures that https://github.com/tomas/needle/issues/115 will work --- test/test-post.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/test-post.js b/test/test-post.js index 4a33943..3153e96 100644 --- a/test/test-post.js +++ b/test/test-post.js @@ -9,6 +9,11 @@ s.on('/', function (req, res) { req.pipe(res); }); +s.on('/method', function (req, res) { + res.setHeader('method', req.method); + res.end(); +}); + s.on('/empty', function (req, res) { res.end(); }); @@ -19,6 +24,20 @@ tape('setup', function (t) { }); }); +tape('GET can have body', function (t) { + t.plan(3); + + var stream = from(['wow']); + stream.on('end', function () { + t.ok(true); // Ensure, that stream was dumped + }); + + got.get(s.url + '/method', {body: stream}, function (err, data, res) { + t.error(err); + t.equal(res.headers.method, 'GET'); + }); +}); + tape('send data from options with post request', function (t) { t.plan(3);