[d565449] | 1 | 'use strict';
|
---|
| 2 |
|
---|
| 3 | require('../auto');
|
---|
| 4 |
|
---|
| 5 | var test = require('tape');
|
---|
| 6 | var keys = require('object-keys');
|
---|
| 7 | var defineProperties = require('define-properties');
|
---|
| 8 | var isEnumerable = Object.prototype.propertyIsEnumerable;
|
---|
| 9 | var functionsHaveNames = function f() {}.name === 'f';
|
---|
| 10 |
|
---|
| 11 | var runTests = require('./tests');
|
---|
| 12 |
|
---|
| 13 | test('shimmed', function (t) {
|
---|
| 14 | t.equal(Object.fromEntries.length, 1, 'Object.fromEntries has a length of 1');
|
---|
| 15 | t.test('Function name', { skip: !functionsHaveNames }, function (st) {
|
---|
| 16 | st.equal(Object.fromEntries.name, 'fromEntries', 'Object.fromEntries has name "fromEntries"');
|
---|
| 17 | st.end();
|
---|
| 18 | });
|
---|
| 19 |
|
---|
| 20 | t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
|
---|
| 21 | et.equal(false, isEnumerable.call(Object, 'fromEntries'), 'Object.fromEntries is not enumerable');
|
---|
| 22 | et.end();
|
---|
| 23 | });
|
---|
| 24 |
|
---|
| 25 | var supportsStrictMode = (function () { return typeof this === 'undefined'; }());
|
---|
| 26 |
|
---|
| 27 | t.test('bad object value', { skip: !supportsStrictMode }, function (st) {
|
---|
| 28 | st['throws'](function () { return Object.fromEntries(undefined); }, TypeError, 'undefined is not an object');
|
---|
| 29 | st['throws'](function () { return Object.fromEntries(null); }, TypeError, 'null is not an object');
|
---|
| 30 | st.end();
|
---|
| 31 | });
|
---|
| 32 |
|
---|
| 33 | t.test('does not mutate global method', function (st) {
|
---|
| 34 | st.deepEqual(keys(Object.fromEntries), [], 'no enumerable keys');
|
---|
| 35 | st.equal('shim' in Object.fromEntries, false, '"shim" is not present');
|
---|
| 36 | st.equal('getPolyfill' in Object.fromEntries, false, '"getPolyfill" is not present');
|
---|
| 37 | st.equal('implementation' in Object.fromEntries, false, '"implementation" is not present');
|
---|
| 38 | st.end();
|
---|
| 39 | });
|
---|
| 40 |
|
---|
| 41 | runTests(Object.fromEntries, t);
|
---|
| 42 |
|
---|
| 43 | t.end();
|
---|
| 44 | });
|
---|