shimmed.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. 'use strict';
  2. require('../auto');
  3. var test = require('tape');
  4. var defineProperties = require('define-properties');
  5. var callBind = require('call-bind');
  6. var isEnumerable = Object.prototype.propertyIsEnumerable;
  7. var functionsHaveNames = require('functions-have-names')();
  8. var hasStrictMode = require('has-strict-mode')();
  9. var runTests = require('./tests');
  10. test('shimmed', function (t) {
  11. t.equal(Object.hasOwn.length, 2, 'Relect.hasOwn has a length of 2');
  12. t.test('Function name', { skip: !functionsHaveNames }, function (st) {
  13. st.equal(Object.hasOwn.name, 'hasOwn', 'Object.hasOwn has name "hasOwn"');
  14. st.end();
  15. });
  16. t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
  17. et.equal(false, isEnumerable.call(Object, 'hasOwn'), 'Object.hasOwn is not enumerable');
  18. et.end();
  19. });
  20. t.test('bad array/this value', { skip: !hasStrictMode }, function (st) {
  21. st['throws'](function () { return Object.hasOwn.call(undefined); }, TypeError, 'undefined is not an object');
  22. st['throws'](function () { return Object.hasOwn.call(null); }, TypeError, 'null is not an object');
  23. st.end();
  24. });
  25. runTests(callBind(Object.hasOwn, Object), t);
  26. t.end();
  27. });