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

31 lines
681 B
JavaScript

'use strict';
const request = require('../helpers/context').request;
const assert = require('assert');
describe('req.inspect()', () => {
describe('with no request.req present', () => {
it('should return null', () => {
const req = request();
req.method = 'GET';
delete req.req;
assert(null == req.inspect());
});
});
it('should return a json representation', () => {
const req = request();
req.method = 'GET';
req.url = 'example.com';
req.header.host = 'example.com';
assert.deepEqual({
method: 'GET',
url: 'example.com',
header: {
host: 'example.com'
}
}, req.inspect());
});
});