fix tests on node 6
parsed querystrings no longer inherit from the Object prototype
This commit is contained in:
parent
e0a0d9f7cc
commit
c979056087
4 changed files with 9 additions and 10 deletions
|
@ -2,12 +2,13 @@
|
|||
'use strict';
|
||||
|
||||
const context = require('../helpers/context');
|
||||
const should = require('should');
|
||||
|
||||
describe('ctx.query', () => {
|
||||
describe('when missing', () => {
|
||||
it('should return an empty object', () => {
|
||||
const ctx = context({ url: '/' });
|
||||
ctx.query.should.eql({});
|
||||
should(ctx.query).empty;
|
||||
});
|
||||
|
||||
it('should return the same object each time it\'s accessed', done => {
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
const context = require('../helpers/context');
|
||||
const parseurl = require('parseurl');
|
||||
const should = require('should');
|
||||
|
||||
describe('ctx.querystring', () => {
|
||||
it('should return the querystring', () => {
|
||||
|
@ -32,10 +33,8 @@ describe('ctx.querystring=', () => {
|
|||
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', () => {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
'use strict';
|
||||
|
||||
const context = require('../helpers/context');
|
||||
const should = require('should');
|
||||
|
||||
describe('ctx.search=', () => {
|
||||
it('should replace the search', () => {
|
||||
|
@ -16,10 +17,8 @@ describe('ctx.search=', () => {
|
|||
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', () => {
|
||||
|
|
|
@ -27,7 +27,7 @@ describe('ctx.attachment([filename])', () => {
|
|||
it('should set the encodeURI filename param', () => {
|
||||
const ctx = context();
|
||||
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);
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue