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
872 B
JavaScript
36 lines
872 B
JavaScript
|
|
'use strict';
|
|
|
|
const response = require('../helpers/context').response;
|
|
const assert = require('assert');
|
|
const util = require('util');
|
|
|
|
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);
|
|
assert.equal(util.inspect(res), 'undefined');
|
|
});
|
|
});
|
|
|
|
it('should return a json representation', () => {
|
|
const res = response();
|
|
res.body = 'hello';
|
|
|
|
const expected = {
|
|
status: 200,
|
|
message: 'OK',
|
|
header: {
|
|
'content-type': 'text/plain; charset=utf-8',
|
|
'content-length': '5'
|
|
},
|
|
body: 'hello'
|
|
};
|
|
|
|
assert.deepEqual(res.inspect(), expected);
|
|
assert.deepEqual(util.inspect(res), util.inspect(expected));
|
|
});
|
|
});
|