Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added `.query()` tests

  • Loading branch information...
commit 8e2cd1a9ff27d0362b4dd660f1156568d4e4c882 1 parent 57531c3
@tj tj authored
Showing with 37 additions and 2 deletions.
  1. +37 −2 test/node/query.js
View
39 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();
+ });
+ });
+})
Please sign in to comment.
Something went wrong with that request. Please try again.