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 36d47b9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
coverage/
2 changes: 1 addition & 1 deletion .nycrc
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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 36d47b9

Please sign in to comment.