fix tests on node 6

parsed querystrings no longer inherit from the Object prototype
This commit is contained in:
Yu Qi 2016-05-01 14:45:30 +08:00 committed by Julian Gruber
parent 4809f083ac
commit 10e31cdde3
3 changed files with 8 additions and 9 deletions

View file

@ -2,12 +2,13 @@
'use strict';
var context = require('../context');
var should = require('should');
describe('ctx.query', function(){
describe('when missing', function(){
it('should return an empty object', function(){
var ctx = context({ url: '/' });
ctx.query.should.eql({});
should(ctx.query).empty;
})
it('should return the same object each time it\'s accessed', function(done) {

View file

@ -3,6 +3,7 @@
var context = require('../context');
var parseurl = require('parseurl');
var should = require('should');
describe('ctx.querystring', function(){
it('should return the querystring', function(){
@ -32,10 +33,8 @@ describe('ctx.querystring=', function(){
ctx.querystring = 'page=2&color=blue';
ctx.url.should.equal('/store/shoes?page=2&color=blue');
ctx.search.should.equal('?page=2&color=blue');
ctx.query.should.eql({
page: '2',
color: 'blue'
});
should(ctx.query).have.property('page', '2');
should(ctx.query).have.property('color', 'blue');
})
it('should change .url but not .originalUrl', function(){

View file

@ -2,6 +2,7 @@
'use strict';
var context = require('../context');
var should = require('should');
describe('ctx.search=', function(){
it('should replace the search', function(){
@ -16,10 +17,8 @@ describe('ctx.search=', function(){
ctx.search = '?page=2&color=blue';
ctx.url.should.equal('/store/shoes?page=2&color=blue');
ctx.querystring.should.equal('page=2&color=blue');
ctx.query.should.eql({
page: '2',
color: 'blue'
});
should(ctx.query).have.property('page', '2');
should(ctx.query).have.property('color', 'blue');
})
it('should change .url but not .originalUrl', function(){