From 8e2cd1a9ff27d0362b4dd660f1156568d4e4c882 Mon Sep 17 00:00:00 2001 From: Tj Holowaychuk Date: Tue, 24 Jan 2012 19:52:16 -0800 Subject: [PATCH] added `.query()` tests --- test/node/query.js | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/test/node/query.js b/test/node/query.js index f523e8742..f6756e0ec 100644 --- a/test/node/query.js +++ b/test/node/query.js @@ -8,9 +8,11 @@ app.get('/', function(req, res){ res.send(req.query); }); -app.listen(3006); +app.del('/', function(req, res){ + res.send(req.query); +}); -// TODO: "response" event should be a Response +app.listen(3006); describe('req.send(Object)', function(){ describe('on a GET request', function(){ @@ -46,3 +48,36 @@ describe('req.send(Object)', function(){ }); }) }) + +describe('req.query(Object)', function(){ + it('should construct the query-string', function(done){ + request + .del('http://localhost:3006/') + .query({ name: 'tobi' }) + .query({ order: 'asc' }) + .query({ limit: ['1', '2'] }) + .end(function(res){ + res.body.should.eql({ name: 'tobi', order: 'asc', limit: ['1', '2'] }); + done(); + }); + }) + + it('should append to the original query-string', function(done){ + request + .del('http://localhost:3006/?name=tobi') + .query({ order: 'asc' }) + .end(function(res) { + res.body.should.eql({ name: 'tobi', order: 'asc' }); + done(); + }); + }); + + it('should retain the original query-string', function(done){ + request + .del('http://localhost:3006/?name=tobi') + .end(function(res) { + res.body.should.eql({ name: 'tobi' }); + done(); + }); + }); +})