• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3var getDescriptors = require('../');
4getDescriptors.shim();
5
6var test = require('tape');
7var defineProperties = require('define-properties');
8var runTests = require('./tests');
9var isEnumerable = Object.prototype.propertyIsEnumerable;
10var functionsHaveNames = function f() {}.name === 'f';
11
12test('shimmed', function (t) {
13	t.equal(Object.getOwnPropertyDescriptors.length, 1, 'Object.getOwnPropertyDescriptors has a length of 1');
14	t.test('Function name', { skip: !functionsHaveNames }, function (st) {
15		st.equal(Object.getOwnPropertyDescriptors.name, 'getOwnPropertyDescriptors', 'Object.getOwnPropertyDescriptors has name "getOwnPropertyDescriptors"');
16		st.end();
17	});
18
19	t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
20		et.equal(false, isEnumerable.call(Object, 'getOwnPropertyDescriptors'), 'Object.getOwnPropertyDescriptors is not enumerable');
21		et.end();
22	});
23
24	var supportsStrictMode = (function () { return typeof this === 'undefined'; }());
25
26	t.test('bad object/this value', { skip: !supportsStrictMode }, function (st) {
27		st.throws(function () { return getDescriptors(undefined, 'a'); }, TypeError, 'undefined is not an object');
28		st.throws(function () { return getDescriptors(null, 'a'); }, TypeError, 'null is not an object');
29		st.end();
30	});
31
32	runTests(Object.getOwnPropertyDescriptors, t);
33
34	t.end();
35});
36