inspect.js 636 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
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') + ', [] ]');
});