v3 new release (#84)

swap to graphql
This commit is contained in:
github-actions[bot]
2022-07-11 13:48:02 -04:00
committed by GitHub
parent 20d2b4f98d
commit e4f3964f67
1492 changed files with 63799 additions and 63001 deletions

View File

@ -40,9 +40,9 @@ test('type error', function (t) {
'{ [TypeError] foo: 555, bar: [ 1, 2, 3 ] }',
'{ [TypeError: tuv] baz: 555 }',
'{ [SyntaxError: whoa] message: \'whoa\', \'a-b\': 5 }',
'{ [Error: foo] [cause]: \'bar\' }',
'{ [Error: foo] [cause]: \'bar\', foo: \'bar\' }',
'{ [Error: foo] [cause]: undefined }',
'cause' in Error.prototype ? '[Error: foo]' : '{ [Error: foo] [cause]: \'bar\' }',
'{ [Error: foo] ' + ('cause' in Error.prototype ? '' : '[cause]: \'bar\', ') + 'foo: \'bar\' }',
'cause' in Error.prototype ? '[Error: foo]' : '{ [Error: foo] [cause]: undefined }',
'{ [Error: foo] cause: \'bar\' }'
].join(', ') + ' ]');
});

View File

@ -1,34 +1,15 @@
'use strict';
var inspect = require('../');
var test = require('tape');
function withoutProperty(object, property, fn) {
var original;
if (Object.getOwnPropertyDescriptor) {
original = Object.getOwnPropertyDescriptor(object, property);
} else {
original = object[property];
}
delete object[property];
try {
fn();
} finally {
if (Object.getOwnPropertyDescriptor) {
Object.defineProperty(object, property, original);
} else {
object[property] = original;
}
}
}
var mockProperty = require('mock-property');
test('when Object#hasOwnProperty is deleted', function (t) {
t.plan(1);
var arr = [1, , 3]; // eslint-disable-line no-sparse-arrays
// eslint-disable-next-line no-extend-native
Array.prototype[1] = 2; // this is needed to account for "in" vs "hasOwnProperty"
t.teardown(mockProperty(Array.prototype, 1, { value: 2 })); // this is needed to account for "in" vs "hasOwnProperty"
t.teardown(mockProperty(Object.prototype, 'hasOwnProperty', { 'delete': true }));
withoutProperty(Object.prototype, 'hasOwnProperty', function () {
t.equal(inspect(arr), '[ 1, , 3 ]');
});
delete Array.prototype[1];
t.equal(inspect(arr), '[ 1, , 3 ]');
});

View File

@ -100,3 +100,40 @@ test('maxStringLength', function (t) {
t.end();
});
test('inspect options', { skip: !utilInspect.custom }, function (t) {
var obj = {};
obj[utilInspect.custom] = function () {
return JSON.stringify(arguments);
};
t.equal(
inspect(obj),
utilInspect(obj, { depth: 5 }),
'custom symbols will use node\'s inspect'
);
t.equal(
inspect(obj, { depth: 2 }),
utilInspect(obj, { depth: 2 }),
'a reduced depth will be passed to node\'s inspect'
);
t.equal(
inspect({ d1: obj }, { depth: 3 }),
'{ d1: ' + utilInspect(obj, { depth: 2 }) + ' }',
'deep objects will receive a reduced depth'
);
t.equal(
inspect({ d1: obj }, { depth: 1 }),
'{ d1: [Object] }',
'unlike nodejs inspect, customInspect will not be used once the depth is exceeded.'
);
t.end();
});
test('inspect URL', { skip: typeof URL === 'undefined' }, function (t) {
t.match(
inspect(new URL('https://nodejs.org')),
/nodejs\.org/, // Different environments stringify it differently
'url can be inspected'
);
t.end();
});

View File

@ -2,6 +2,7 @@
var inspect = require('../');
var test = require('tape');
var mockProperty = require('mock-property');
var hasSymbols = require('has-symbols/shams')();
var hasToStringTag = require('has-tostringtag/shams')();
@ -23,10 +24,9 @@ test('arrays with properties', function (t) {
test('has', function (t) {
t.plan(1);
var has = Object.prototype.hasOwnProperty;
delete Object.prototype.hasOwnProperty;
t.teardown(mockProperty(Object.prototype, 'hasOwnProperty', { 'delete': true }));
t.equal(inspect({ a: 1, b: 2 }), '{ a: 1, b: 2 }');
Object.prototype.hasOwnProperty = has; // eslint-disable-line no-extend-native
});
test('indexOf seen', function (t) {