fix tests on node 6

parsed querystrings no longer inherit from the Object prototype
This commit is contained in:
Yu Qi 2016-04-30 15:19:29 +08:00 committed by Julian Gruber
parent e0a0d9f7cc
commit c979056087
4 changed files with 9 additions and 10 deletions

View file

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

View file

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

View file

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

View file

@ -27,7 +27,7 @@ describe('ctx.attachment([filename])', () => {
it('should set the encodeURI filename param', () => { it('should set the encodeURI filename param', () => {
const ctx = context(); const ctx = context();
ctx.attachment('path/to/include-no-ascii-char-中文名-ok.png'); ctx.attachment('path/to/include-no-ascii-char-中文名-ok.png');
const str = 'attachment; filename=\"include-no-ascii-char-???-ok.png\"; filename*=UTF-8\'\'include-no-ascii-char-%E4%B8%AD%E6%96%87%E5%90%8D-ok.png'; const str = 'attachment; filename="include-no-ascii-char-???-ok.png"; filename*=UTF-8\'\'include-no-ascii-char-%E4%B8%AD%E6%96%87%E5%90%8D-ok.png';
ctx.response.header['content-disposition'].should.equal(str); ctx.response.header['content-disposition'].should.equal(str);
}); });