create project
This commit is contained in:
20
kitabcitab/node_modules/object.hasown/test/implementation.js
generated
vendored
Normal file
20
kitabcitab/node_modules/object.hasown/test/implementation.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
'use strict';
|
||||
|
||||
var hasOwn = require('../implementation');
|
||||
var callBind = require('call-bind');
|
||||
var test = require('tape');
|
||||
var hasStrictMode = require('has-strict-mode')();
|
||||
var runTests = require('./tests');
|
||||
|
||||
test('as a function', function (t) {
|
||||
t.test('bad array/this value', { skip: !hasStrictMode }, function (st) {
|
||||
/* eslint no-useless-call: 0 */
|
||||
st['throws'](function () { hasOwn.call(undefined); }, TypeError, 'undefined is not an object');
|
||||
st['throws'](function () { hasOwn.call(null); }, TypeError, 'null is not an object');
|
||||
st.end();
|
||||
});
|
||||
|
||||
runTests(callBind(hasOwn, Object), t);
|
||||
|
||||
t.end();
|
||||
});
|
||||
11
kitabcitab/node_modules/object.hasown/test/index.js
generated
vendored
Normal file
11
kitabcitab/node_modules/object.hasown/test/index.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
'use strict';
|
||||
|
||||
var index = require('../');
|
||||
var test = require('tape');
|
||||
var runTests = require('./tests');
|
||||
|
||||
test('as a function', function (t) {
|
||||
runTests(index, t);
|
||||
|
||||
t.end();
|
||||
});
|
||||
24
kitabcitab/node_modules/object.hasown/test/index.mjs
generated
vendored
Normal file
24
kitabcitab/node_modules/object.hasown/test/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
import index, * as Module from 'object.hasown';
|
||||
import test from 'tape';
|
||||
import runTests from './tests.js';
|
||||
|
||||
test('as a function', (t) => {
|
||||
runTests(index, t);
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('named exports', async (t) => {
|
||||
t.deepEqual(
|
||||
Object.keys(Module).sort(),
|
||||
['default', 'shim', 'getPolyfill', 'implementation'].sort(),
|
||||
'has expected named exports',
|
||||
);
|
||||
|
||||
const { shim, getPolyfill, implementation } = Module;
|
||||
t.equal((await import('object.hasown/shim')).default, shim, 'shim named export matches deep export');
|
||||
t.equal((await import('object.hasown/implementation')).default, implementation, 'implementation named export matches deep export');
|
||||
t.equal((await import('object.hasown/polyfill')).default, getPolyfill, 'getPolyfill named export matches deep export');
|
||||
|
||||
t.end();
|
||||
});
|
||||
36
kitabcitab/node_modules/object.hasown/test/shimmed.js
generated
vendored
Normal file
36
kitabcitab/node_modules/object.hasown/test/shimmed.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
'use strict';
|
||||
|
||||
require('../auto');
|
||||
|
||||
var test = require('tape');
|
||||
var defineProperties = require('define-properties');
|
||||
var callBind = require('call-bind');
|
||||
|
||||
var isEnumerable = Object.prototype.propertyIsEnumerable;
|
||||
var functionsHaveNames = require('functions-have-names')();
|
||||
var hasStrictMode = require('has-strict-mode')();
|
||||
|
||||
var runTests = require('./tests');
|
||||
|
||||
test('shimmed', function (t) {
|
||||
t.equal(Object.hasOwn.length, 2, 'Relect.hasOwn has a length of 2');
|
||||
t.test('Function name', { skip: !functionsHaveNames }, function (st) {
|
||||
st.equal(Object.hasOwn.name, 'hasOwn', 'Object.hasOwn has name "hasOwn"');
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
|
||||
et.equal(false, isEnumerable.call(Object, 'hasOwn'), 'Object.hasOwn is not enumerable');
|
||||
et.end();
|
||||
});
|
||||
|
||||
t.test('bad array/this value', { skip: !hasStrictMode }, function (st) {
|
||||
st['throws'](function () { return Object.hasOwn.call(undefined); }, TypeError, 'undefined is not an object');
|
||||
st['throws'](function () { return Object.hasOwn.call(null); }, TypeError, 'null is not an object');
|
||||
st.end();
|
||||
});
|
||||
|
||||
runTests(callBind(Object.hasOwn, Object), t);
|
||||
|
||||
t.end();
|
||||
});
|
||||
36
kitabcitab/node_modules/object.hasown/test/tests.js
generated
vendored
Normal file
36
kitabcitab/node_modules/object.hasown/test/tests.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
'use strict';
|
||||
|
||||
var hasSymbols = require('has-symbols')();
|
||||
|
||||
module.exports = function runTests(hasOwn, t) {
|
||||
var badPropertyKey = { toString: function () { throw new SyntaxError('nope'); } };
|
||||
|
||||
t['throws'](
|
||||
function () { hasOwn(null, badPropertyKey); },
|
||||
TypeError,
|
||||
'checks ToObject first'
|
||||
);
|
||||
|
||||
t['throws'](
|
||||
function () { hasOwn({}, badPropertyKey); },
|
||||
SyntaxError,
|
||||
'checks ToPropertyKey next'
|
||||
);
|
||||
|
||||
var obj = { a: 1 };
|
||||
t.equal('toString' in obj, true, 'object literal has non-own toString');
|
||||
t.equal(hasOwn(obj, 'toString'), false, 'toString is not an own property');
|
||||
t.equal(hasOwn(obj, 'a'), true, 'own property is recognized');
|
||||
|
||||
t.equal(hasOwn([], 'length'), true, 'non-enumerable own property is recognized');
|
||||
|
||||
t.test('Symbols', { skip: !hasSymbols }, function (st) {
|
||||
var o = {};
|
||||
o[Symbol.iterator] = true;
|
||||
st.equal(hasOwn(o, Symbol.iterator), true, 'own symbol is recognized');
|
||||
|
||||
st.equal(hasOwn(Array.prototype, Symbol.iterator), true, 'built-in own symbol is recognized');
|
||||
|
||||
st.end();
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user