shimmed.js 1.4 KB

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