Server IP : 185.86.78.101 / Your IP : 216.73.216.124 Web Server : Apache System : Linux 675867-vds-valikoshka1996.gmhost.pp.ua 5.4.0-150-generic #167-Ubuntu SMP Mon May 15 17:35:05 UTC 2023 x86_64 User : www ( 1000) PHP Version : 7.4.33 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /www/wwwroot/mifepriston.org/node_modules/define-properties/test/ |
Upload File : |
'use strict'; var define = require('../'); var test = require('tape'); var keys = require('object-keys'); var arePropertyDescriptorsSupported = function () { var obj = { a: 1 }; try { Object.defineProperty(obj, 'x', { value: obj }); return obj.x === obj; } catch (e) { /* this is IE 8. */ return false; } }; var descriptorsSupported = !!Object.defineProperty && arePropertyDescriptorsSupported(); var hasSymbols = typeof Symbol === 'function' && typeof Symbol('foo') === 'symbol'; test('defineProperties', function (dt) { dt.test('with descriptor support', { skip: !descriptorsSupported }, function (t) { var getDescriptor = function (value) { return { configurable: true, enumerable: false, value: value, writable: true }; }; var obj = { a: 1, b: 2, c: 3 }; t.deepEqual(keys(obj), ['a', 'b', 'c'], 'all literal-set keys start enumerable'); define(obj, { b: 3, c: 4, d: 5 }); t.deepEqual(obj, { a: 1, b: 2, c: 3 }, 'existing properties were not overridden'); t.deepEqual(Object.getOwnPropertyDescriptor(obj, 'd'), getDescriptor(5), 'new property "d" was added and is not enumerable'); t.deepEqual(['a', 'b', 'c'], keys(obj), 'new keys are not enumerable'); define(obj, { a: 2, b: 3, c: 4 }, { a: function () { return true; }, b: function () { return false; } }); t.deepEqual(obj, { b: 2, c: 3 }, 'properties only overriden when predicate exists and returns true'); t.deepEqual(Object.getOwnPropertyDescriptor(obj, 'd'), getDescriptor(5), 'existing property "d" remained and is not enumerable'); t.deepEqual(Object.getOwnPropertyDescriptor(obj, 'a'), getDescriptor(2), 'existing property "a" was overridden and is not enumerable'); t.deepEqual(['b', 'c'], keys(obj), 'overridden keys are not enumerable'); t.end(); }); dt.test('without descriptor support', { skip: descriptorsSupported }, function (t) { var obj = { a: 1, b: 2, c: 3 }; define(obj, { b: 3, c: 4, d: 5 }); t.deepEqual(obj, { a: 1, b: 2, c: 3, d: 5 }, 'existing properties were not overridden, new properties were added'); define(obj, { a: 2, b: 3, c: 4 }, { a: function () { return true; }, b: function () { return false; } }); t.deepEqual(obj, { a: 2, b: 2, c: 3, d: 5 }, 'properties only overriden when predicate exists and returns true'); t.end(); }); dt.end(); }); test('symbols', { skip: !hasSymbols }, function (t) { var sym = Symbol('foo'); var obj = {}; var aValue = {}; var bValue = {}; var properties = { a: aValue }; properties[sym] = bValue; define(obj, properties); t.deepEqual(Object.keys(obj), [], 'object has no enumerable keys'); t.deepEqual(Object.getOwnPropertyNames(obj), ['a'], 'object has non-enumerable "a" key'); t.deepEqual(Object.getOwnPropertySymbols(obj), [sym], 'object has non-enumerable symbol key'); t.equal(obj.a, aValue, 'string keyed value is defined'); t.equal(obj[sym], bValue, 'symbol keyed value is defined'); t.end(); });