You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
1.2 KiB

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