Skip to content

Commit

Permalink
added .query() tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Jan 25, 2012
1 parent 57531c3 commit 8e2cd1a
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions test/node/query.js
Expand Up @@ -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(){
Expand Down Expand Up @@ -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();
});
});
})

0 comments on commit 8e2cd1a

Please sign in to comment.