shimmed.js 1.1 KB

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