Skip to content

Commit

Permalink
[Tests] cover util.inspect.custom
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Nov 10, 2019
1 parent 7f9953a commit 95d2316
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .nycrc
Expand Up @@ -3,7 +3,7 @@
"check-coverage": true,
"instrumentation": false,
"sourceMap": false,
"reporter": "html",
"reporter": ["html", "text-summary"],
"lines": 94,
"statements": 94,
"functions": 96,
Expand Down
14 changes: 13 additions & 1 deletion test/inspect.js
@@ -1,8 +1,20 @@
var inspect = require('../');
var test = require('tape');
var hasSymbols = require('has-symbols')();
var utilInspect = require('../util.inspect');

var inspect = require('..');

test('inspect', function (t) {
t.plan(1);
var obj = [{ inspect: function () { return '!XYZ¡'; } }, []];
t.equal(inspect(obj), '[ !XYZ¡, [] ]');
});

test('inspect custom symbol', { skip: !hasSymbols || !utilInspect }, function (t) {
t.plan(1);

var obj = { inspect: function () { return 'string'; } };
obj[utilInspect.custom] = function () { return 'symbol'; };

t.equal(inspect([obj, []]), '[ ' + (utilInspect.custom ? 'symbol' : 'string') + ', [] ]');
});

0 comments on commit 95d2316

Please sign in to comment.