koa-lite/test/response/inspect.js
2017-05-11 11:30:32 +08:00

31 lines
693 B
JavaScript

'use strict';
const response = require('../helpers/context').response;
const assert = require('assert');
describe('res.inspect()', () => {
describe('with no response.res present', () => {
it('should return null', () => {
const res = response();
res.body = 'hello';
delete res.res;
assert.equal(res.inspect(), null);
});
});
it('should return a json representation', () => {
const res = response();
res.body = 'hello';
assert.deepEqual({
body: 'hello',
status: 200,
message: 'OK',
header: {
'content-length': '5',
'content-type': 'text/plain; charset=utf-8'
}
}, res.inspect());
});
});