koa-lite/test/response/inspect.js

32 lines
678 B
JavaScript
Raw Normal View History

2014-07-06 08:43:14 +00:00
'use strict';
2014-07-06 08:43:14 +00:00
var response = require('../context').response;
2014-11-16 13:52:14 +00:00
var assert = require('assert');
2014-07-06 08:43:14 +00:00
describe('res.inspect()', function(){
describe('with no response.res present', function(){
it('should return null', function(){
var res = response();
res.body = 'hello';
delete res.res;
assert(null == res.inspect());
})
})
it('should return a json representation', function(){
var res = response();
res.body = 'hello';
res.inspect().should.eql({
body: 'hello',
status: 200,
message: 'OK',
2014-07-06 08:43:14 +00:00
header: {
'content-length': '5',
'content-type': 'text/plain; charset=utf-8'
}
});
})
})