koa-lite/test/request/inspect.js

30 lines
655 B
JavaScript
Raw Normal View History

2014-07-06 08:43:14 +00:00
var request = require('../context').request;
2014-11-16 13:52:14 +00:00
var assert = require('assert');
2014-07-06 08:43:14 +00:00
describe('req.inspect()', function(){
describe('with no request.req present', function(){
it('should return null', function(){
var req = request();
req.method = 'GET';
delete req.req;
assert(null == req.inspect());
})
})
it('should return a json representation', function(){
var req = request();
req.method = 'GET';
req.url = 'example.com';
req.header.host = 'example.com';
req.inspect().should.eql({
method: 'GET',
url: 'example.com',
header: {
host: 'example.com'
}
});
})
})