koa-lite/test/context/inspect.js
Ruben Bridgewater 8f047ddb84 fix: use non deprecated custom inspect (#1198)
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.
2018-06-25 10:34:15 +08:00

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));
});
});