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.
23 lines
711 B
JavaScript
23 lines
711 B
JavaScript
|
|
'use strict';
|
|
|
|
const prototype = require('../../lib/context');
|
|
const assert = require('assert');
|
|
const util = require('util');
|
|
const context = require('../helpers/context');
|
|
|
|
describe('ctx.inspect()', () => {
|
|
it('should return a json representation', () => {
|
|
const ctx = context();
|
|
const toJSON = ctx.toJSON(ctx);
|
|
|
|
assert.deepEqual(toJSON, ctx.inspect());
|
|
assert.deepEqual(util.inspect(toJSON), util.inspect(ctx));
|
|
});
|
|
|
|
// console.log(require.cache) will call prototype.inspect()
|
|
it('should not crash when called on the prototype', () => {
|
|
assert.deepEqual(prototype, prototype.inspect());
|
|
assert.deepEqual(util.inspect(prototype.inspect()), util.inspect(prototype));
|
|
});
|
|
});
|