2015-10-12 04:59:30 +00:00
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const request = require('supertest');
|
|
|
|
const assert = require('assert');
|
2015-10-13 06:19:42 +00:00
|
|
|
const Koa = require('../..');
|
2015-10-12 04:59:30 +00:00
|
|
|
|
|
|
|
describe('app.response', function(){
|
2015-10-13 06:19:42 +00:00
|
|
|
const app1 = new Koa();
|
2015-10-12 04:59:30 +00:00
|
|
|
app1.response.msg = 'hello';
|
2015-10-13 06:19:42 +00:00
|
|
|
const app2 = new Koa();
|
2015-10-12 04:59:30 +00:00
|
|
|
|
|
|
|
it('should merge properties', function(done){
|
|
|
|
app1.use(function *(next){
|
2015-10-12 20:36:41 +00:00
|
|
|
assert.equal(this.response.msg, 'hello');
|
|
|
|
this.status = 204;
|
2015-10-12 04:59:30 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
request(app1.listen())
|
|
|
|
.get('/')
|
|
|
|
.expect(204, done);
|
2015-10-12 20:36:41 +00:00
|
|
|
});
|
2015-10-12 04:59:30 +00:00
|
|
|
|
|
|
|
it('should not affect the original prototype', function(done){
|
|
|
|
app2.use(function *(next){
|
2015-10-12 20:36:41 +00:00
|
|
|
assert.equal(this.response.msg, undefined);
|
2015-10-12 04:59:30 +00:00
|
|
|
this.status = 204;
|
|
|
|
});
|
|
|
|
|
|
|
|
request(app2.listen())
|
|
|
|
.get('/')
|
|
|
|
.expect(204, done);
|
2015-10-12 20:36:41 +00:00
|
|
|
});
|
|
|
|
});
|