e8f79d43f9
closes #517 add index test for Application add app.toJSON test add test for app.inspect() add tests for app.use() add tests for app.onerror() add tests for app.respond() add tests for app.context() add tests for app.request() add tests for app.response refactor for non-existence of test/app...js no need for *.js use helpers/ dir for non-tests
34 lines
722 B
JavaScript
34 lines
722 B
JavaScript
|
|
'use strict';
|
|
|
|
const request = require('supertest');
|
|
const assert = require('assert');
|
|
const koa = require('../..');
|
|
|
|
describe('app.request', function(){
|
|
const app1 = koa();
|
|
app1.request.message = 'hello';
|
|
const app2 = koa();
|
|
|
|
it('should merge properties', function(done){
|
|
app1.use(function *(next){
|
|
assert.equal(this.request.message, 'hello')
|
|
this.status = 204
|
|
});
|
|
|
|
request(app1.listen())
|
|
.get('/')
|
|
.expect(204, done);
|
|
})
|
|
|
|
it('should not affect the original prototype', function(done){
|
|
app2.use(function *(next){
|
|
assert.equal(this.request.message, undefined)
|
|
this.status = 204;
|
|
});
|
|
|
|
request(app2.listen())
|
|
.get('/')
|
|
.expect(204, done);
|
|
})
|
|
})
|