source: imaps-frontend/node_modules/object.fromentries/test/shimmed.js@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.6 KB
Line 
1'use strict';
2
3require('../auto');
4
5var test = require('tape');
6var keys = require('object-keys');
7var defineProperties = require('define-properties');
8var isEnumerable = Object.prototype.propertyIsEnumerable;
9var functionsHaveNames = function f() {}.name === 'f';
10
11var runTests = require('./tests');
12
13test('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});
Note: See TracBrowser for help on using the repository browser.