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