get.js
1 'use strict'; 2 3 var test = require('tape'); 4 5 var getDunderProto = require('../get'); 6 7 test('getDunderProto', { skip: !getDunderProto }, function (t) { 8 if (!getDunderProto) { 9 throw 'should never happen; this is just for type narrowing'; // eslint-disable-line no-throw-literal 10 } 11 12 // @ts-expect-error 13 t['throws'](function () { getDunderProto(); }, TypeError, 'throws if no argument'); 14 // @ts-expect-error 15 t['throws'](function () { getDunderProto(undefined); }, TypeError, 'throws with undefined'); 16 // @ts-expect-error 17 t['throws'](function () { getDunderProto(null); }, TypeError, 'throws with null'); 18 19 t.equal(getDunderProto({}), Object.prototype); 20 t.equal(getDunderProto([]), Array.prototype); 21 t.equal(getDunderProto(function () {}), Function.prototype); 22 t.equal(getDunderProto(/./g), RegExp.prototype); 23 t.equal(getDunderProto(42), Number.prototype); 24 t.equal(getDunderProto(true), Boolean.prototype); 25 t.equal(getDunderProto('foo'), String.prototype); 26 27 t.end(); 28 }); 29 30 test('no dunder proto', { skip: !!getDunderProto }, function (t) { 31 t.notOk('__proto__' in Object.prototype, 'no __proto__ in Object.prototype'); 32 33 t.end(); 34 });