8f047ddb84
Custom inspection with the `inspect` property is deprecated and will not work in Node.js 11 anymore. This fixes it by using the custom inspect symbol where existent and falls back to the old style in case it does not exist.
36 lines
863 B
JavaScript
36 lines
863 B
JavaScript
|
|
'use strict';
|
|
|
|
const request = require('../helpers/context').request;
|
|
const assert = require('assert');
|
|
const util = require('util');
|
|
|
|
describe('req.inspect()', () => {
|
|
describe('with no request.req present', () => {
|
|
it('should return null', () => {
|
|
const req = request();
|
|
req.method = 'GET';
|
|
delete req.req;
|
|
assert(undefined === req.inspect());
|
|
assert('undefined' === util.inspect(req));
|
|
});
|
|
});
|
|
|
|
it('should return a json representation', () => {
|
|
const req = request();
|
|
req.method = 'GET';
|
|
req.url = 'example.com';
|
|
req.header.host = 'example.com';
|
|
|
|
const expected = {
|
|
method: 'GET',
|
|
url: 'example.com',
|
|
header: {
|
|
host: 'example.com'
|
|
}
|
|
};
|
|
|
|
assert.deepEqual(req.inspect(), expected);
|
|
assert.deepEqual(util.inspect(req), util.inspect(expected));
|
|
});
|
|
});
|